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
impl GpuValueCache
Sourcepub fn dl_emission_fingerprint(&self) -> u64
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.
Sourcepub fn synchronize(&mut self, styled_dom: &StyledDom) -> GpuEventChanges
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).
Sourcepub fn synchronize_with_sizes(
&mut self,
styled_dom: &StyledDom,
node_size: &dyn Fn(NodeId) -> Option<(f32, f32)>,
) -> GpuEventChanges
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.
Sourcepub fn refresh_transform_values(
&mut self,
styled_dom: &StyledDom,
node_size: &dyn Fn(NodeId) -> Option<(f32, f32)>,
) -> usize
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
impl Clone for GpuValueCache
Source§fn clone(&self) -> GpuValueCache
fn clone(&self) -> GpuValueCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more