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,
pub async_state_epoch: u64,
pub lcd_buffer: Option<LcdBuffer>,
pub partial_allowed: bool,
pub content_version: u64,
}Expand description
A CPU bitmap owned by a widget that opts into backbuffer caching.
The framework re-rasterises when the cache’s explicit dirty flag is set or when global styling epochs change.
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: boolWhen 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: u64Visuals 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: u64Typography 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 System window’s typography controls invalidate
every cached Label bitmap without bespoke hooks per widget.
async_state_epoch: u64Async-state epoch (see
crate::animation::async_state_epoch) — bumped when an
off-thread / async source (e.g. an image fetch + decode)
finishes outside the normal event-dispatch path that would
otherwise mark widgets dirty. Mismatch forces a re-raster
so freshly-loaded data lands in newly-laid-out bounds.
lcd_buffer: Option<LcdBuffer>Retained LcdCoverage planes (Y-up) kept alive between paints so an
over-scan-band widget can partially re-raster only the edited line
strip into the existing pixels instead of rebuilding the whole (up to
2×-viewport) buffer on every keystroke. Only populated on the band path
(see crate::widget::Widget::backbuffer_band); None for every other
widget, so the extra memory and reuse machinery never touch them.
partial_allowed: boolSet by the framework immediately before a band widget’s paint: true
means the retained Self::lcd_buffer was reused unchanged (same size,
mode and styling epochs), so the widget may repaint only its dirty line
strip and leave the rest of the buffer intact. false forces a full
repaint (first raster, resize, re-anchor, theme flip). Transient — the
widget reads it during paint and must not rely on it afterwards.
content_version: u64Stamped with a globally-unique value (see [next_content_version]) on
every raster that changes the published pixels / lcd_alpha content.
It lets backends that cache GPU textures by buffer identity detect an
in-place content change: the dirty-strip path updates the retained planes
through Arc::make_mut, which keeps the byte-buffer address stable, so a
pointer-keyed texture cache would otherwise miss the edit. Pairing the
buffer pointer with this version disambiguates. 0 means “never rastered”.
Implementations§
Source§impl BackbufferCache
impl BackbufferCache
pub fn new() -> Self
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Mark the cache dirty so the next paint re-rasterises.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BackbufferCache
impl RefUnwindSafe for BackbufferCache
impl Send for BackbufferCache
impl Sync for BackbufferCache
impl Unpin for BackbufferCache
impl UnsafeUnpin for BackbufferCache
impl UnwindSafe for BackbufferCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().