euv_example/app/struct.rs
1use super::*;
2
3/// Independent stacked HTML `<canvas>` presentation target locked to a single browser context family.
4#[derive(Clone, Copy, Data, Debug, Eq, PartialEq)]
5pub struct ShowcaseWebCanvasSlot {
6 /// Unique monotonic identifier for this `<canvas>` DOM element.
7 #[get(type(copy))]
8 pub(crate) canvas_id: u64,
9 /// Permanently locked context family (`WebGl2` or `Canvas2d`) for this `<canvas>`.
10 #[get(type(copy))]
11 pub(crate) context_family: ShowcaseWebCanvasContextFamily,
12 /// Target presentation path served by this slot.
13 #[get(type(copy))]
14 pub(crate) path: ShowcaseWebPresentationPath,
15 /// Whether this `<canvas>` is currently visible in the foreground stack.
16 #[get(type(copy))]
17 pub(crate) visible: bool,
18 /// CSS stacking `z-index` (`1` active foreground, `0` hidden standby).
19 #[get(type(copy))]
20 pub(crate) z_index: i32,
21 /// Physical canvas width in pixels.
22 #[get(type(copy))]
23 pub(crate) width: u32,
24 /// Physical canvas height in pixels.
25 #[get(type(copy))]
26 pub(crate) height: u32,
27 /// Scene revision rendered into this slot (`0` before first frame).
28 #[get(type(copy))]
29 pub(crate) scene_version: u64,
30 /// Whether the candidate's first frame has completed and is ready for atomic handoff.
31 #[get(type(copy))]
32 pub(crate) ready: bool,
33}
34
35/// Stacked dual-canvas handoff controller guaranteeing independent `<canvas>` targets and honest `SubmissionProxy` telemetry.
36#[derive(Clone, Data, Debug, Eq, PartialEq)]
37pub struct ShowcaseWebDualCanvasCoordinator {
38 /// Foreground visible `<canvas>` currently presenting frames.
39 #[get(type(copy))]
40 pub(crate) active: ShowcaseWebCanvasSlot,
41 /// Optional hidden sibling `<canvas>` pre-warming a candidate backend before atomic frame-boundary swap.
42 #[get(skip)]
43 pub(crate) standby: Option<ShowcaseWebCanvasSlot>,
44 /// Explicit CPU-mirror flag (`false` for `GpuDirect`; `true` for `GpuUpload` and `Canvas2d`).
45 #[get(type(copy))]
46 pub(crate) cpu_mirror_active: bool,
47 /// Truthful timing source (browser rAF always reports `SubmissionProxy`).
48 #[get(type(copy))]
49 pub(crate) timing_source: ShowcaseWebTimingSource,
50 /// Next unique `<canvas>` ID allocator.
51 #[get(type(copy))]
52 pub(crate) next_canvas_id: u64,
53 /// Total atomic frame-boundary handoff swaps committed.
54 #[get(type(copy))]
55 pub(crate) completed_swaps: u64,
56 /// Total aborted candidate handoffs leaving the previous canvas active.
57 #[get(type(copy))]
58 pub(crate) aborted_swaps: u64,
59 /// Total browser rAF ticks recorded strictly as `SubmissionProxy`.
60 #[get(type(copy))]
61 pub(crate) raf_proxy_ticks: u64,
62 /// Exact framebuffer upload bytes reported on the latest frame (`0` on `GpuDirect`).
63 #[get(type(copy))]
64 pub(crate) last_upload_bytes: u64,
65 /// Ordered history of retired `<canvas>` IDs removed only after atomic commit.
66 pub(crate) retired_canvas_ids: Vec<u64>,
67}
68
69/// Persistent zero-DOM WebAssembly canvas host runtime backing Mini-Programs, QuickApps, and WASM Wearables.
70#[cfg(target_arch = "wasm32")]
71#[derive(Data)]
72pub struct HostCanvasRuntime {
73 /// Active EUV application instance rendering into the software RGBA8 framebuffer.
74 pub(crate) app: App,
75 /// Shared reactive showcase state.
76 pub(crate) state: ShowcaseState,
77 /// Multi-touch contact tracker translating touch phases into pointer events and drag gestures.
78 pub(crate) touch_tracker: TouchPointerTracker,
79 /// Canonical host vendor identifier (e.g. `"wechat"`, `"alliance"`, `"vivo-watch"`).
80 pub(crate) vendor: String,
81 /// Active platform kind (`MiniApp`, `QuickApp`, or `Wearable`).
82 #[get(type(copy))]
83 pub(crate) platform_kind: PlatformKind,
84 /// Current logical viewport width in dp.
85 #[get(type(copy))]
86 pub(crate) logical_width: u32,
87 /// Current logical viewport height in dp.
88 #[get(type(copy))]
89 pub(crate) logical_height: u32,
90 /// Active display pixel ratio.
91 #[get(type(copy))]
92 pub(crate) dpr: f32,
93 /// Whether host lifecycle froze the frame pump (`onHide`/`onUnload`/screen-off).
94 #[get(type(copy))]
95 pub(crate) paused: bool,
96 /// Whether wearable Always-On Display (1Hz ambient) mode is active.
97 #[get(type(copy))]
98 pub(crate) ambient: bool,
99 /// Pending dirty flag requiring a software rasterization pass on the next host step.
100 #[get(type(copy))]
101 pub(crate) dirty: bool,
102 /// Whether the next rendered frame must report full-viewport damage (`[0, 0, phys_w, phys_h]`).
103 #[get(type(copy))]
104 pub(crate) force_full_dirty: bool,
105 /// Last rendered physical dirty rectangle X origin in pixels.
106 #[get(type(copy))]
107 pub(crate) dirty_x: u32,
108 /// Last rendered physical dirty rectangle Y origin in pixels.
109 #[get(type(copy))]
110 pub(crate) dirty_y: u32,
111 /// Last rendered physical dirty rectangle width in pixels.
112 #[get(type(copy))]
113 pub(crate) dirty_w: u32,
114 /// Last rendered physical dirty rectangle height in pixels.
115 #[get(type(copy))]
116 pub(crate) dirty_h: u32,
117 /// Total frames rasterized during this host session.
118 #[get(type(copy))]
119 pub(crate) frame_count: u64,
120 /// Deterministic pixel hash of the latest rasterized frame.
121 #[get(type(copy))]
122 pub(crate) last_frame_hash: u64,
123 /// Accumulated fractional crown detents for discrete wearable focus/directional stepping.
124 #[get(type(copy))]
125 pub(crate) crown_remainder: f32,
126}