Skip to main content

PathAtlas

Struct PathAtlas 

Source
pub struct PathAtlas { /* private fields */ }
Expand description

Shelf-packed atlas for rasterized paths with LRU eviction.

Implementations§

Source§

impl PathAtlas

Source

pub fn new(width: u32, height: u32) -> Self

Create a new path atlas with the given initial dimensions.

Source

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.

Source

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).

Source

pub fn size(&self) -> (u32, u32)

Current atlas dimensions.

Source

pub fn is_dirty(&self) -> bool

Whether the atlas texture needs re-uploading to the GPU.

Source

pub fn pixels(&self) -> &[u8]

Raw pixel data (RGBA).

Source

pub fn mark_clean(&mut self)

Mark the atlas as uploaded.

Source

pub fn lookup_or_rasterize( &mut self, path: &Path, style: &StrokeStyle, fill_rule: FillRule, bounds: [f32; 4], scale_factor: f32, zoom: f32, ) -> Option<AtlasRegion>

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).

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,