Skip to main content

CompositionLayer

Trait CompositionLayer 

Source
pub trait CompositionLayer:
    Any
    + Send
    + Sync {
    // Required methods
    fn present(
        &self,
        buffer: Arc<dyn HardwareBuffer>,
        children: Vec<(Arc<dyn CompositionLayer>, Placement)>,
        released: Box<dyn FnOnce() + Send + Sync>,
    );
    fn current_picture(&self) -> Option<LayerPicture>;
}
Expand description

One layer of the compositor’s tree. Every method may be called from any thread.

The handle is the layer’s identity: a frame places the Arc itself, so only a layer that exists can be placed, and it lives while anything shows it. A host gets its own type back from a placed layer by downcasting through Any.

Required Methods§

Source

fn present( &self, buffer: Arc<dyn HardwareBuffer>, children: Vec<(Arc<dyn CompositionLayer>, Placement)>, released: Box<dyn FnOnce() + Send + Sync>, )

Shows buffer, which fills the layer, and children beneath it, the bottom-most first, from the compositor’s next frame on, in one step, in place of what the layer showed: the buffers presented before, or a layer the system draws into, such as a player’s, whose picture goes nowhere then. A layer shows one source at a time, the last given it. Each child lies where its placement says in the buffer’s pixels, as a scene places a layer in its view’s, so the buffer’s own placement moves, clips and scales it with it. A child the last present showed and this one does not name is let go; a layer another parent holds is not shown here, and is reported.

Returns once the host holds the buffer, not once it is on screen. released runs, on any thread, when the compositor has finished with the buffer and the producer may draw into it again, as Wayland’s wl_buffer.release; at once for a buffer another host handed out, which is not shown. On Apple platforms the host learns that from IOSurfaceIsInUse at the layer’s next present, or when the layer goes, so a producer there never waits for a buffer to come back: it draws into one it knows is free, or a new one. Core Animation takes no fence, so a producer that draws the buffer on the GPU presents it once that work is scheduled (waitUntilScheduled), as Chromium does before it hands Core Animation a surface.

Source

fn current_picture(&self) -> Option<LayerPicture>

What the layer shows now: the last buffer presented, or the current frame of the video or camera it shows. None while it shows nothing, and while it shows a layer the system draws into that the host does not read, such as one an app shows on it itself.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§