Skip to main content

Compositor

Struct Compositor 

Source
pub struct Compositor { /* private fields */ }
Expand description

Compositor for overlay framebuffer management.

Supports two restore modes:

  • Pristine restore: copies from a fixed reference framebuffer (fast, no allocation)
  • Save-under: saves pixels on show, restores on hide (handles dynamic content)

All public methods accept landscape draw coordinates; the compositor transforms to portrait framebuffer coordinates internally.

Implementations§

Source§

impl Compositor

Source

pub fn new(fb_width: u32, fb_height: u32, pristine_addr: u32) -> Self

Create a new compositor for the given portrait framebuffer dimensions.

pristine_addr is the address of a reference background copy in SDRAM (e.g. the desktop image). Pass 0 if no pristine copy is available.

Source

pub fn register_overlay(&mut self) -> u32

Allocate an overlay ID for save-under management.

Source

pub unsafe fn save( &mut self, overlay_id: u32, draw_rect: Rect, front_buffer: *const u8, )

Save the framebuffer pixels under an overlay region.

Call when an overlay becomes visible. draw_rect is in landscape draw coordinates. Reads from the front buffer (what’s currently displayed) since the back buffer may not have been rendered yet.

§Safety

front_buffer must point to a valid framebuffer.

Source

pub fn mark_pristine_restore(&mut self, draw_rect: Rect)

Queue restoration from the pristine background copy.

Use this for overlays over static backgrounds (desktop image). No heap allocation — reads directly from the pristine fb address. Queue restoration from pristine for multiple frames (double-buffer).

Source

pub fn mark_restore(&mut self, overlay_id: u32)

Queue restoration of the saved pixels for an overlay.

Call when an overlay hides. The actual restore happens on the next restore() call. The save buffer is consumed.

Source

pub unsafe fn restore(&mut self, back_buffer: *mut u8)

Restore all pending save-under regions to the back buffer.

Call before drawing the widget tree each frame.

§Safety

back_buffer must point to a valid framebuffer.

Source

pub fn has_pending(&self) -> bool

Whether there are pending restores of any kind.

Source

pub fn diag_counts(&self) -> u32

Return a packed summary of compositor queue state.

Source

pub fn diag_bytes(&self) -> u32

Return the most recent restore sequence and byte count.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.