Struct webrender::picture::TileCacheInstance

source ·
pub struct TileCacheInstance {
Show 44 fields pub debug_flags: DebugFlags, pub slice: usize, pub slice_flags: SliceFlags, pub current_tile_size: DeviceIntSize, pub sub_slices: Vec<SubSlice>, pub spatial_node_index: SpatialNodeIndex, opacity_bindings: FastHashMap<PropertyBindingId, BindingInfo<f32>>, old_opacity_bindings: FastHashMap<PropertyBindingId, BindingInfo<f32>>, spatial_node_comparer: SpatialNodeComparer, color_bindings: FastHashMap<PropertyBindingId, BindingInfo<ColorU>>, old_color_bindings: FastHashMap<PropertyBindingId, BindingInfo<ColorU>>, pub dirty_region: DirtyRegion, tile_size: PictureSize, tile_rect: Box2D<i32, TileCoordinate>, tile_bounds_p0: TileOffset, tile_bounds_p1: TileOffset, pub local_rect: PictureRect, pub local_clip_rect: PictureRect, pub screen_rect_in_pic_space: PictureRect, surface_index: SurfaceIndex, pub background_color: Option<ColorF>, pub backdrop: BackdropInfo, pub subpixel_mode: SubpixelMode, pub shared_clip_node_id: ClipNodeId, pub shared_clip_leaf_id: Option<ClipLeafId>, frames_until_size_eval: usize, virtual_offset: DeviceIntPoint, compare_cache: FastHashMap<PrimitiveComparisonKey, PrimitiveCompareResult>, tile_size_override: Option<DeviceIntSize>, pub external_native_surface_cache: FastHashMap<ExternalNativeSurfaceKey, ExternalNativeSurface>, frame_id: FrameId, pub transform_index: CompositorTransformIndex, local_to_raster: ScaleOffset, raster_to_device: ScaleOffset, invalidate_all_tiles: bool, current_raster_scale: f32, current_surface_traversal_depth: usize, deferred_dirty_tests: Vec<DeferredDirtyTest>, found_prims_after_backdrop: bool, pub backdrop_surface: Option<BackdropSurface>, pub underlays: Vec<ExternalSurfaceDescriptor>, pub overlay_region: PictureRect, pub yuv_images_count: usize, pub yuv_images_remaining: usize,
}
Expand description

Represents a cache of tiles that make up a picture primitives.

Fields§

§debug_flags: DebugFlags§slice: usize

Index of the tile cache / slice for this frame builder. It’s determined by the setup_picture_caching method during flattening, which splits the picture tree into multiple slices. It’s used as a simple input to the tile keys. It does mean we invalidate tiles if a new layer gets inserted / removed between display lists - this seems very unlikely to occur on most pages, but can be revisited if we ever notice that.

§slice_flags: SliceFlags

Propagated information about the slice

§current_tile_size: DeviceIntSize

The currently selected tile size to use for this cache

§sub_slices: Vec<SubSlice>

The list of sub-slices in this tile cache

§spatial_node_index: SpatialNodeIndex

The positioning node for this tile cache.

§opacity_bindings: FastHashMap<PropertyBindingId, BindingInfo<f32>>

List of opacity bindings, with some extra information about whether they changed since last frame.

§old_opacity_bindings: FastHashMap<PropertyBindingId, BindingInfo<f32>>

Switch back and forth between old and new bindings hashmaps to avoid re-allocating.

§spatial_node_comparer: SpatialNodeComparer

A helper to compare transforms between previous and current frame.

§color_bindings: FastHashMap<PropertyBindingId, BindingInfo<ColorU>>

List of color bindings, with some extra information about whether they changed since last frame.

§old_color_bindings: FastHashMap<PropertyBindingId, BindingInfo<ColorU>>

Switch back and forth between old and new bindings hashmaps to avoid re-allocating.

§dirty_region: DirtyRegion

The current dirty region tracker for this picture.

§tile_size: PictureSize

Current size of tiles in picture units.

§tile_rect: Box2D<i32, TileCoordinate>

Tile coords of the currently allocated grid.

§tile_bounds_p0: TileOffset

Pre-calculated versions of the tile_rect above, used to speed up the calculations in get_tile_coords_for_rect.

§tile_bounds_p1: TileOffset§local_rect: PictureRect

Local rect (unclipped) of the picture this cache covers.

§local_clip_rect: PictureRect

The local clip rect, from the shared clips of this picture.

§screen_rect_in_pic_space: PictureRect

