pub struct GpuStateManager {
pub caches: BTreeMap<DomId, GpuValueCache>,
pub fade_delay: Duration,
pub fade_duration: Duration,
pub fade_states: BTreeMap<(DomId, NodeId), ScrollbarFadeState>,
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
fade_states: BTreeMap<(DomId, NodeId), ScrollbarFadeState>Per-scrollbar fade state: (DomId, NodeId) → last activity time
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 tick(&mut self, now: Instant) -> GpuTickResult
pub fn tick(&mut self, now: Instant) -> GpuTickResult
Advances GPU state by one tick, interpolating animated opacity values.
This should be called each frame to update opacity transitions for smooth scrollbar fading. Returns whether a repaint is needed (i.e., any opacity value changed).
Sourcepub fn record_scroll_activity(
&mut self,
dom_id: DomId,
node_id: NodeId,
now: Instant,
needs_vertical: bool,
needs_horizontal: bool,
)
pub fn record_scroll_activity( &mut self, dom_id: DomId, node_id: NodeId, now: Instant, needs_vertical: bool, needs_horizontal: bool, )
Record scroll activity for a scrollbar node, resetting the fade timer.
This should be called whenever scroll activity occurs to keep the scrollbar visible and reset the fade-out timer.
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.
Sourcepub fn get_gpu_value_cache(&self) -> BTreeMap<DomId, GpuValueCache>
pub fn get_gpu_value_cache(&self) -> BTreeMap<DomId, GpuValueCache>
Returns a clone of all GPU value caches.
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
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