Skip to main content

Module mask_cache

Module mask_cache 

Source
Expand description

Cache of generated mask textures (M-DYN.2 / AUT-44).

Keyed on the MaskShape data + output dimensions + invert flag. f32 fields are bit-cast to u32 so equality is exact-bit and Hash works (avoids the NaN-aware floating-point quirks of std::cmp::Eq). Same canonical NaN bits hash identically — fine for our use case where callers re-pass the same shape value across frames.

Eviction is FIFO, capped at MAX_ENTRIES. The cap is a balance between memory (each mask texture is w × h × 4 bytes of GPU memory) and reuse efficiency. 64 entries × 256² × 4 bytes ≈ 16 MB upper bound — small even on integrated GPUs.

Path masks are intentionally not cached in V1: hashing a Vec<glam::Vec2> is non-trivial and most freehand-mask use cases mutate the polygon between frames anyway. Callers needing path caching should use Renderer::generate_path_mask_texture and manage the cache externally.

Structs§

MaskCache 🔒
FIFO-bounded cache of generated mask textures.
MaskKey 🔒

Enums§

ShapeKey 🔒

Constants§

MAX_ENTRIES 🔒
Maximum number of cached mask textures before FIFO eviction.

Type Aliases§

MaskCacheCell 🔒
Type alias for the RefCell-wrapped cache as stored on crate::render::Renderer.