Skip to main content

CornersCache

Struct CornersCache 

Source
pub struct CornersCache {
    unquantized: Vec<RasterPoint>,
    cached_node: Option<SpatialNodeIndex>,
    cached_mapping: CoordinateSpaceMapping<LayoutPixel, LayoutPixel>,
}
Expand description

Persistent per-tile-cache scratch and transform cache for computing raster-space corners.

Lives on TileCacheInstance and provides two optimisations:

  1. Amortised unquantized scratch: unquantized is never dropped between frames, so the heap allocation is paid once after warmup.

  2. Spatial-node transform cache: the relative transform from prim_spatial_nodetile_cache_spatial_node is cached so that consecutive primitives in the same scroll frame avoid repeated get_relative_transform calls.

Fields§

§unquantized: Vec<RasterPoint>

Amortised scratch for unquantized corners. Cleared once before computing prim + coverage + clips for each primitive.

§cached_node: Option<SpatialNodeIndex>

The primitive spatial node for which cached_mapping was computed. None means the cache is cold (reset at frame start).

§cached_mapping: CoordinateSpaceMapping<LayoutPixel, LayoutPixel>

Cached mapping for cached_node. Valid only when cached_node == Some(current prim_spatial_node).

Implementations§

Source§

impl CornersCache

Source

pub fn new() -> Self

Source

pub fn pre_update(&mut self)

Reset the transform cache. Call once at the start of each frame’s dependency update, before any primitives are processed.

Source

pub fn clear_scratch(&mut self)

Clear the unquantized scratch. Call once before computing corners for a single primitive (before prim rect, coverage rect and all clips).

Source

pub fn compute_to_scratch( &mut self, local_rect: LayoutRect, prim_spatial_node: SpatialNodeIndex, tile_cache_spatial_node: SpatialNodeIndex, local_to_raster: ScaleOffset, spatial_tree: &SpatialTree, ) -> VertRange

Compute unquantized raster-space corners for local_rect and append them to the scratch buffer. Returns a VertRange into the scratch, or VertRange::INVALID if the transform is non-invertible.

The relative transform for prim_spatial_node is cached across calls: if the same node is passed as the previous call, get_relative_transform is not recomputed.

Source

fn append_corners_from_mapping( &mut self, local_rect: LayoutRect, local_to_raster: ScaleOffset, ) -> VertRange

Source

pub fn push_verts( &self, scratch_range: VertRange, dst: &mut Vec<i32>, ) -> VertRange

Quantize corners at scratch_range from the scratch buffer into dst. Returns a VertRange into dst, or INVALID if scratch_range is invalid.

Source

pub fn push_verts_clamped( &self, scratch_range: VertRange, tile_rect: &RasterRect, dst: &mut Vec<i32>, ) -> VertRange

Quantize corners at scratch_range into dst, clamping to tile_rect. Returns a VertRange into dst, or INVALID if scratch_range is invalid.

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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<'a, T> Deserialize<'a> for T