pub struct PlatformRenderInterfaceContextManager { /* private fields */ }Expand description
Owns the backend render context of a renderer and recreates it (together with the graphics context it is bound to) when it is lost.
Like the platform contracts it manages, it is confined to the thread it was created on.
Implementations§
Source§impl PlatformRenderInterfaceContextManager
impl PlatformRenderInterfaceContextManager
pub fn new( graphics: Option<Arc<dyn IPlatformGraphics>>, ) -> Rc<PlatformRenderInterfaceContextManager>
Sourcepub fn capture_platform_render_interface(&self)
pub fn capture_platform_render_interface(&self)
Looks the render interface of the platform up in the service locator of the calling thread, if it is not known yet. Called on the thread that has the services (the UI thread), before a frame of another thread needs the render interface.
Sourcepub fn has_platform_render_interface(&self) -> bool
pub fn has_platform_render_interface(&self) -> bool
Whether the render interface of the platform is known.
Sourcepub fn with_platform_render_interface<R>(
&self,
f: impl FnOnce(&dyn IPlatformRenderInterface) -> R,
) -> Option<R>
pub fn with_platform_render_interface<R>( &self, f: impl FnOnce(&dyn IPlatformRenderInterface) -> R, ) -> Option<R>
Runs f with the render interface of the platform, if it is known.
The render interface is lent, not handed out: its handle is shared with the service locator of the UI thread, whose count is not atomic, so a frame of the render thread must neither clone nor release it.
Sourcepub fn release_platform_handles(&self)
pub fn release_platform_handles(&self)
Lets go of the handles the manager shares with the thread that created it: the platform graphics, its ready state feature and the render interface. The count of the render interface is not atomic, so its handle is dropped here, by that thread, when the rest of the manager is about to be released by the render thread (a compositor that is confined to it). The other two may be dropped by any thread and go with it: the manager creates no backend context afterwards.
Sourcepub fn context_disposed(
&self,
handler: impl Fn() + 'static,
) -> Rc<dyn IDisposable>
pub fn context_disposed( &self, handler: impl Fn() + 'static, ) -> Rc<dyn IDisposable>
Raised after a lost graphics context has been released.
Sourcepub fn context_created(
&self,
handler: impl Fn(&Rc<dyn IPlatformRenderInterfaceContext>) + 'static,
) -> Rc<dyn IDisposable>
pub fn context_created( &self, handler: impl Fn(&Rc<dyn IPlatformRenderInterfaceContext>) + 'static, ) -> Rc<dyn IDisposable>
Raised after a backend context has been created.
pub fn is_ready(&self) -> bool
Sourcepub fn ensure_valid_backend_context(&self)
pub fn ensure_valid_backend_context(&self)
Makes sure there is a backend context that is not lost.
§Panics
Panics when the platform graphics are not ready yet.
Sourcepub fn value(&self) -> Rc<dyn IPlatformRenderInterfaceContext>
pub fn value(&self) -> Rc<dyn IPlatformRenderInterfaceContext>
The backend context; created (or recreated) when needed.
Sourcepub fn existing_backend_context(
&self,
) -> Option<Rc<dyn IPlatformRenderInterfaceContext>>
pub fn existing_backend_context( &self, ) -> Option<Rc<dyn IPlatformRenderInterfaceContext>>
The backend context if there is one, as it is: nothing is created, and a lost context is not replaced. For a thread that may look at the context but must not create one (the thread of a compositor that is confined to its render thread).
Sourcepub fn gpu_context(&self) -> Option<Rc<dyn IPlatformGraphicsContext>>
pub fn gpu_context(&self) -> Option<Rc<dyn IPlatformGraphicsContext>>
The graphics context the backend context is bound to, if any.
Sourcepub fn ensure_current(&self) -> Rc<dyn IDisposable>
pub fn ensure_current(&self) -> Rc<dyn IDisposable>
Makes the graphics context current. Disposing the result restores the previously current context.
pub fn create_render_target( &self, surfaces: &[Arc<dyn IPlatformRenderSurface>], ) -> Rc<dyn IRenderTarget>
pub fn is_ready_to_create_render_target( &self, surfaces: &[Arc<dyn IPlatformRenderSurface>], ) -> bool
Auto Trait Implementations§
impl !Freeze for PlatformRenderInterfaceContextManager
impl !RefUnwindSafe for PlatformRenderInterfaceContextManager
impl !Send for PlatformRenderInterfaceContextManager
impl !Sync for PlatformRenderInterfaceContextManager
impl !UnwindSafe for PlatformRenderInterfaceContextManager
impl Unpin for PlatformRenderInterfaceContextManager
impl UnsafeUnpin for PlatformRenderInterfaceContextManager
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more