Skip to main content

ServerCompositor

Struct ServerCompositor 

Source
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

Source

pub fn pools(&self) -> &CompositorPools

The object pools of the tree walks.

Source

pub fn animations(&self) -> &ServerCompositorAnimations

The clock items and the animated objects of the compositor.

Source

pub fn last_batch_id(&self) -> i64

The sequence id of the batch applied last.

Source

pub fn clock_elapsed(&self) -> Duration

The time elapsed on the compositor clock.

Source

pub fn clock(&self) -> &CompositorClock

The compositor clock itself.

Source

pub fn server_now(&self) -> Duration

The compositor time of the frame being rendered.

Source

pub fn render_interface(&self) -> &Rc<PlatformRenderInterfaceContextManager>

Source

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.

Source

pub fn options(&self) -> &CompositionOptions

Source

pub fn readback(&self) -> &Arc<ReadbackIndices> ⓘ

The indices of the values the UI thread reads back from the server.

Source

pub fn get_object(&self, id: ServerObjectId) -> Option<Rc<dyn IServerObject>>

The server object with the given id, if it is alive.

Source

pub fn get<T: IServerObject>(&self, id: ServerObjectId) -> Option<Rc<T>>

The server object with the given id as its concrete type.

Source

pub fn get_animated_object( &self, id: ServerObjectId, ) -> Option<Rc<dyn IAnimatedServerObject>>

The server object with the given id as an animatable object.

Source

pub fn object_count(&self) -> usize

The number of live server objects.

Source

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.

Source

pub fn enqueue_visual_for_own_properties_update_pass( &self, visual: Rc<ServerCompositionVisual>, )

Source

pub fn enqueue_visual_for_readback_update_pass( &self, visual: Rc<ServerCompositionVisual>, )

Source

pub fn enqueue_adorner_update(&self, visual: Rc<ServerCompositionVisual>)

Source

pub fn add_composition_target(&self, target: &Rc<ServerCompositionTarget>)

Source

pub fn remove_composition_target(&self, target: &Rc<ServerCompositionTarget>)

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

Source

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.

Source

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.

Source

pub fn reset_all_gpu_resources(&self)

Source

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.

Source

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.

Source

pub fn is_rendering_stopped(&self) -> bool

Whether stop_rendering was called.

Source

pub fn invalidate_all_composition_targets(&self)

Source

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.

Source

pub fn verify_access(&self)

Panics when the caller may not access the objects of the compositor (see check_access).

Source

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.

Source

pub fn render(&self) -> bool

Runs one frame: applies the pending batches, runs the global passes and the queued jobs. Returns whether another tick is needed even if nothing else wakes the render loop up.

Panics on reentrancy.

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.