The screen rect, transformed to local picture space.

§surface_index: SurfaceIndex

The surface index that this tile cache will be drawn into.

§background_color: Option<ColorF>

The background color from the renderer. If this is set opaque, we know it’s fine to clear the tiles to this and allow subpixel text on the first slice.

§backdrop: BackdropInfo

Information about the calculated backdrop content of this cache.

§subpixel_mode: SubpixelMode

The allowed subpixel mode for this surface, which depends on the detected opacity of the background.

§shared_clip_node_id: ClipNodeId§shared_clip_leaf_id: Option<ClipLeafId>§frames_until_size_eval: usize

The number of frames until this cache next evaluates what tile size to use. If a picture rect size is regularly changing just around a size threshold, we don’t want to constantly invalidate and reallocate different tile size configuration each frame.

§virtual_offset: DeviceIntPoint

For DirectComposition, virtual surfaces don’t support negative coordinates. However, picture cache tile coordinates can be negative. To handle this, we apply an offset to each tile in DirectComposition. We want to change this as little as possible, to avoid invalidating tiles. However, if we have a picture cache tile coordinate which is outside the virtual surface bounds, we must change this to allow correct remapping of the coordinates passed to BeginDraw in DC.

§compare_cache: FastHashMap<PrimitiveComparisonKey, PrimitiveCompareResult>

keep around the hash map used as compare_cache to avoid reallocating it each frame.

§tile_size_override: Option<DeviceIntSize>

The currently considered tile size override. Used to check if we should re-evaluate tile size, even if the frame timer hasn’t expired.

§external_native_surface_cache: FastHashMap<ExternalNativeSurfaceKey, ExternalNativeSurface>

A cache of compositor surfaces that are retained between frames

§frame_id: FrameId

Current frame ID of this tile cache instance. Used for book-keeping / garbage collecting

§transform_index: CompositorTransformIndex

Registered transform in CompositeState for this picture cache

§local_to_raster: ScaleOffset

Current transform mapping local picture space to compositor surface raster space

§raster_to_device: ScaleOffset

Current transform mapping compositor surface raster space to final device space

§invalidate_all_tiles: bool

If true, we need to invalidate all tiles during post_update

§current_raster_scale: f32

The current raster scale for tiles in this cache

§current_surface_traversal_depth: usize

Depth of off-screen surfaces that are currently pushed during dependency updates

§deferred_dirty_tests: Vec<DeferredDirtyTest>

A list of extra dirty invalidation tests that can only be checked once we know the dirty rect of all tiles

§found_prims_after_backdrop: bool

Is there a backdrop associated with this cache

§backdrop_surface: Option<BackdropSurface>§underlays: Vec<ExternalSurfaceDescriptor>

List of underlay compositor surfaces that exist in this picture cache

§overlay_region: PictureRect

“Region” (actually a spanning rect) containing all overlay promoted surfaces

§yuv_images_count: usize

The number YuvImage prims in this cache, provided in our TileCacheParams.

§yuv_images_remaining: usize

The remaining number of YuvImage prims we will see this frame. We prioritize promoting these before promoting any Image prims.

Implementations§

source§

impl TileCacheInstance

source

pub fn new(params: TileCacheParams) -> Self

source

pub fn tile_count(&self) -> usize

Return the total number of tiles allocated by this tile cache

source

pub fn memory_pressure(&mut self, resource_cache: &mut ResourceCache)

Trims memory held by the tile cache, such as native surfaces.

source

pub fn prepare_for_new_scene( &mut self, params: TileCacheParams, resource_cache: &mut ResourceCache, )

Reset this tile cache with the updated parameters from a new scene that has arrived. This allows the tile cache to be retained across new scenes.

source

pub fn destroy(self, resource_cache: &mut ResourceCache)

Destroy any manually managed resources before this picture cache is destroyed, such as native compositor surfaces.

source

fn get_tile_coords_for_rect( &self, rect: &PictureRect, ) -> (TileOffset, TileOffset)

Get the tile coordinates for a given rectangle.

source

pub fn pre_update( &mut self, pic_rect: PictureRect, surface_index: SurfaceIndex, frame_context: &FrameVisibilityContext<'_>, frame_state: &mut FrameVisibilityState<'_>, ) -> WorldRect

Update transforms, opacity, color bindings and tile rects.

source

