Skip to main content

RenderSessionHandle

Struct RenderSessionHandle 

Source
pub struct RenderSessionHandle { /* private fields */ }
Expand description

Render session handle bound to the thread that attached it.

The session holds no Rust-level retention of its map. Native keeps the map alive instead: destroying a map fails while a session is attached to it.

Implementations§

Source§

impl RenderSessionHandle

Source

pub fn set_feature_state( &self, selector: &FeatureStateSelector, state: &[u8], ) -> Result<()>

Sets per-feature state on a render source for this session.

Source

pub fn get_feature_state( &self, selector: &FeatureStateSelector, ) -> Result<Vec<u8>>

Copies per-feature state from a render source in this session.

Source

pub fn remove_feature_state( &self, selector: &FeatureStateSelector, ) -> Result<()>

Removes per-feature state selected for this session.

Source

pub fn query_rendered_features( &self, geometry: &RenderedQueryGeometry, options: Option<&RenderedFeatureQueryOptions>, ) -> Result<Vec<QueriedFeature>>

Copies rendered features from the latest render session state.

Source

pub fn query_source_features( &self, source_id: &str, options: Option<&SourceFeatureQueryOptions>, ) -> Result<Vec<QueriedFeature>>

Copies source features from the latest render session state.

Source

pub fn query_feature_extension( &self, source_id: &str, feature: &[u8], extension: &str, extension_field: &str, arguments: Option<&[u8]>, ) -> Result<Vec<u8>>

Queries a feature extension as UTF-8 JSON or GeoJSON bytes.

Source§

impl RenderSessionHandle

Source

pub fn close(self) -> Result<(), HandleOperationError<Self>>

Explicitly destroys the render session.

Native destruction errors are returned. When destruction fails, the underlying native handle remains live so a later close can retry.

Source

pub fn resize(&self, width: u32, height: u32, scale_factor: f64) -> Result<()>

Resizes this attached render session.

Surface and owned-texture sessions resize in place, keeping the renderer and its state. A scale factor change starts a new renderer with renderer-held state empty. Borrowed texture targets report an unsupported-feature error; hand over a new texture with the backend’s set_*_borrowed_texture_target method instead.

Source

pub fn set_metal_surface_target( &self, descriptor: &MetalSurfaceDescriptor, ) -> Result<()>

Presents this attached surface session through a new surface, keeping this session’s renderer and its state.

The descriptor’s extent applies as a resize does. A context.device that is neither null nor this session’s device reports an invalid-argument error and leaves the current surface in place.

Source

pub fn set_vulkan_surface_target( &self, descriptor: &VulkanSurfaceDescriptor, ) -> Result<()>

Presents this attached surface session through a new surface.

See RenderSessionHandle::set_metal_surface_target for what replacing a surface preserves. The outgoing VkSurfaceKHR must still be valid: this session holds a swapchain built from it, and Vulkan destroys every swapchain before its surface.

Source

pub fn set_webgpu_surface_target( &self, descriptor: &WebGpuSurfaceDescriptor, ) -> Result<()>

Presents this attached surface session through a new WebGPU surface.

See RenderSessionHandle::set_metal_surface_target for what replacing a surface preserves. The replacement names the same device and format as the session attached with.

Source

pub fn set_opengl_surface_target( &self, descriptor: &OpenGLSurfaceDescriptor, ) -> Result<()>

Presents this attached surface session through a new surface.

See RenderSessionHandle::set_metal_surface_target for what replacing a surface preserves. The new surface is made current on the next render, so a host may hand over a replacement for one it has already destroyed. A surface accepted here can still prove unusable, which the next render_update reports rather than this call.

Source

pub fn set_metal_borrowed_texture_target( &self, descriptor: &MetalBorrowedTextureDescriptor, ) -> Result<()>

Renders this attached texture session into a new caller-owned texture, keeping this session’s renderer. A scale factor change starts a new renderer, as RenderSessionHandle::resize does.

The replacement must belong to the device this session attached with and carry the pixel format it attached with; otherwise this reports an error and leaves the current texture in place. The caller owns the replacement and keeps it valid until the next replacement, detach, or close. The outgoing texture is neither retained nor read here.

Source

pub fn set_vulkan_borrowed_texture_target( &self, descriptor: &VulkanBorrowedTextureDescriptor, ) -> Result<()>

Renders this attached texture session into a new caller-owned image.

See RenderSessionHandle::set_metal_borrowed_texture_target for what replacing a target preserves. The replacement carries the format and both layouts this session attached with, since its render pass was built around them.

Source

pub fn set_webgpu_borrowed_texture_target( &self, descriptor: &WebGpuBorrowedTextureDescriptor, ) -> Result<()>

Renders this attached texture session into a new caller-owned texture.

See RenderSessionHandle::set_metal_borrowed_texture_target for what replacing a target preserves. The replacement carries the format this session attached with, and belongs to the device it attached with.

Source

pub fn set_opengl_borrowed_texture_target( &self, descriptor: &OpenGLBorrowedTextureDescriptor, ) -> Result<()>

Renders this attached texture session into a new caller-owned texture.

See RenderSessionHandle::set_metal_borrowed_texture_target for what replacing a target preserves. The replacement belongs to the context this session attached with, or one in its share group, and the host context must be current on this thread.

Source

pub fn render_update(&self) -> Result<RenderUpdate>

Processes the latest map render update for this render target.

The map retains its latest update, so repeated calls re-render it and report RenderResult::Rendered again. Every other result names the wake to wait for: RenderResult::NoUpdate and RenderResult::SizePending resolve on a render-update-available event, and RenderResult::TargetNotReady resolves when the host changes the render target.

The returned RenderUpdate::needs_repaint reports whether the map asked for another frame while rendering this one, so a frame loop can re-arm without draining events first.

Source

pub fn detach( self, ) -> Result<DetachedRenderSessionHandle, HandleOperationError<Self>>

Detaches backend-bound render resources from the map, consuming this handle and returning a close-only handle.

A detached session no longer reaches its map, so the map is free to close and the detached session stays destroyable afterwards.

Source

pub fn reduce_memory_use(&self) -> Result<()>

Asks the session renderer to release cached resources where possible.

Source

pub fn clear_data(&self) -> Result<()>

Clears renderer data for the session.

Source

pub fn dump_debug_logs(&self) -> Result<()>

Dumps renderer debug logs through MapLibre Native logging.

Source

pub fn texture_image_info(&self) -> Result<TextureImageInfo>

Returns CPU readback metadata for the most recently rendered texture frame.

Source

pub fn read_premultiplied_rgba8_into( &self, data: &mut [u8], ) -> Result<TextureImageInfo>

Reads the most recently rendered texture frame as premultiplied RGBA8.

Source

pub fn acquire_metal_owned_texture_frame( &self, ) -> Result<MetalOwnedTextureFrameHandle>

Acquires a borrowed Metal frame from a session-owned texture target.

Source

pub fn acquire_vulkan_owned_texture_frame( &self, ) -> Result<VulkanOwnedTextureFrameHandle>

Acquires a borrowed Vulkan frame from a session-owned texture target.

Source

pub fn acquire_webgpu_owned_texture_frame( &self, ) -> Result<WebGpuOwnedTextureFrameHandle>

Acquires a borrowed WebGPU frame from a session-owned texture target.

Source

pub fn acquire_opengl_owned_texture_frame( &self, ) -> Result<OpenGLOwnedTextureFrameHandle>

Acquires a borrowed OpenGL frame from a session-owned texture target.

Trait Implementations§

Source§

impl Debug for RenderSessionHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.