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:
-
Amortised unquantized scratch:
unquantizedis never dropped between frames, so the heap allocation is paid once after warmup. -
Spatial-node transform cache: the relative transform from
prim_spatial_node→tile_cache_spatial_nodeis cached so that consecutive primitives in the same scroll frame avoid repeatedget_relative_transformcalls.
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
impl CornersCache
pub fn new() -> Self
Sourcepub fn pre_update(&mut self)
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.
Sourcepub fn clear_scratch(&mut self)
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).
Sourcepub 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
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.
fn append_corners_from_mapping( &mut self, local_rect: LayoutRect, local_to_raster: ScaleOffset, ) -> VertRange
Sourcepub fn push_verts(
&self,
scratch_range: VertRange,
dst: &mut Vec<i32>,
) -> VertRange
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.
Sourcepub fn push_verts_clamped(
&self,
scratch_range: VertRange,
tile_rect: &RasterRect,
dst: &mut Vec<i32>,
) -> VertRange
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§
impl Freeze for CornersCache
impl RefUnwindSafe for CornersCache
impl Send for CornersCache
impl Sync for CornersCache
impl Unpin for CornersCache
impl UnsafeUnpin for CornersCache
impl UnwindSafe for CornersCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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