pub struct PathAtlas { /* private fields */ }Expand description
Shelf-packed atlas for rasterized paths with LRU eviction.
Implementations§
Source§impl PathAtlas
impl PathAtlas
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Create a new path atlas with the given initial dimensions.
Sourcepub fn cap_max_size(&mut self, device_max: u32)
pub fn cap_max_size(&mut self, device_max: u32)
Lower the growth cap to what the GPU can actually allocate.
The 4096 default is this renderer’s own ceiling, not a fact about the
hardware. Limits::downlevel_defaults guarantees only 2048, and the
window path can legitimately open a device on an adapter’s own limits,
which on GLES-3-class hardware may sit below 4096. Growing past what the
device allows is a create_texture validation error at the first
path-heavy frame — a crash on the machine least able to report it.
Only ever lowers: a device that allows more than this renderer asks for does not get a bigger atlas, because the cap is also a memory bound.
Sourcepub fn oversize_skips(&self) -> u64
pub fn oversize_skips(&self) -> u64
How many paths have been skipped for being too large to ever fit the atlas.
Each one is a path that simply was not drawn. Non-zero means some geometry is
rasterizing bigger than max_size — upstream, that is a
layout that has run away (an overlay spanning a whole scrolled document, a
shape scaled by a runaway transform), and it is worth chasing rather than
leaving as a hole in the frame.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
How many distinct masks are resident.
The observable side of the cache key: two draws that share a key share an entry, and two that do not each get one. A test asserting that identical geometry is not rasterized twice reads this.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Call at the start of each frame to advance the LRU counter.
This is also the only point at which the atlas may safely repack
itself: no AtlasRegion has been handed out for the new frame yet, so
moving surviving entries to fresh coordinates cannot invalidate any
region the renderer is still holding from the current frame. When the
atlas is near-full and there are stale entries (not touched on the last
completed frame), we compact — dropping the stale entries and repacking
the rest tightly — so steady-state reclamation never has to happen
mid-frame (which would corrupt already-placed paths).
Sourcepub fn mark_clean(&mut self)
pub fn mark_clean(&mut self)
Mark the atlas as uploaded.
Sourcepub fn lookup_or_rasterize(
&mut self,
path: &Path,
style: &StrokeStyle,
fill_rule: FillRule,
bounds: [f32; 4],
scale_factor: f32,
zoom: f32,
snap: bool,
) -> Option<PathPlacement>
pub fn lookup_or_rasterize( &mut self, path: &Path, style: &StrokeStyle, fill_rule: FillRule, bounds: [f32; 4], scale_factor: f32, zoom: f32, snap: bool, ) -> Option<PathPlacement>
Look up or rasterize a path, returning its atlas region.
The rasterized bitmap is always an opaque-white AA coverage
mask — color is applied by the GPU at draw time (solid fills tint
it via the quad pipeline; gradients sample an analytic gradient in
path_gradient.wgsl and modulate by the mask’s alpha channel), so
this function takes no color and two fills of identical geometry
share one atlas entry regardless of their paint.
zoom is the uniform scale of the view transform active where the path
is drawn. For a cosmetic stroke (StrokeSpace::Device) the body
is rasterized at the current zoom (so it stays sharp, matching the
transform-scaled display quad 1:1) while the stroke is baked at a
zoom-independent device width — the border holds a constant
device-pixel thickness at any zoom. Logical strokes ignore zoom
(the body bitmap is stretched by the display quad, as before).
snap asks for the quad to be aligned to whole device pixels and the
bitmap baked to match, so the mask samples 1:1 — pass it when the
effective transform is the identity, and only then (see the body for
why). The returned PathPlacement carries the rect the caller must
draw; it is not to be re-derived from bounds.