Skip to main content

euv_core/scene/retained/
struct.rs

1use super::*;
2
3/// Retained page and scroll layer state preserved cleanly across `PageRetention::Freeze` route transitions.
4#[derive(Clone, Data, Debug, Default, PartialEq)]
5pub struct RetainedScrollLayer {
6    /// Canonical route path owning this retained page layer.
7    pub(crate) route_key: String,
8    /// Persistent outer `ScrollView` wrapper node reused across route switches.
9    #[get(type(copy))]
10    pub(crate) wrapper_node: NodeId,
11    /// Monotonic retained layer generation preserved across reuse without teardown.
12    #[get(type(copy))]
13    pub(crate) layer_generation: u64,
14    /// Primary wrapper scroll offset captured before freeze and verified on resume.
15    #[get(type(copy))]
16    pub(crate) scroll_offset: Point,
17    /// Nested scrollable descendant `(node_id, scroll_offset)` pairs preserved across route switches.
18    pub(crate) nested_scroll_offsets: Vec<(NodeId, Point)>,
19    /// Focused descendant `NodeId` inside this page when it froze (restored on return when still live).
20    #[get(skip)]
21    pub(crate) focused_node: Option<NodeId>,
22    /// Monotonic page animation timeline clock in seconds preserved across freeze/resume.
23    #[get(type(copy))]
24    pub(crate) animation_timeline_secs: f64,
25    /// Suspended descendant `NodeTransition` records keeping exact `elapsed` progress intact across freeze.
26    pub(crate) suspended_transitions: Vec<NodeTransition>,
27    /// Cumulative number of times this retained page/scroll layer was reused on route resume.
28    #[get(type(copy))]
29    pub(crate) reuse_count: u64,
30    /// Cumulative number of resource pre-warm passes completed for this route.
31    #[get(type(copy))]
32    pub(crate) prewarm_count: u64,
33    /// Number of layout nodes inspected during the most recent pre-warm pass.
34    #[get(type(copy))]
35    pub(crate) prewarmed_layout_nodes: usize,
36    /// Number of representative glyph strings warmed during the most recent pre-warm pass.
37    #[get(type(copy))]
38    pub(crate) prewarmed_glyph_strings: usize,
39    /// Monotonic last-used tick for bounded LRU maintenance.
40    #[get(type(copy))]
41    pub(crate) last_used_tick: u64,
42}
43
44/// Summary report emitted by `prewarm_page_resources` during route transition pre-warming.
45#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
46pub struct PagePrewarmReport {
47    /// Target route path that was pre-warmed.
48    pub(crate) route_key: String,
49    /// Number of layout/scene nodes inspected and verified for the target page.
50    #[get(type(copy))]
51    pub(crate) layout_nodes_warmed: usize,
52    /// Number of text/glyph strings registered for shaping cache warmup.
53    #[get(type(copy))]
54    pub(crate) glyph_strings_warmed: usize,
55    /// True when an existing retained page/scroll layer was reused without rebuilding.
56    #[get(type(copy))]
57    pub(crate) retained_layer_reused: bool,
58    /// Number of scroll layers (wrapper + nested scrollables) preserved for this page.
59    #[get(type(copy))]
60    pub(crate) scroll_layers_preserved: usize,
61}
62
63/// Bounded registry tracking retained page/scroll layers, focus, and animation timelines across route transitions.
64#[derive(Clone, Data, Debug, Default)]
65pub struct RetainedLayerRegistry {
66    /// Active retained page layer records keyed by canonical route path.
67    #[get(pub(crate))]
68    #[get_mut(pub(crate))]
69    #[set(skip)]
70    pub(crate) entries: HashMap<String, RetainedScrollLayer>,
71    /// Monotonic layer generation counter assigned only when a brand-new wrapper layer is registered.
72    #[get(type(copy))]
73    #[get_mut(skip)]
74    #[set(skip)]
75    pub(crate) next_generation: u64,
76    /// Monotonic LRU tick incremented on every capture, restore, or pre-warm touch.
77    #[get(type(copy))]
78    #[get_mut(skip)]
79    #[set(skip)]
80    pub(crate) touch_clock: u64,
81    /// Cumulative retained layer reuse hits across all routes.
82    #[get(type(copy))]
83    #[get_mut(skip)]
84    #[set(skip)]
85    pub(crate) total_reuse_hits: u64,
86    /// Cumulative pre-warm executions across all routes.
87    #[get(type(copy))]
88    #[get_mut(skip)]
89    #[set(skip)]
90    pub(crate) total_prewarms: u64,
91}