fn can_promote_to_surface( &mut self, prim_clip_chain: &ClipChainInstance, prim_spatial_node_index: SpatialNodeIndex, is_root_tile_cache: bool, sub_slice_index: usize, surface_kind: CompositorSurfaceKind, pic_coverage_rect: PictureRect, frame_context: &FrameVisibilityContext<'_>, ) -> Result<CompositorSurfaceKind, SurfacePromotionFailure>

source

fn setup_compositor_surfaces_yuv( &mut self, sub_slice_index: usize, prim_info: &mut PrimitiveDependencyInfo, flags: PrimitiveFlags, local_prim_rect: LayoutRect, prim_spatial_node_index: SpatialNodeIndex, pic_coverage_rect: PictureRect, frame_context: &FrameVisibilityContext<'_>, image_dependencies: &[ImageDependency; 3], api_keys: &[ImageKey; 3], resource_cache: &mut ResourceCache, composite_state: &mut CompositeState, gpu_cache: &mut GpuCache, image_rendering: ImageRendering, color_depth: ColorDepth, color_space: YuvRangedColorSpace, format: YuvFormat, surface_kind: CompositorSurfaceKind, ) -> Result<CompositorSurfaceKind, SurfacePromotionFailure>

source

fn setup_compositor_surfaces_rgb( &mut self, sub_slice_index: usize, prim_info: &mut PrimitiveDependencyInfo, flags: PrimitiveFlags, local_prim_rect: LayoutRect, prim_spatial_node_index: SpatialNodeIndex, pic_coverage_rect: PictureRect, frame_context: &FrameVisibilityContext<'_>, image_dependency: ImageDependency, api_key: ImageKey, resource_cache: &mut ResourceCache, composite_state: &mut CompositeState, gpu_cache: &mut GpuCache, image_rendering: ImageRendering, is_opaque: bool, surface_kind: CompositorSurfaceKind, ) -> Result<CompositorSurfaceKind, SurfacePromotionFailure>

source

fn setup_compositor_surfaces_impl( &mut self, sub_slice_index: usize, prim_info: &mut PrimitiveDependencyInfo, flags: PrimitiveFlags, local_prim_rect: LayoutRect, prim_spatial_node_index: SpatialNodeIndex, pic_coverage_rect: PictureRect, frame_context: &FrameVisibilityContext<'_>, dependency: ExternalSurfaceDependency, api_keys: &[ImageKey; 3], resource_cache: &mut ResourceCache, composite_state: &mut CompositeState, image_rendering: ImageRendering, is_opaque: bool, surface_kind: CompositorSurfaceKind, ) -> Result<CompositorSurfaceKind, SurfacePromotionFailure>

source

pub fn push_surface( &mut self, estimated_local_rect: LayoutRect, surface_spatial_node_index: SpatialNodeIndex, spatial_tree: &SpatialTree, )

Push an estimated rect for an off-screen surface during dependency updates. This is a workaround / hack that allows the picture cache code to know when it should be processing primitive dependencies as a single atomic unit. In future, we aim to remove this hack by having the primitive dependencies stored within each owning picture. This is part of the work required to support child picture caching anyway!

source

pub fn pop_surface(&mut self)

Pop an off-screen surface off the stack during dependency updates

source

fn maybe_report_promotion_failure( &self, result: Result<CompositorSurfaceKind, SurfacePromotionFailure>, rect: PictureRect, reported: &mut bool, )

source

pub fn update_prim_dependencies( &mut self, prim_instance: &mut PrimitiveInstance, prim_spatial_node_index: SpatialNodeIndex, local_prim_rect: LayoutRect, frame_context: &FrameVisibilityContext<'_>, data_stores: &DataStores, clip_store: &ClipStore, pictures: &[PicturePrimitive], resource_cache: &mut ResourceCache, color_bindings: &Storage<PropertyBinding<ColorU>>, surface_stack: &[(PictureIndex, SurfaceIndex)], composite_state: &mut CompositeState, gpu_cache: &mut GpuCache, scratch: &mut PrimitiveScratchBuffer, is_root_tile_cache: bool, surfaces: &mut [SurfaceInfo], profile: &mut TransactionProfile, )

Update the dependencies for each tile for a given primitive instance.

source

fn print(&self)

Print debug information about this picture cache to a tree printer.

source

fn calculate_subpixel_mode(&self) -> SubpixelMode

source

pub fn post_update( &mut self, frame_context: &FrameVisibilityContext<'_>, frame_state: &mut FrameVisibilityState<'_>, )

Apply any updates after prim dependency updates. This applies any late tile invalidations, and sets up the dirty rect and set of tile blits.

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

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>,

§

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>,

§

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.