pub trait CompositionLayer:
Any
+ Send
+ Sync {
// Required method
fn present(
&self,
buffer: HardwareBuffer,
children: Vec<(Arc<dyn CompositionLayer>, Placement)>,
released: Box<dyn FnOnce() + Send + Sync>,
);
}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§
Sourcefn present(
&self,
buffer: HardwareBuffer,
children: Vec<(Arc<dyn CompositionLayer>, Placement)>,
released: Box<dyn FnOnce() + Send + Sync>,
)
fn present( &self, buffer: 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. 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. 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".