pub struct RenderSessionHandle { /* private fields */ }Expand description
Owns one native handle.
A render session draws a map into a surface or a texture.
See mln_render_session in the
C API reference.
Implementations§
Source§impl RenderSessionHandle
impl RenderSessionHandle
Sourcepub fn abandon(&self) -> Result<RenderAbandonResult>
pub fn abandon(&self) -> Result<RenderAbandonResult>
Stops the session right away, without running its pending graphics work.
Use it when the target’s graphics objects are going away and a detach
can’t finish first. Pending work completes with Status::TargetLost,
and pending frame demands finish with RenderResult::TargetNotReady.
Once the call returns, the library no longer uses your graphics objects,
and you can attach another session to the map. Release the session
afterward.
Abandon keeps the session’s OpenGL and WebGPU objects until the process exits, and reports how many it kept. Detach the session instead to free them.
See mln_render_session_abandon in the
C API reference.
Sourcepub fn acquire_frame(&self) -> Result<Option<AcquiredFrameHandle>>
pub fn acquire_frame(&self) -> Result<Option<AcquiredFrameHandle>>
Takes the newest rendered frame from the session’s texture ring, if one is ready.
Older frames that you haven’t acquired are dropped, and the session can render over a frame before you acquire it. While you hold a frame in every texture of the ring, new frames wait until you release one. When no frame is ready, it succeeds and writes the null handle.
See mln_render_session_acquire_frame in the
C API reference.
§Errors
Status::Unsupportedwhen the session lacksRenderSessionCapabilityFlag::FRAME_ACQUISITION.Status::TargetLostorStatus::NativeError, asRenderSessionSnapshot::failure_statusreports, when the session has failed.Status::InvalidStatewhen you detached, abandoned, released, or disposed the session.
Sourcepub fn barrier(&self) -> Result<NativeFuture<()>>
pub fn barrier(&self) -> Result<NativeFuture<()>>
Ends the session’s pending frame demands and waits for its earlier work.
Frame demands that haven’t started, including those that wait for a map
update, finish with RenderResult::NoUpdate.
See mln_render_session_barrier in the
C API reference.
§Errors
Status::TargetLostwhen the session loses its target before the barrier runs.
Sourcepub fn clear_data(&self) -> Result<NativeFuture<()>>
pub fn clear_data(&self) -> Result<NativeFuture<()>>
Clears the data that the session’s renderer holds, such as loaded tiles, and draws the map again.
See mln_render_session_clear_data in the
C API reference.
§Errors
Status::TargetLostwhen the session loses its target before the work runs.
Sourcepub fn demand_frame(&self, demand: &FrameDemand) -> Result<()>
pub fn demand_frame(&self, demand: &FrameDemand) -> Result<()>
Asks the session to render a frame.
The frame shows the map commands that you sent before the call, except the changes that an open command group holds back.
You can call it once the attach call returns. While the attach runs, the
demand waits for it to complete. Every demand finishes with one frame
result that carries its token, and
RenderSessionHandle::drain_frame_results() takes it. A demand without
FrameDemandFlag::FORCE replaces each pending demand with the same
flags.
See mln_render_session_demand_frame in the
C API reference.
§Errors
Status::TargetLostorStatus::NativeError, asRenderSessionSnapshot::failure_statusreports, when the session has failed.Status::InvalidStatewhen you detached, abandoned, released, or disposed the session, or discarded a frame from every texture of its ring.
Sourcepub fn detach(&self) -> Result<NativeFuture<()>>
pub fn detach(&self) -> Result<NativeFuture<()>>
Detaches the session from its map and frees its graphics objects.
Release every acquired frame first. Pending frame demands finish with
RenderResult::TargetNotReady. Once the detach completes, the library
no longer uses your graphics objects, and you can attach another session
to the map. Release the session afterward.
See mln_render_session_detach in the
C API reference.
§Errors
Status::TargetLostwhen the session loses its target before the detach runs.
Sourcepub fn dispose(self) -> Result<RetiringRenderSession, ReleaseError<Self>>
pub fn dispose(self) -> Result<RetiringRenderSession, ReleaseError<Self>>
Releases the session in any state, and finishes in the background.
Use it from destructors and finalizers, and
RenderSessionHandle::release() elsewhere. It ends the session as a
release does, except that it abandons a session whose frames you hold,
which ends those frames. Keep servicing a session driven by
RenderDriverKind::CallerGraphicsThread until
RenderSessionHandle::service_driver_work() no longer accepts it.
See mln_render_session_dispose in the
C API reference.
Sourcepub fn drain_frame_results(&self) -> Result<Vec<RenderFrameResult>>
pub fn drain_frame_results(&self) -> Result<Vec<RenderFrameResult>>
Takes the frame results that the session has queued.
When no result is queued, it succeeds and writes the null handle and an empty view.
See mln_render_session_drain_frame_results in the
C API reference.
Sourcepub fn dump_debug_logs(&self) -> Result<NativeFuture<()>>
pub fn dump_debug_logs(&self) -> Result<NativeFuture<()>>
Logs debugging information about the session’s renderer.
See mln_render_session_dump_debug_logs in the
C API reference.
§Errors
Status::TargetLostwhen the session loses its target before the work runs.
Sourcepub fn get_capabilities(&self) -> Result<RenderSessionCapabilities>
pub fn get_capabilities(&self) -> Result<RenderSessionCapabilities>
Reads what the session supports.
See mln_render_session_get_capabilities in the
C API reference.
Sourcepub fn get_cluster_children(
&self,
source_id: &str,
cluster_id: u32,
) -> Result<NativeFuture<String>>
pub fn get_cluster_children( &self, source_id: &str, cluster_id: u32, ) -> Result<NativeFuture<String>>
Reads the children of a cluster in a clustered GeoJSON source.
cluster_id is the “cluster_id” property of a cluster feature. The
result is a GeoJSON feature collection of the clusters and points that
the cluster splits into at the next zoom level.
The query reads the source’s data from the session’s most recent render attempt, so a change to the data shows once the session tries to render again.
A cluster ID belongs to one version of the source’s data. After the data
changes, feature queries can return IDs from the earlier version until
the source’s tiles reload, and such an ID completes with
Status::NotFound or names a different cluster. Query the features
again for current IDs.
See mln_render_session_get_cluster_children in the
C API reference.
§Errors
Status::NotFoundwhen the session’s most recent render attempt had no source namedsource_id, or the source has no clustercluster_id.Status::InvalidArgumentwhen the source isn’t a GeoJSON source with clustering turned on.
Sourcepub fn get_cluster_expansion_zoom(
&self,
source_id: &str,
cluster_id: u32,
) -> Result<NativeFuture<u32>>
pub fn get_cluster_expansion_zoom( &self, source_id: &str, cluster_id: u32, ) -> Result<NativeFuture<u32>>
Reads the zoom level at which a cluster of a clustered GeoJSON source splits.
cluster_id is the “cluster_id” property of a cluster feature. At the
result’s zoom level, the cluster splits into two or more clusters or
points.
A cluster ID can go out of date as
RenderSessionHandle::get_cluster_children() describes.
See mln_render_session_get_cluster_expansion_zoom in the
C API reference.
§Errors
Status::NotFoundwhen the session’s most recent render attempt had no source namedsource_id, or the source has no clustercluster_id.Status::InvalidArgumentwhen the source isn’t a GeoJSON source with clustering turned on.
Sourcepub fn get_cluster_leaves(
&self,
source_id: &str,
cluster_id: u32,
limit: u32,
offset: u32,
) -> Result<NativeFuture<String>>
pub fn get_cluster_leaves( &self, source_id: &str, cluster_id: u32, limit: u32, offset: u32, ) -> Result<NativeFuture<String>>
Reads the points in a cluster of a clustered GeoJSON source.
cluster_id is the “cluster_id” property of a cluster feature. The
result is a GeoJSON feature collection of the original point features.
It skips the first offset points and then holds up to limit of them,
so a limit of 0 gives an empty collection.
A cluster ID can go out of date as
RenderSessionHandle::get_cluster_children() describes.
See mln_render_session_get_cluster_leaves in the
C API reference.
§Errors
Status::NotFoundwhen the session’s most recent render attempt had no source namedsource_id, or the source has no clustercluster_id.Status::InvalidArgumentwhen the source isn’t a GeoJSON source with clustering turned on.
Sourcepub fn get_failure(&self) -> Result<String>
pub fn get_failure(&self) -> Result<String>
Reads the message of the error that made the session fail.
RenderSessionSnapshot::failure_status reports the error’s status. The
message is empty while the session hasn’t failed, and doesn’t change
once it fails.
See mln_render_session_get_failure in the
C API reference.
Sourcepub fn get_snapshot(&self) -> Result<RenderSessionSnapshot>
pub fn get_snapshot(&self) -> Result<RenderSessionSnapshot>
Reads the session’s current state.
See mln_render_session_get_snapshot in the
C API reference.
Sourcepub fn query_rendered_features(
&self,
geometry: &RenderedQueryGeometry,
options: Option<&RenderedFeatureQueryOptions<'_>>,
) -> Result<NativeFuture<Vec<RenderedFeature>>>
pub fn query_rendered_features( &self, geometry: &RenderedQueryGeometry, options: Option<&RenderedFeatureQueryOptions<'_>>, ) -> Result<NativeFuture<Vec<RenderedFeature>>>
Finds the features that the session drew in an area of the screen.
The query reads the last frame that the session rendered. A feature that several layers draw appears once for each layer.
See mln_render_session_query_rendered_features in the
C API reference.
Sourcepub fn query_source_features(
&self,
source_id: &str,
options: Option<&SourceFeatureQueryOptions<'_>>,
) -> Result<NativeFuture<Vec<SourceFeature>>>
pub fn query_source_features( &self, source_id: &str, options: Option<&SourceFeatureQueryOptions<'_>>, ) -> Result<NativeFuture<Vec<SourceFeature>>>
Finds the features of the source named source_id.
The query covers only the tiles that the source has loaded for the current view. A source loads tiles only while a visible layer uses it.
See mln_render_session_query_source_features in the
C API reference.
Sourcepub fn read_texture(&self) -> Result<NativeFuture<TextureReadbackResult>>
pub fn read_texture(&self) -> Result<NativeFuture<TextureReadbackResult>>
Reads the pixels of the last frame that the session rendered.
See mln_render_session_read_texture in the
C API reference.
§Errors
Status::Unsupportedwhen the session’s capabilities lackRenderSessionCapabilityFlag::READBACK.Status::InvalidStatewhen the session hasn’t rendered a frame since it attached, resized, or changed its target.
Sourcepub fn reduce_memory_use(&self) -> Result<NativeFuture<()>>
pub fn reduce_memory_use(&self) -> Result<NativeFuture<()>>
Frees memory that the session’s renderer can rebuild, such as caches.
See mln_render_session_reduce_memory_use in the
C API reference.
§Errors
Status::TargetLostwhen the session loses its target before the work runs.
Sourcepub fn release(
self,
) -> Result<(NativeFuture<()>, RetiringRenderSession), ReleaseError<Self>>
pub fn release( self, ) -> Result<(NativeFuture<()>, RetiringRenderSession), ReleaseError<Self>>
Releases the session, detaching it first when it is attached.
Pending frame demands finish with RenderResult::TargetNotReady. Once
the release completes, the library no longer uses your graphics objects,
and you can attach another session to the map.
A session driven by RenderDriverKind::CallerGraphicsThread detaches at
your next RenderSessionHandle::service_driver_work(), so keep
servicing it until the release completes. When the session isn’t
attached, such as while it attaches or after it fails, or when you
release or dispose its map before that service, the release abandons it
as RenderSessionHandle::abandon() does.
See mln_render_session_release in the
C API reference.
§Errors
Status::InvalidStatewhile you hold one of the session’s acquired frames. Release or discard them first.
Sourcepub fn release_target(&self) -> Result<NativeFuture<()>>
pub fn release_target(&self) -> Result<NativeFuture<()>>
Lets go of the session’s surface or textures, and keeps the rest of the session.
Use it when the platform takes a surface away, such as when your app
goes to the background. Release every acquired frame first. Frame
demands that are still pending, and later ones until you give the
session a new target, finish with RenderResult::TargetNotReady. Once
the release completes, you can destroy the old target. An Android or
OpenHarmony window can go away sooner, as
MapHandle::attach_android_surface() and
MapHandle::attach_ohos_surface() say.
See mln_render_session_release_target in the
C API reference.
§Errors
Status::Unsupportedwhen the session renders offscreen or into Android hardware buffers, dmabufs, DXGI shared textures, or IOSurfaces that it allocates.Status::Unsupportedwhen the target is a WebGL canvas.Status::TargetLostwhen the session loses its target before the release runs.
Sourcepub fn resize(
&self,
logical_size: LogicalSize,
) -> Result<NativeFuture<CommandCompletion>>
pub fn resize( &self, logical_size: LogicalSize, ) -> Result<NativeFuture<CommandCompletion>>
Resizes the session’s target and its map.
The session renders at the map’s scale factor. Release every acquired frame first.
See mln_render_session_resize in the
C API reference.
§Errors
Status::Unsupportedwhen the session renders into a borrowed ring. Give it new textures of the new size instead.Status::TargetLostwhen the session loses its target before the resize applies.
Sourcepub fn service_driver_work(&self) -> Result<()>
pub fn service_driver_work(&self) -> Result<()>
Runs the session’s ready graphics work on your graphics thread.
Use it with RenderDriverKind::CallerGraphicsThread, and call it from
the same thread every time. Call it each time
RenderSessionAttachOptions::driver_work_wake is called, even while you
demand no frames, until a detach, release, or disposal of the session
finishes. It returns once no work is ready.
It accepts a released or disposed session until that release or disposal finishes.
See mln_render_session_service_driver_work in the
C API reference.
Sourcepub fn set_frame_pacer(&self, pacer: Option<&FramePacerHandle>) -> Result<()>
pub fn set_frame_pacer(&self, pacer: Option<&FramePacerHandle>) -> Result<()>
Sets the frame pacer that demands the session’s frames.
At the first display refresh after the session has something new to
draw, pacer demands a frame without flags and with token 0. One pacer
can serve many sessions. A null pacer stops pacing the session. You
can call it once the attach call returns.
See mln_render_session_set_frame_pacer in the
C API reference.
§Errors
Status::TargetLostorStatus::NativeError, asRenderSessionSnapshot::failure_statusreports, when the session has failed.Status::InvalidStatewhen you attached the session with a redraw wake, or detached, abandoned, released, or disposed it.
Sourcepub unsafe fn set_open_gl_borrowed_texture_target(
&self,
replacement: &OpenGlBorrowedTextureReplacement,
) -> Result<NativeFuture<()>>
pub unsafe fn set_open_gl_borrowed_texture_target( &self, replacement: &OpenGlBorrowedTextureReplacement, ) -> Result<NativeFuture<()>>
Replaces the OpenGL textures that a borrowed ring renders into.
Use it to resize the ring, or to give the session textures again after
RenderSessionHandle::release_target(). Release every acquired frame
first. Once the replacement completes, the session no longer uses the
old textures.
See mln_render_session_set_open_gl_borrowed_texture_target in the
C API reference.
§Safety
Native graphics objects must have the types, lifetimes, and synchronization required by the C operation.
Sourcepub unsafe fn set_open_gl_surface_target(
&self,
replacement: &OpenGlSurfaceReplacement,
) -> Result<NativeFuture<()>>
pub unsafe fn set_open_gl_surface_target( &self, replacement: &OpenGlSurfaceReplacement, ) -> Result<NativeFuture<()>>
Replaces the OpenGL surface that the session presents to.
Use it to give the session a surface again after
RenderSessionHandle::release_target(), to move it to another surface,
or to resize it. Once the replacement completes, the session no longer
uses the old surface.
See mln_render_session_set_open_gl_surface_target in the
C API reference.
§Safety
Native graphics objects must have the types, lifetimes, and synchronization required by the C operation.
Sourcepub unsafe fn set_vulkan_borrowed_texture_target(
&self,
replacement: &VulkanBorrowedTextureReplacement,
) -> Result<NativeFuture<()>>
pub unsafe fn set_vulkan_borrowed_texture_target( &self, replacement: &VulkanBorrowedTextureReplacement, ) -> Result<NativeFuture<()>>
Replaces the Vulkan images that a borrowed ring renders into.
Use it to resize the ring, or to give the session images again after
RenderSessionHandle::release_target(). Release every acquired frame
first. Once the replacement completes, the session no longer uses the
old images.
See mln_render_session_set_vulkan_borrowed_texture_target in the
C API reference.
§Safety
Native graphics objects must have the types, lifetimes, and synchronization required by the C operation.
Sourcepub unsafe fn set_vulkan_surface_target(
&self,
replacement: &VulkanSurfaceReplacement,
) -> Result<NativeFuture<()>>
pub unsafe fn set_vulkan_surface_target( &self, replacement: &VulkanSurfaceReplacement, ) -> Result<NativeFuture<()>>
Replaces the Vulkan surface that the session presents to.
Use it to give the session a surface again after
RenderSessionHandle::release_target(), to move it to another surface,
or to resize it. Once the replacement completes, the session no longer
uses the old surface.
See mln_render_session_set_vulkan_surface_target in the
C API reference.
§Errors
Status::Unsupportedwhen the new surface needs a different color format or pre-rotation support than the old one. Attach a new session instead.
§Safety
Native graphics objects must have the types, lifetimes, and synchronization required by the C operation.
Sourcepub unsafe fn set_wayland_surface_target(
&self,
replacement: &WaylandSurfaceReplacement,
) -> Result<NativeFuture<()>>
pub unsafe fn set_wayland_surface_target( &self, replacement: &WaylandSurfaceReplacement, ) -> Result<NativeFuture<()>>
Replaces the Wayland surface that the session presents to.
Use it to give the session a surface again after
RenderSessionHandle::release_target(), to move it to another surface,
or to resize it. Once the replacement completes, the session no longer
uses the old surface.
See mln_render_session_set_wayland_surface_target in the
C API reference.
§Errors
Status::Unsupportedwhen, in a Vulkan build, the new surface needs a different color format than the old one. Attach a new session instead.Status::NativeErrorwhen the library can’t present to the new surface.
§Safety
Native graphics objects must have the types, lifetimes, and synchronization required by the C operation.
Source§impl RenderSessionHandle
impl RenderSessionHandle
pub fn discarding(&self) -> RenderSessionHandleDiscarding<'_>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RenderSessionHandle
impl RefUnwindSafe for RenderSessionHandle
impl Send for RenderSessionHandle
impl Sync for RenderSessionHandle
impl Unpin for RenderSessionHandle
impl UnsafeUnpin for RenderSessionHandle
impl UnwindSafe for RenderSessionHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more