pub struct GpuStateManager {
pub caches: BTreeMap<DomId, GpuValueCache>,
pub fade_delay: Duration,
pub fade_duration: Duration,
pub scrollbar_fade_active: bool,
pub pending_changes: GpuEventChanges,
}Expand description
Manages GPU-accelerated properties across all DOMs.
The GpuStateManager maintains caches for transform and opacity keys
that are used by the GPU renderer. It handles:
- Scrollbar thumb position transforms (updated on scroll)
- Opacity fading for scrollbars (fade in on activity, fade out after delay)
- Per-DOM GPU value caches for efficient rendering
Fields§
§caches: BTreeMap<DomId, GpuValueCache>GPU value caches indexed by DOM ID
fade_delay: DurationDelay before scrollbars start fading out after last activity
fade_duration: DurationDuration of the fade-out animation
scrollbar_fade_active: boolWhether any scrollbar has non-zero opacity and needs continued frame
generation. Set during both the fade_delay period (opacity == 1.0)
and the active fade-out phase (0 < opacity < 1).
Set by LayoutWindow::synchronize_scrollbar_opacity, read by the platform render loop.
pending_changes: GpuEventChangesGPU events produced during layout (CSS transform / opacity synchronization, scrollbar transform / opacity updates) that have not yet been pushed to the renderer. Drained by the platform render path when a transaction is built.
Implementations§
Source§impl GpuStateManager
impl GpuStateManager
Sourcepub fn new(fade_delay: Duration, fade_duration: Duration) -> Self
pub fn new(fade_delay: Duration, fade_duration: Duration) -> Self
Creates a new GPU state manager with specified fade timing.
Sourcepub fn take_pending_changes(&mut self) -> GpuEventChanges
pub fn take_pending_changes(&mut self) -> GpuEventChanges
Take any queued transform / opacity events that have been accumulated during layout. Clears the internal buffer.
Sourcepub fn get_cache(&self, dom_id: DomId) -> Option<&GpuValueCache>
pub fn get_cache(&self, dom_id: DomId) -> Option<&GpuValueCache>
Gets or creates the GPU cache for a specific DOM.
pub fn get_or_create_cache(&mut self, dom_id: DomId) -> &mut GpuValueCache
Sourcepub fn update_scrollbar_transforms(
&mut self,
dom_id: DomId,
scroll_manager: &ScrollManager,
layout_tree: &LayoutTree,
) -> GpuEventChanges
pub fn update_scrollbar_transforms( &mut self, dom_id: DomId, scroll_manager: &ScrollManager, layout_tree: &LayoutTree, ) -> GpuEventChanges
Updates scrollbar thumb transforms based on current scroll positions.
Calculates the transform needed to position scrollbar thumbs correctly based on the scroll offset and content/container sizes. Returns the GPU event changes that need to be applied by the renderer.
Trait Implementations§
Source§impl Clone for GpuStateManager
impl Clone for GpuStateManager
Source§fn clone(&self) -> GpuStateManager
fn clone(&self) -> GpuStateManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GpuStateManager
impl Debug for GpuStateManager
Source§impl Default for GpuStateManager
impl Default for GpuStateManager
Source§impl NodeIdRemap for GpuStateManager
impl NodeIdRemap for GpuStateManager
Source§fn remap_node_ids(&mut self, dom: DomId, map: &NodeIdMap)
fn remap_node_ids(&mut self, dom: DomId, map: &NodeIdMap)
Remap the per-node GPU caches (transform / opacity keys and values).
Without this, a rebuild that shifts NodeIds left the scrollbar/CSS
transform + opacity keys attached to the wrong node — the visible symptom
being a scrollbar thumb (or an animated element) that keeps painting at a
stale offset, plus scrollbar_fade_active never settling because the
platform loop keeps generating frames for a node that is not the one
actually scrolling.
Auto Trait Implementations§
impl Freeze for GpuStateManager
impl RefUnwindSafe for GpuStateManager
impl Send for GpuStateManager
impl Sync for GpuStateManager
impl Unpin for GpuStateManager
impl UnsafeUnpin for GpuStateManager
impl UnwindSafe for GpuStateManager
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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