Skip to main content

GpuValueCache

Struct GpuValueCache 

Source
pub struct GpuValueCache {
Show 16 fields pub transform_keys: HashMap<NodeId, TransformKey>, pub current_transform_values: HashMap<NodeId, ComputedTransform3D>, pub h_transform_keys: HashMap<NodeId, TransformKey>, pub h_current_transform_values: HashMap<NodeId, ComputedTransform3D>, pub css_transform_keys: HashMap<NodeId, TransformKey>, pub css_current_transform_values: HashMap<NodeId, ComputedTransform3D>, pub anim_transform_keys: HashMap<NodeId, TransformKey>, pub anim_current_transform_values: HashMap<NodeId, ComputedTransform3D>, pub anim_opacity_keys: HashMap<NodeId, OpacityKey>, pub anim_current_opacity_values: HashMap<NodeId, f32>, pub opacity_keys: HashMap<NodeId, OpacityKey>, pub current_opacity_values: HashMap<NodeId, f32>, pub scrollbar_v_opacity_keys: HashMap<(DomId, NodeId), OpacityKey>, pub scrollbar_h_opacity_keys: HashMap<(DomId, NodeId), OpacityKey>, pub scrollbar_v_opacity_values: HashMap<(DomId, NodeId), f32>, pub scrollbar_h_opacity_values: HashMap<(DomId, NodeId), f32>,
}
Expand description

Caches GPU transform and opacity keys and their current values for all nodes.

This cache stores the WebRender keys and computed values for nodes with CSS transforms or opacity. It’s synchronized with the StyledDom to detect changes and generate minimal update events.

Fields§

§transform_keys: HashMap<NodeId, TransformKey>

Vertical scrollbar thumb transform keys (keyed by scrollable node ID)

§current_transform_values: HashMap<NodeId, ComputedTransform3D>

Current vertical scrollbar thumb transform values

§h_transform_keys: HashMap<NodeId, TransformKey>

Horizontal scrollbar thumb transform keys (keyed by scrollable node ID)

§h_current_transform_values: HashMap<NodeId, ComputedTransform3D>

Current horizontal scrollbar thumb transform values

§css_transform_keys: HashMap<NodeId, TransformKey>

CSS transform keys (keyed by node ID) — for CSS transform property animation. Separate from scrollbar transform keys to avoid SpatialTreeItemKey collisions.

§css_current_transform_values: HashMap<NodeId, ComputedTransform3D>

Current CSS transform values (keyed by node ID)

§anim_transform_keys: HashMap<NodeId, TransformKey>

ANIMATION transform keys (keyed by node ID).

A separate channel from css_transform_keys on purpose. That map is OWNED by synchronize, which adds and removes entries to match the DOM’s CSS transform property — so an animation writing into it has its keys evicted on the very next frame, and the element snaps instead of moving. Scrollbar thumbs already have their own channel for the same reason; this follows that precedent rather than fighting the cascade for one map.

§anim_current_transform_values: HashMap<NodeId, ComputedTransform3D>

Current animation transform values (keyed by node ID).

§anim_opacity_keys: HashMap<NodeId, OpacityKey>

Animation opacity keys (keyed by node ID).

§anim_current_opacity_values: HashMap<NodeId, f32>

Current animation opacity values (keyed by node ID).

§opacity_keys: HashMap<NodeId, OpacityKey>

CSS opacity keys (keyed by node ID)

§current_opacity_values: HashMap<NodeId, f32>

Current CSS opacity values (keyed by node ID)

§scrollbar_v_opacity_keys: HashMap<(DomId, NodeId), OpacityKey>

Vertical scrollbar opacity keys (keyed by DOM ID and scrollable node ID)

§scrollbar_h_opacity_keys: HashMap<(DomId, NodeId), OpacityKey>

Horizontal scrollbar opacity keys (keyed by DOM ID and scrollable node ID)

§scrollbar_v_opacity_values: HashMap<(DomId, NodeId), f32>

Current vertical scrollbar opacity values

§scrollbar_h_opacity_values: HashMap<(DomId, NodeId), f32>

Current horizontal scrollbar opacity values

Implementations§

Source§

impl GpuValueCache

Source

pub fn empty() -> Self

Creates an empty GPU value cache.

Source

pub fn dl_emission_fingerprint(&self) -> u64

Fingerprint of the KEY POPULATION the display-list builder consumes — which nodes carry which transform/opacity keys, and (for the channels the builder zips with their value map) whether a value exists.

This exists because the solver’s structural-identity display-list cache keyed on (root subtree hash, viewport) alone, and the emitted list is ALSO a function of this population: PushReferenceFrame is emitted for a node exactly when it has a key+value pair. Diff-driven animation mints its keys AFTER the first layout (First/Last need solved rects), so the very next relayout of the unchanged DOM hit the cache and served the PRE-KEY display list back — no reference frames, so no GPU damage, so the animation was invisible and every subsequent screenshot froze.

Deliberately a population fingerprint, not a value fingerprint: values change every animation tick, and serving the cached list across ticks is the entire point of routing animation through GPU keys. The hash covers exactly the maps the builder reads: css/anim transform keys (plus the keysets of their value maps — a key without a value emits nothing), scrollbar v/h thumb transform keys, and scrollbar v/h opacity keys. In-process comparison only, so hasher stability across runs is not required; iteration order is normalised by sorting.

Source

pub fn synchronize(&mut self, styled_dom: &StyledDom) -> GpuEventChanges

Synchronizes the cache with the current StyledDom, generating change events for CSS transform and opacity additions, modifications, and removals.

Split into read-only compute_*_events passes (which diff against the cache) and apply_*_events passes (which mutate it).

Source

pub fn synchronize_with_sizes( &mut self, styled_dom: &StyledDom, node_size: &dyn Fn(NodeId) -> Option<(f32, f32)>, ) -> GpuEventChanges

Self::synchronize with the nodes’ border-box sizes (logical px), which is what transform-origin and translate() percentages resolve against (CSS Transforms 1: the element’s own box). Layout runs AFTER this sync, so callers pass the PREVIOUS pass’s sizes — exact in steady state — and correct the values once the new sizes exist with Self::refresh_transform_values. With no size source a percentage origin resolves to 0, i.e. the top-left corner: that was the only behaviour before, and it pivoted every rotate() / scale() under the default transform-origin: 50% 50% at the corner instead of the centre.

Source

pub fn refresh_transform_values( &mut self, styled_dom: &StyledDom, node_size: &dyn Fn(NodeId) -> Option<(f32, f32)>, ) -> usize

AFTER layout: recompute every cached CSS transform with the nodes’ real sizes (see Self::synchronize_with_sizes). Returns how many values changed. Both compositors read the LIVE values from this cache (the display list’s baked matrix is only the fallback for a key nothing has published), so a corrected value reaches the screen in the same frame.

Trait Implementations§

Source§

impl Clone for GpuValueCache

Source§

fn clone(&self) -> GpuValueCache

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GpuValueCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GpuValueCache

Source§

fn default() -> GpuValueCache

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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.