Skip to main content

PlatformRenderInterfaceContextManager

Struct PlatformRenderInterfaceContextManager 

Source
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

Source

pub fn new( graphics: Option<Arc<dyn IPlatformGraphics>>, ) -> Rc<PlatformRenderInterfaceContextManager>

Source

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.

Source

pub fn has_platform_render_interface(&self) -> bool

Whether the render interface of the platform is known.

Source

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.

Source

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.

Source

pub fn context_disposed( &self, handler: impl Fn() + 'static, ) -> Rc<dyn IDisposable>

Raised after a lost graphics context has been released.

Source

pub fn context_created( &self, handler: impl Fn(&Rc<dyn IPlatformRenderInterfaceContext>) + 'static, ) -> Rc<dyn IDisposable>

Raised after a backend context has been created.

Source

pub fn is_ready(&self) -> bool

Source

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.

Source

pub fn value(&self) -> Rc<dyn IPlatformRenderInterfaceContext>

The backend context; created (or recreated) when needed.

Source

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).

Source

pub fn gpu_context(&self) -> Option<Rc<dyn IPlatformGraphicsContext>>

The graphics context the backend context is bound to, if any.

Source

pub fn ensure_current(&self) -> Rc<dyn IDisposable>

Makes the graphics context current. Disposing the result restores the previously current context.

Source

pub fn create_render_target( &self, surfaces: &[Arc<dyn IPlatformRenderSurface>], ) -> Rc<dyn IRenderTarget>

Source

pub fn is_ready_to_create_render_target( &self, surfaces: &[Arc<dyn IPlatformRenderSurface>], ) -> bool

Source

pub fn reset(&self)

Releases the backend context; the next use creates a new one.

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.