Skip to main content

BackbufferCache

Struct BackbufferCache 

Source
pub struct BackbufferCache {
    pub pixels: Option<Arc<Vec<u8>>>,
    pub lcd_alpha: Option<Arc<Vec<u8>>>,
    pub width: u32,
    pub height: u32,
    pub dirty: bool,
    pub theme_epoch: u64,
    pub typography_epoch: u64,
}
Expand description

A CPU bitmap owned by a widget that opts into backbuffer caching.

Set dirty = true from the widget’s setter methods whenever the widget’s visual output could change (text, colour, bounds, hover/press state, …). The framework re-rasterises on the next paint and clears the flag.

Fields§

§pixels: Option<Arc<Vec<u8>>>

In Rgba mode: top-row-first RGBA8 pixels, straight alpha. Blitted via DrawCtx::draw_image_rgba_arc.

In LcdCoverage mode: top-row-first colour plane — 3 bytes/pixel (R_premult, G_premult, B_premult) matching the convention of crate::lcd_coverage::LcdBuffer::color_plane flipped to top-down. The companion alpha plane lives in Self::lcd_alpha.

§lcd_alpha: Option<Arc<Vec<u8>>>

LcdCoverage-mode companion to pixels: top-row-first per-channel alpha plane (3 bytes/pixel, (R_alpha, G_alpha, B_alpha)). None means this is a plain Rgba cache. When Some, the blit step uses DrawCtx::draw_lcd_backbuffer_arc to preserve the per-channel subpixel information through to the destination — required for LCD chroma to survive the cache round-trip.

§width: u32§height: u32§dirty: bool

When true, the next paint will re-rasterise rather than reusing pixels. Widgets set this from their mutation paths (set_text, set_color, focus/hover changes, etc.) and the framework clears it after a successful re-raster.

§theme_epoch: u64

Visuals epoch (see crate::theme::current_visuals_epoch) recorded the last time this cache was populated. paint_subtree_backbuffered compares it against the live epoch and forces a re-raster on mismatch, so widgets whose text/fill colours come from ctx.visuals() refresh automatically on a dark/light theme flip without needing every widget to subscribe to theme-change events.

§typography_epoch: u64

Typography epoch (see crate::font_settings::current_typography_epoch) — same pattern as theme_epoch but for font / size scale / LCD / hinting / gamma / width / interval / faux-* globals. Lets a slider drag in the LCD Subpixel demo invalidate every cached Label bitmap without bespoke hooks per widget.

Implementations§

Source§

impl BackbufferCache

Source

pub fn new() -> Self

Source

pub fn invalidate(&mut self)

Mark the cache dirty so the next paint re-rasterises.

Trait Implementations§

Source§

impl Default for BackbufferCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.