pub struct ShadowCache { /* private fields */ }Expand description
Rendered shadows, most recently used last.
Implementations§
Source§impl ShadowCache
impl ShadowCache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
A cache holding capacity shadows.
Zero is treated as DEFAULT_CAPACITY: a cache that held nothing
would re-blur every shadow every frame, which is the cost this type
exists to remove.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Forget everything.
For a theme change that invalidates every shadow at once, where evicting one at a time would blur each of them again on the way out.
Sourcepub fn blit_into(
&mut self,
key: ShadowKey,
theme: &Theme,
dst: &mut ShadowDest<'_>,
) -> bool
pub fn blit_into( &mut self, key: ShadowKey, theme: &Theme, dst: &mut ShadowDest<'_>, ) -> bool
Blit this shadow into dst, rendering it first if it is not cached.
Returns whether anything was written. A zero-sized key or an undersized destination writes nothing rather than failing: a window being resized passes through both, and a decoration that errored on the way would flicker.
A destination smaller than the patch is clipped, not refused — the alternative is reading past the caller’s buffer.
Sourcepub fn blit_cross_fade(
&mut self,
a: ShadowKey,
b: ShadowKey,
theme: &Theme,
dst: &mut ShadowDest<'_>,
t: f32,
) -> bool
pub fn blit_cross_fade( &mut self, a: ShadowKey, b: ShadowKey, theme: &Theme, dst: &mut ShadowDest<'_>, t: f32, ) -> bool
Blit a blend of two shadows, t of the way from a to b.
What a focus change animates through. Both patches are cached, so the transition costs a per-pixel lerp rather than a blur per frame.
t is clamped to 0..=1: an animation that overshoots is a caller
bug, and extrapolating a colour past its endpoints produces values
that are not a shadow at all.