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
impl Compositor
Sourcepub fn new(fb_width: u32, fb_height: u32, pristine_addr: u32) -> Self
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.
Sourcepub fn register_overlay(&mut self) -> u32
pub fn register_overlay(&mut self) -> u32
Allocate an overlay ID for save-under management.
Sourcepub unsafe fn save(
&mut self,
overlay_id: u32,
draw_rect: Rect,
front_buffer: *const u8,
)
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.
Sourcepub fn mark_pristine_restore(&mut self, draw_rect: Rect)
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).
Sourcepub fn mark_restore(&mut self, overlay_id: u32)
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.
Sourcepub unsafe fn restore(&mut self, back_buffer: *mut u8)
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.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Whether there are pending restores of any kind.
Sourcepub fn diag_counts(&self) -> u32
pub fn diag_counts(&self) -> u32
Return a packed summary of compositor queue state.
Sourcepub fn diag_bytes(&self) -> u32
pub fn diag_bytes(&self) -> u32
Return the most recent restore sequence and byte count.