pub struct ServerCompositor { /* private fields */ }Expand description
Server-side counterpart of the compositor: owns the server objects, applies the batches committed by the UI thread and renders.
Confined to the render thread. UI-thread code interacts with it only by enqueueing batches (and by reading the clock and the readback indices, which are thread-safe values).
Implementations§
Source§impl ServerCompositor
impl ServerCompositor
Sourcepub fn pools(&self) -> &CompositorPools
pub fn pools(&self) -> &CompositorPools
The object pools of the tree walks.
Sourcepub fn animations(&self) -> &ServerCompositorAnimations
pub fn animations(&self) -> &ServerCompositorAnimations
The clock items and the animated objects of the compositor.
Sourcepub fn last_batch_id(&self) -> i64
pub fn last_batch_id(&self) -> i64
The sequence id of the batch applied last.
Sourcepub fn clock_elapsed(&self) -> Duration
pub fn clock_elapsed(&self) -> Duration
The time elapsed on the compositor clock.
Sourcepub fn clock(&self) -> &CompositorClock
pub fn clock(&self) -> &CompositorClock
The compositor clock itself.
Sourcepub fn server_now(&self) -> Duration
pub fn server_now(&self) -> Duration
The compositor time of the frame being rendered.
pub fn render_interface(&self) -> &Rc<PlatformRenderInterfaceContextManager>
Sourcepub fn diagnostic_text_renderer(&self) -> Option<Rc<DiagnosticTextRenderer>>
pub fn diagnostic_text_renderer(&self) -> Option<Rc<DiagnosticTextRenderer>>
The text renderer of the debug overlays, shared by the targets.
It can only be created on a thread that has the font manager (the UI thread; upstream’s services are global and the first overlay creates it wherever it is drawn). The compositor asks for it under the lock when debug overlays are switched on; a frame of the render thread uses what is there and draws no overlay text until then.
pub fn options(&self) -> &CompositionOptions
Sourcepub fn readback(&self) -> &Arc<ReadbackIndices> ⓘ
pub fn readback(&self) -> &Arc<ReadbackIndices> ⓘ
The indices of the values the UI thread reads back from the server.
Sourcepub fn get_object(&self, id: ServerObjectId) -> Option<Rc<dyn IServerObject>>
pub fn get_object(&self, id: ServerObjectId) -> Option<Rc<dyn IServerObject>>
The server object with the given id, if it is alive.
Sourcepub fn get<T: IServerObject>(&self, id: ServerObjectId) -> Option<Rc<T>>
pub fn get<T: IServerObject>(&self, id: ServerObjectId) -> Option<Rc<T>>
The server object with the given id as its concrete type.
Sourcepub fn get_animated_object(
&self,
id: ServerObjectId,
) -> Option<Rc<dyn IAnimatedServerObject>>
pub fn get_animated_object( &self, id: ServerObjectId, ) -> Option<Rc<dyn IAnimatedServerObject>>
The server object with the given id as an animatable object.
Sourcepub fn object_count(&self) -> usize
pub fn object_count(&self) -> usize
The number of live server objects.
Sourcepub fn enqueue_render_resource_for_invalidation(
&self,
resource: Rc<dyn IServerRenderResource>,
)
pub fn enqueue_render_resource_for_invalidation( &self, resource: Rc<dyn IServerRenderResource>, )
Queues a render resource whose observers must be told that it changed, once per frame.
pub fn enqueue_visual_for_own_properties_update_pass( &self, visual: Rc<ServerCompositionVisual>, )
pub fn enqueue_visual_for_readback_update_pass( &self, visual: Rc<ServerCompositionVisual>, )
pub fn enqueue_adorner_update(&self, visual: Rc<ServerCompositionVisual>)
pub fn add_composition_target(&self, target: &Rc<ServerCompositionTarget>)
pub fn remove_composition_target(&self, target: &Rc<ServerCompositionTarget>)
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
Sourcepub fn at_try_get_cached_render_interface_features(
&self,
) -> Option<Rc<HashMap<TypeId, Rc<dyn Any>>>>
pub fn at_try_get_cached_render_interface_features( &self, ) -> Option<Rc<HashMap<TypeId, Rc<dyn Any>>>>
The public features of the render interface, if a backend context exists (callable from any place that can reach the compositor).
Sourcepub fn rt_get_render_interface_features(
&self,
) -> Rc<HashMap<TypeId, Rc<dyn Any>>>
pub fn rt_get_render_interface_features( &self, ) -> Rc<HashMap<TypeId, Rc<dyn Any>>>
The public features of the render interface; creates the backend context when needed.
Sourcepub fn create_composition_visual_snapshot(
&self,
visual: &Rc<ServerCompositionVisual>,
scaling: f64,
render_children: bool,
) -> Arc<SharedBitmapImpl> ⓘ
pub fn create_composition_visual_snapshot( &self, visual: &Rc<ServerCompositionVisual>, scaling: f64, render_children: bool, ) -> Arc<SharedBitmapImpl> ⓘ
Renders a visual (and, with render_children, its subtree) into a
new bitmap.
pub fn reset_all_gpu_resources(&self)
Sourcepub fn release_gpu_resources(&self)
pub fn release_gpu_resources(&self)
Releases what the compositor draws with, while its graphics context is current: the layer and the render target of every active target, then the backend context. The context that was current before is restored. Does nothing when no backend context was ever created, and nothing for a graphics context that is lost (nothing can be released in it).
For the two places where these objects go for good: before the graph of a compositor is dropped, and when the surface the compositor draws to is closed. An object of a graphics interface with a current context (OpenGL) is deleted in whatever context is current when it is dropped: with none current the call fails, and with the context of another compositor current it deletes an object of that one. Once the backend context is released here, what is dropped later touches no graphics context.
Unlike reset_all_gpu_resources,
nothing is asked for that may have to be created: it also works for
graphics that are not ready, and after the compositor has taken its
platform handles back.
Not from upstream, where these objects are finalized by the garbage collector, on the thread of the context.
Sourcepub fn stop_rendering(&self)
pub fn stop_rendering(&self)
Ends the rendering of the compositor for good: from here on a frame applies the batches that arrive (so that whoever waits for one is answered), drops the jobs they carry, renders nothing and does not ask for another tick.
For a compositor whose surface is closed while the compositor lives on: its graphics would be “not ready” for ever, and a compositor that is not ready asks for the next tick each time. Upstream’s browser backend takes the server compositor out of the render loop at that point; here the compositor stays in the loop, because the thread of the compositor still waits for the batch that disposes its target.
Sourcepub fn is_rendering_stopped(&self) -> bool
pub fn is_rendering_stopped(&self) -> bool
Whether stop_rendering was called.
pub fn invalidate_all_composition_targets(&self)
Sourcepub fn check_access(&self) -> bool
pub fn check_access(&self) -> bool
Whether the caller may access the objects of the compositor: whether the compositor is rendering a frame. Upstream the frame is rendered under the compositor lock by the thread that holds it.
Sourcepub fn verify_access(&self)
pub fn verify_access(&self)
Panics when the caller may not access the objects of the compositor
(see check_access).
Sourcepub fn verify_access_of(
compositor: Option<&Rc<ServerCompositor>>,
) -> Rc<ServerCompositor>
pub fn verify_access_of( compositor: Option<&Rc<ServerCompositor>>, ) -> Rc<ServerCompositor>
verify_access of a compositor that may be
gone: no frame of a compositor that is gone is being rendered.
Returns the compositor.
Auto Trait Implementations§
impl !Freeze for ServerCompositor
impl !RefUnwindSafe for ServerCompositor
impl !Send for ServerCompositor
impl !Sync for ServerCompositor
impl !UnwindSafe for ServerCompositor
impl Unpin for ServerCompositor
impl UnsafeUnpin for ServerCompositor
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