euv_core/app/runner/struct.rs
1use super::*;
2
3/// Top-level cross-platform application configuration.
4#[derive(Clone, Data, Debug, PartialEq)]
5pub struct AppConfig {
6 /// Primary window creation settings.
7 pub(crate) window: WindowConfig,
8 /// Clear background color drawn beneath the root scene node.
9 #[get(type(copy))]
10 pub(crate) clear_color: Color,
11}
12
13/// Opt-in per-phase microsecond breakdown for a single `App::step_frame` execution.
14#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, PartialEq)]
15pub struct FramePhaseMetrics {
16 /// Window command flushing, event polling, and input dispatch duration in microseconds.
17 #[get(type(copy))]
18 pub(crate) input_us: u64,
19 /// Reactive effect flushing, animation/gesture/scroll ticking, and damage collection duration in microseconds.
20 #[get(type(copy))]
21 pub(crate) reactive_us: u64,
22 /// `LayoutEngine::compute` pass duration in microseconds.
23 #[get(type(copy))]
24 pub(crate) layout_us: u64,
25 /// Display-list compilation duration in microseconds when timed separately (`0` when combined into `raster_us`).
26 #[get(type(copy))]
27 pub(crate) paint_list_us: u64,
28 /// Unified render pass (`Renderer::render_frame`) duration in microseconds.
29 #[get(type(copy))]
30 pub(crate) raster_us: u64,
31 /// Native surface / framebuffer region presentation duration in microseconds.
32 #[get(type(copy))]
33 pub(crate) present_us: u64,
34}
35
36/// Unified per-frame diagnostic telemetry covering phase timings, damage ratio, redraw cause, and idle-aware FPS.
37#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
38pub struct FrameTelemetry {
39 /// Monotonic frame identifier matching `FrameStats::get_frame_index()`.
40 #[get(type(copy))]
41 pub(crate) frame_id: u64,
42 /// Microsecond breakdown across pipeline phases (zeroed when telemetry timing is disabled).
43 #[get(type(copy))]
44 pub(crate) phases: FramePhaseMetrics,
45 /// Fraction of physical viewport area rasterized (`0.0` when idle, `(0.0..=1.0]` when rendered).
46 #[get(type(copy))]
47 pub(crate) dirty_area_ratio: f32,
48 /// Diagnostic reason when the frame promoted to full-viewport redraw (`FullRedrawReason::None` for partial or idle).
49 #[get(type(copy))]
50 pub(crate) full_redraw_reason: FullRedrawReason,
51 /// Effective target cadence in Hertz (`min(fps_limit, display_refresh_rate_hz)` or `display_refresh_rate_hz`).
52 #[get(type(copy))]
53 pub(crate) target_hz: f32,
54 /// Active presented frames per second (`0.0` while idle, smoothed active present cadence while rendering).
55 #[get(type(copy))]
56 pub(crate) present_fps: f32,
57 /// Whether this frame skipped rendering because the scene was clean or rate-capped.
58 #[get(type(copy))]
59 pub(crate) is_idle: bool,
60 /// Number of scene nodes recomputed during layout.
61 #[get(type(copy))]
62 pub(crate) layout_nodes: usize,
63 /// Number of display-list draw commands executed.
64 #[get(type(copy))]
65 pub(crate) draw_commands: usize,
66 /// Number of physical pixels shaded.
67 #[get(type(copy))]
68 pub(crate) pixels_shaded: usize,
69 /// Native display target refresh mode in Hertz (distinct from callback and completed frame rates).
70 #[get(type(copy))]
71 pub(crate) target_refresh_mode_hz: f32,
72 /// Measured host frame-callback tick rate in Hertz when `has_callback_sample` is `true`.
73 #[get(type(copy))]
74 pub(crate) callback_rate_hz: f32,
75 /// True when `callback_rate_hz` reflects an active measured sample rather than idle no-sample.
76 #[get(type(copy))]
77 pub(crate) has_callback_sample: bool,
78 /// Measured completed & presented frame rate in Hertz when `has_completed_sample` is `true` (`0.0` / idle when skipped).
79 #[get(type(copy))]
80 pub(crate) completed_frame_rate_hz: f32,
81 /// True when `completed_frame_rate_hz` holds a live non-idle completed frame sample.
82 #[get(type(copy))]
83 pub(crate) has_completed_sample: bool,
84 /// Monotonic presentation timestamp in nanoseconds when `has_present_timestamp` is `true`.
85 #[get(type(copy))]
86 pub(crate) present_timestamp_ns: u64,
87 /// True when this frame completed submission with a valid monotonic presentation timestamp.
88 #[get(type(copy))]
89 pub(crate) has_present_timestamp: bool,
90 /// Explicit frame submission outcome separating idle skip, submitted, and retryable submit failure.
91 #[get(type(copy))]
92 pub(crate) submit_outcome: FrameSubmitOutcome,
93 /// True when this frame took the composite-only fast path without layout or full repaint.
94 #[get(type(copy))]
95 pub(crate) composite_only: bool,
96 /// Cumulative layout telemetry snapshot (`invalidations`, `passes`, `changed_passes`, `changed_nodes_total`).
97 #[get(type(copy))]
98 pub(crate) layout_telemetry: LayoutTelemetry,
99}
100
101/// Unified cross-platform application runtime orchestrating platform events, reactivity, layout, and rendering.
102#[derive(CustomDebug, Data)]
103pub struct App {
104 /// Application configuration.
105 pub(crate) config: AppConfig,
106 /// Active direct OS or headless platform backend.
107 #[debug(skip)]
108 #[get(skip)]
109 pub(crate) platform: Box<dyn PlatformBackend>,
110 /// Primary window live state.
111 #[get(type(copy))]
112 pub(crate) window_state: WindowState,
113 /// Shared scene tree handle.
114 pub(crate) scene: SceneHandle,
115 /// Framework context carrying reactive breakpoint, theme, gesture, and safe-area signals.
116 pub(crate) context: Context,
117 /// Deterministic cross-platform layout engine.
118 pub(crate) layout_engine: LayoutEngine,
119 /// Multi-mode rendering pipeline (`Auto`, `Software`, `Hardware`, `Hybrid`).
120 pub(crate) renderer: Renderer,
121 /// Queued imperative window commands awaiting dispatch.
122 pub(crate) command_queue: WindowCommandQueue,
123 /// Local key-value storage service.
124 pub(crate) storage: StorageStore,
125 /// Flag indicating whether the application loop should keep running.
126 #[get(type(copy))]
127 pub(crate) running: bool,
128 /// Pending damage region for the next rendered frame.
129 #[get(type(copy))]
130 pub(crate) pending_damage: DamageRegion,
131 /// Real-time polled keyboard, pointer, and scroll state for game loops and interactive viewports.
132 pub(crate) input_state: InputState,
133 /// Fixed-timestep accumulator and FPS telemetry clock for real-time game rendering.
134 #[get(type(copy))]
135 pub(crate) frame_clock: FrameClock,
136 /// Platform-native services hub (permissions, protocol registration, Dynamic Island, haptics, tray, A11y).
137 pub(crate) services: PlatformServiceHub,
138 /// Reactive signal carrying the most recently received custom-scheme or universal deep link.
139 #[get(type(copy))]
140 pub(crate) deep_link: Signal<Option<DeepLinkEvent>>,
141 /// Shared dynamic update hub for live component-level and page-level OTA updates.
142 pub(crate) dynamic_hub: DynamicUpdateHub,
143 /// Last scene revision that was rasterized and presented, enabling zero-cost idle frame skipping.
144 #[get(type(copy))]
145 pub(crate) last_rendered_revision: u64,
146 /// Most recently submitted OS/Web cursor icon to avoid redundant platform cursor calls.
147 #[get(type(copy))]
148 pub(crate) last_cursor: CursorIcon,
149 /// Attached real-time game engine hosts receiving automatic OS input forwarding.
150 #[debug(skip)]
151 pub(crate) game_hosts: Vec<GameEngineHost>,
152 /// Active touch pointer identifier currently driving single-finger pan scrolling.
153 #[get(skip)]
154 pub(crate) touch_drag_pointer_id: Option<u64>,
155 /// Starting touch coordinate for mobile pan-to-scroll detection.
156 #[get(skip)]
157 pub(crate) touch_drag_origin: Option<Point>,
158 /// Previous touch coordinate for incremental mobile scroll deltas.
159 #[get(skip)]
160 pub(crate) touch_drag_last: Option<Point>,
161 /// Whether the active touch gesture has crossed tap slop into pan-scrolling.
162 #[get(type(copy))]
163 pub(crate) touch_dragging: bool,
164 /// Cumulative post-slop drag displacement in logical pixels for the active touch scroll gesture.
165 #[get(type(copy))]
166 pub(crate) touch_drag_travel: f32,
167 /// Locked scroll axis for the active touch drag (`0` = unlocked, `1` = vertical, `2` = horizontal, `3` = free).
168 #[get(type(copy))]
169 pub(crate) touch_scroll_axis: u8,
170 /// Touch pan displacement accumulated during the current frame for jitter-free velocity estimation.
171 #[get(type(copy))]
172 pub(crate) touch_vel_accum_delta: Point,
173 /// Fixed 8-entry stack ring buffer of `(dt_secs, dx, dy)` frame samples preventing thumb-lift backward fling reversals.
174 #[get(skip)]
175 #[get_mut(skip)]
176 #[set(skip)]
177 pub(crate) touch_vel_ring: [(f32, f32, f32); 8],
178 /// Ring buffer index of the oldest live velocity sample in `0..8`.
179 #[get(type(copy))]
180 pub(crate) touch_vel_head: usize,
181 /// Number of live samples currently stored in `touch_vel_ring` (`0..=8`).
182 #[get(type(copy))]
183 pub(crate) touch_vel_len: usize,
184 /// Elapsed idle seconds since the last touch pan movement while a finger remains held down.
185 #[get(type(copy))]
186 pub(crate) touch_vel_idle_secs: f32,
187 /// Whether the active pointer press grabbed a scrollbar track for thumb dragging.
188 #[get(type(copy))]
189 pub(crate) scrollbar_dragging: bool,
190 /// Active scrollbar thumb drag axis (`0` = none, `1` = vertical, `2` = horizontal).
191 #[get(type(copy))]
192 pub(crate) scrollbar_drag_axis: u8,
193 /// Pointer offset from the grabbed scrollbar thumb's leading edge in logical pixels, ensuring zero-jump dragging.
194 #[get(pub(crate), type(copy))]
195 #[get_mut(skip)]
196 #[set(pub(crate))]
197 pub(crate) scrollbar_grab_offset: f32,
198 /// Active selectable `NodeKind::Text` node currently undergoing pointer drag selection.
199 #[get(skip)]
200 pub(crate) text_selecting_node: Option<NodeId>,
201 /// Starting character index anchored at pointer-down for drag text selection.
202 #[get(type(copy))]
203 pub(crate) text_select_anchor_char: usize,
204 /// Consecutive click count on the same selectable text node (`1` = caret, `2` = word, `3` = full node).
205 #[get(type(copy))]
206 pub(crate) text_click_count: u8,
207 /// Most recently clicked selectable text node for multi-click detection.
208 #[get(skip)]
209 pub(crate) text_last_click_node: Option<NodeId>,
210 /// Coordinates of the most recent click on a selectable text node.
211 #[get(skip)]
212 pub(crate) text_last_click_pos: Option<Point>,
213 /// Elapsed seconds since the most recent click on a selectable text node.
214 #[get(type(copy))]
215 pub(crate) text_last_click_age_secs: f32,
216 /// Active multi-touch / pointer contact map keyed by `pointer_id` for pinch & swipe recognition.
217 pub(crate) active_pointers: HashMap<u64, Point>,
218 /// Device kind recorded per active `pointer_id` for deterministic touch vs mouse separation.
219 pub(crate) active_pointer_devices: HashMap<u64, PointerDevice>,
220 /// Initial contact point of the active single-pointer gesture stroke.
221 #[get(skip)]
222 pub(crate) gesture_origin: Option<Point>,
223 /// Baseline two-finger distance recorded when a pinch gesture starts.
224 #[get(type(copy))]
225 pub(crate) pinch_base_dist: f32,
226 /// Accumulated hold duration in seconds for long-press gesture detection.
227 #[get(type(copy))]
228 pub(crate) gesture_hold_secs: f32,
229 /// Whether `GestureEventKind::LongPress` has already fired for the current press.
230 #[get(type(copy))]
231 pub(crate) long_press_fired: bool,
232 /// Coordinates of the most recent completed clean tap for double-tap detection.
233 #[get(skip)]
234 pub(crate) last_tap_pos: Option<Point>,
235 /// Elapsed seconds since the most recent completed clean tap.
236 #[get(type(copy))]
237 pub(crate) last_tap_age_secs: f32,
238 /// Monotonic gesture event sequence counter.
239 #[get(type(copy))]
240 pub(crate) gesture_seq: u64,
241 /// Inertial touch-scroll fling velocity in logical pixels per second.
242 #[get(type(copy))]
243 pub(crate) scroll_velocity: Point,
244 /// Pointer coordinates where inertial touch-scroll fling originated for hit-target resolution.
245 #[get(type(copy))]
246 pub(crate) scroll_fling_pos: Point,
247 /// Locked innermost scrollable node captured at touch-down to prevent nested scroll penetration.
248 #[get(skip)]
249 pub(crate) touch_scroll_target: Option<NodeId>,
250 /// Remaining smooth-scroll interpolation delta for discrete mouse-wheel notches.
251 #[get(type(copy))]
252 pub(crate) smooth_scroll_pending: Point,
253 /// Current critically-damped velocity in logical pixels per second for C1-continuous smooth scrolling.
254 #[get(pub(crate), type(copy))]
255 #[get_mut(skip)]
256 #[set(pub(crate))]
257 pub(crate) smooth_scroll_velocity: Point,
258 /// Pointer coordinates captured when smooth wheel scrolling started.
259 #[get(type(copy))]
260 pub(crate) smooth_scroll_pos: Point,
261 /// Locked scroll container target for active smooth wheel interpolation.
262 #[get(skip)]
263 pub(crate) smooth_scroll_target: Option<NodeId>,
264 /// Re-entrancy guard preventing nested `step_frame` execution during macOS live-resize callbacks.
265 #[get(type(copy))]
266 pub(crate) in_step_frame: bool,
267 /// Accumulated blink phase timer in seconds for the focused `NodeKind::Input` caret.
268 #[get(type(copy))]
269 pub(crate) caret_blink_secs: f32,
270 /// When `true`, global swipe gestures are suppressed because the active stroke started in a canvas, slider, or isolated region.
271 #[get(type(copy))]
272 pub(crate) gesture_suppressed: bool,
273 /// Elapsed seconds accumulated for smoothed live FPS telemetry publication.
274 #[get(type(copy))]
275 pub(crate) fps_accum_secs: f32,
276 /// Rendered frame count accumulated inside the current FPS sampling window.
277 #[get(type(copy))]
278 pub(crate) fps_accum_frames: u32,
279 /// Accumulated frame time in seconds used to pace frames when an explicit FPS cap is configured.
280 #[get(type(copy))]
281 pub(crate) fps_budget_accum: f32,
282 /// Whether an editable `NodeKind::Input` currently holds focus and requests the system IME keyboard.
283 #[get(type(copy))]
284 pub(crate) last_ime_active: bool,
285 /// Handle of the `NodeKind::Input` that most recently activated the system IME keyboard.
286 #[get(skip)]
287 pub(crate) last_ime_node: Option<NodeId>,
288 /// Damage region rasterized during the most recent rendered frame for partial native surface presentation.
289 #[get(type(copy))]
290 pub(crate) last_frame_damage: DamageRegion,
291 /// Detected native hardware display refresh rate in Hertz (`60.0` fallback, `120.0`/`144.0`/`180.0`+ on high-refresh screens).
292 #[get(type(copy))]
293 pub(crate) display_refresh_rate_hz: f32,
294 /// Whether motion animations, smooth scrolling, inertia, or active games were running on the previous frame.
295 #[get(type(copy))]
296 pub(crate) was_animating: bool,
297 /// Cross-platform lifecycle and system event normalizer deduplicating OS notifications.
298 pub(crate) system_event_normalizer: SystemEventNormalizer,
299 /// Opt-in flag enabling per-phase microsecond timing instrumentation inside `step_frame` (zero syscall overhead when `false`).
300 #[get(type(copy))]
301 #[set(skip)]
302 pub(crate) telemetry_enabled: bool,
303 /// Most recently recorded `FrameTelemetry` snapshot.
304 #[get(type(copy))]
305 pub(crate) last_frame_telemetry: FrameTelemetry,
306 /// Pending diagnostic reason associated with `pending_damage` when full-viewport damage was queued before `step_frame`.
307 #[get(type(copy))]
308 pub(crate) pending_full_redraw_reason: FullRedrawReason,
309 /// Logical viewport size rasterized during the most recent rendered frame.
310 #[get(type(copy))]
311 pub(crate) last_rendered_viewport: Size,
312 /// Display DPI scale factor rasterized during the most recent rendered frame.
313 #[get(type(copy))]
314 pub(crate) last_rendered_scale: f32,
315 /// Active presented frames-per-second rate (`0.0` once idle beyond the sampling window).
316 #[get(type(copy))]
317 pub(crate) active_present_fps: f32,
318 /// Continuous idle seconds elapsed since the most recent rendered frame.
319 #[get(type(copy))]
320 pub(crate) idle_secs_since_present: f32,
321 /// Whether the most recent `step_frame` call skipped rendering due to a clean idle scene.
322 #[get(type(copy))]
323 pub(crate) is_idle_frame: bool,
324 /// True when the only pending paint was triggered by transitioning the HUD into idle state (prevents `Idle <-> FPS` wakeup ping-pong).
325 #[get(type(copy))]
326 pub(crate) idle_badge_paint_pending: bool,
327 /// Monotonic wall-clock timestamp of the most recent active (non-idle-badge) frame presentation.
328 #[cfg(not(target_arch = "wasm32"))]
329 #[get(type(copy))]
330 pub(crate) last_active_present_at: Option<Instant>,
331 /// Toggle enabling surgical pre/post-layout conservative bounds diffing instead of full-screen layout fallback (default `true`).
332 #[get(type(copy))]
333 #[set(skip)]
334 pub(crate) partial_layout_damage: bool,
335 /// Root reactive scope created by `App::mount` so root effects freeze cleanly in background.
336 #[get(skip)]
337 #[get_mut(skip)]
338 #[set(skip)]
339 pub(crate) mount_scope: Option<Scope>,
340 /// True while the application is frozen in background (zero CPU ticks, zero layout/paint/GPU work).
341 #[get(pub(crate), type(copy))]
342 #[set(pub(crate))]
343 pub(crate) background_frozen: bool,
344 /// True on the first frame after returning from background so elapsed sleep time clamps to `dt = 0.0`.
345 #[get(pub(crate), type(copy))]
346 #[set(pub(crate))]
347 pub(crate) resume_zero_dt_pending: bool,
348 /// Reactive scope handles frozen exclusively by background entry (leaving pre-frozen router pages untouched).
349 #[get(pub(crate))]
350 #[get_mut(pub(crate))]
351 #[set(pub(crate))]
352 pub(crate) background_frozen_scopes: Vec<ScopeId>,
353 /// Deterministic gesture arbitration arena enforcing priority tiers and touch-slop disambiguation.
354 #[get(pub(crate))]
355 #[get_mut(pub(crate))]
356 #[set(pub(crate))]
357 pub(crate) gesture_arena: GestureArena,
358 /// Last immersive fullscreen state synchronized with the platform backend.
359 #[get(pub(crate), type(copy))]
360 #[set(pub(crate))]
361 pub(crate) last_immersive_fullscreen: bool,
362 /// Most recently observed input pointer device kind (`Mouse`, `Touch`, or `Pen`).
363 #[get(pub(crate), type(copy))]
364 #[set(pub(crate))]
365 pub(crate) last_pointer_device: PointerDevice,
366 /// Monotonic frame timestamp in nanoseconds of the most recent active touch contact or touch fling step.
367 #[get(pub(crate), type(copy))]
368 #[set(pub(crate))]
369 pub(crate) last_touch_event_ns: u64,
370 /// Surface presentation generation and automatic same-generation submit-failure retry tracker.
371 pub(crate) surface_present: SurfacePresentState,
372 /// Bounded, cancellable, context-validated route pre-warming pipeline.
373 pub(crate) route_prewarmer: RoutePrewarmer,
374 /// Unified deterministic page lifecycle controller (`Freeze`, `Resume`, `Evict`, `Destroy`, generation guards).
375 pub(crate) page_lifecycle: PageLifecycleController,
376 /// Low-overhead single-owner framework resource ownership and leak accountant.
377 pub(crate) resource_accountant: ResourceAccountant,
378 /// Accumulated elapsed seconds inside the current callback-rate measurement window.
379 #[get(pub(crate), type(copy))]
380 #[set(pub(crate))]
381 pub(crate) callback_accum_secs: f32,
382 /// Callback invocations counted inside the current callback-rate measurement window.
383 #[get(pub(crate), type(copy))]
384 #[set(pub(crate))]
385 pub(crate) callback_accum_ticks: u32,
386 /// Most recently measured host callback cadence in Hertz.
387 #[get(pub(crate), type(copy))]
388 #[set(pub(crate))]
389 pub(crate) last_callback_rate_hz: f32,
390 /// Whether `last_callback_rate_hz` holds a fresh measured callback rate sample.
391 #[get(pub(crate), type(copy))]
392 #[set(pub(crate))]
393 pub(crate) has_callback_rate_sample: bool,
394 /// Monotonic application clock in nanoseconds used for deterministic present timestamps and accounting grace periods.
395 #[get(pub(crate), type(copy))]
396 #[set(pub(crate))]
397 pub(crate) monotonic_clock_ns: u64,
398 /// Persistent per-frame scratch buffers reused across `step_frame` and input dispatch for zero steady-state heap allocations.
399 #[debug(skip)]
400 #[get(skip)]
401 #[get_mut(skip)]
402 #[set(skip)]
403 pub(crate) frame_arena: AppFrameArena,
404 /// Fixed 4-sample monotonic input timestamp ring `(ts_ns, x, y)` for phase-aligned resampling toward `target_present_time_ns`.
405 #[get(skip)]
406 #[get_mut(skip)]
407 #[set(skip)]
408 pub(crate) input_resample_ring: [(u64, f32, f32); 4],
409 /// Next write index into `input_resample_ring` in `0..4`.
410 #[get(pub(crate), type(copy))]
411 #[set(pub(crate))]
412 pub(crate) input_resample_head: usize,
413 /// Number of valid monotonic samples currently stored in `input_resample_ring` (`0..=4`).
414 #[get(pub(crate), type(copy))]
415 #[set(pub(crate))]
416 pub(crate) input_resample_len: usize,
417 /// Monotonic timestamp in nanoseconds of the previous scroll event for precision-trackpad vs discrete-wheel classification.
418 #[get(pub(crate), type(copy))]
419 #[set(pub(crate))]
420 pub(crate) last_scroll_ts_ns: u64,
421 /// Bounded multi-rect dirty set computed during the most recent rendered frame.
422 #[get(type(copy))]
423 pub(crate) last_dirty_rect_set: DirtyRectSet,
424 /// Adaptive dirty-region submission strategy selected for the most recent rendered frame.
425 #[get(type(copy))]
426 pub(crate) last_dirty_strategy: DirtyRectStrategy,
427 /// Bounded retained page/scroll layer registry preserving scroll offsets, focus, and animation timelines across route switches.
428 pub(crate) retained_layers: RetainedLayerRegistry,
429 /// Boxed hysteresis-guarded EWMA + p95 frame-budget stabilizer scaling only internal 3D/water offscreen workload under sustained frame-miss risk while preserving 100% lossless UI/text/vector 1:1 physical pixels.
430 #[get(skip)]
431 #[get_mut(pub(crate))]
432 #[set(skip)]
433 pub(crate) frame_budget_stabilizer: Box<FrameBudgetStabilizer>,
434}
435
436/// Persistent reusable scratch vectors owned by `App` so steady-state frames allocate zero heap buffers.
437#[derive(CustomDebug, Default)]
438pub(crate) struct AppFrameArena {
439 /// Reusable visible portal and backdrop-blur descriptor scratch list.
440 pub(crate) visible_portals: Vec<PortalBackdropRegion>,
441 /// Reusable active game viewport dirty rect scratch list.
442 pub(crate) game_damage_rects: Vec<Rect>,
443 /// Reusable active `GameEngineHost` index scratch list.
444 pub(crate) active_host_indices: Vec<usize>,
445 /// Reusable clipped scroll container `(node_id, old_bounds)` list whose `DIRTY_SUBTREE_LAYOUT` bit is temporarily stashed during paint-damage collection.
446 pub(crate) stashed_scroll_nodes: Vec<(NodeId, Rect)>,
447 /// Reusable pre-layout scroll anchor snapshots preserving scrolled viewports across dynamic content height changes.
448 pub(crate) scroll_anchors: Vec<ScrollAnchorSnapshot>,
449 /// Reusable UI event callback queue avoiding per-pointer-move and per-scroll `Vec` allocations.
450 #[debug(skip)]
451 pub(crate) callbacks: Vec<(UiEventHandler, UiEvent)>,
452}
453
454/// Per-node scroll-chain evaluation step separating standard scroll, virtual scroll, parent traversal, and chaining blocks.
455#[derive(Clone, Copy, Debug, Default)]
456pub(crate) struct ScrollStepOutcome {
457 /// Standard scroll update `(next_offset, consumed_x, consumed_y)`.
458 pub(crate) std_update: Option<(Point, f32, f32)>,
459 /// Virtual scroll update `(next_virtual_y, total_virtual_h, consumed_y)`.
460 pub(crate) virtual_update: Option<(f32, f32, f32)>,
461 /// True when `next_parent_id` holds a valid ancestor along the scroll chain.
462 pub(crate) has_next_parent: bool,
463 /// Next ancestor node handle along the scroll chain when `has_next_parent` is `true`.
464 pub(crate) next_parent_id: NodeId,
465 /// True when this node blocks scroll chaining to outer ancestors.
466 pub(crate) blocks_scroll: bool,
467}
468
469/// Fused single-borrow pre-tick snapshot collected at the start of `App::step_frame`.
470#[derive(Clone, Copy, Debug, Default)]
471pub(crate) struct FramePreTick {
472 /// Whether a live `NodeKind::Input` currently holds keyboard focus.
473 pub(crate) has_focused_input: bool,
474 /// Whether `ime_node_id` holds a visible non-disabled input node requesting OS IME presentation.
475 pub(crate) has_ime_node: bool,
476 /// Focused input node handle requesting OS IME presentation when `has_ime_node` is `true`.
477 pub(crate) ime_node_id: NodeId,
478 /// Screen-space logical bounds of `ime_node_id`.
479 pub(crate) ime_rect: Rect,
480 /// Resolved frame animation timestep in seconds.
481 pub(crate) step_dt: f32,
482 /// Whether one or more `NodeTransition`s ticked inside the fused borrow.
483 pub(crate) anim_ticked: bool,
484 /// Whether active transitions were deferred until after `GameEngineHost::step`.
485 pub(crate) pending_game_transitions: bool,
486}
487
488/// Stack-first ancestor chain buffer avoiding heap allocations up to 32 tree levels deep.
489#[derive(Debug)]
490pub(crate) struct AncestorChain {
491 /// Inline stack buffer holding the first 32 ancestors (leaf first).
492 pub(crate) inline: [NodeId; 32],
493 /// Number of valid entries in `inline` when `spill` is empty.
494 pub(crate) len: usize,
495 /// Heap overflow buffer used only when ancestor depth exceeds 32.
496 pub(crate) spill: Vec<NodeId>,
497}