Skip to main content

euv_core/render/pipeline/
struct.rs

1use super::*;
2
3/// Shared font provider, glyph coverage atlas, and text shaping service reused across active and fallback backends.
4#[derive(Clone, Data, Debug, Default)]
5pub struct FontAtlasService {
6    /// Active native OS or deterministic font provider.
7    pub(crate) font_provider: NativeSystemFont,
8    /// Shared glyph coverage atlas transferred to fallback or switched backends without 3x duplication.
9    pub(crate) glyph_atlas: GlyphAtlas,
10    /// Shared DPI-independent text shaping and line-break cache.
11    pub(crate) text_shaping_cache: TextShapingCache,
12}
13
14/// Fluent per-frame parameter bundle for `Renderer::render_with`.
15#[derive(Clone, Copy, Data, Debug, PartialEq)]
16pub struct FrameRenderParams {
17    /// Logical viewport size.
18    #[get(type(copy))]
19    pub(crate) viewport: Size,
20    /// Active physical DPI scale factor.
21    #[get(type(copy))]
22    pub(crate) scale_factor: f32,
23    /// Surface background clear color.
24    #[get(type(copy))]
25    pub(crate) clear_color: Color,
26    /// Layout pass telemetry from the current frame.
27    #[get(type(copy))]
28    pub(crate) layout_stats: LayoutStats,
29    /// Damaged screen region requiring rasterization.
30    #[get(type(copy))]
31    pub(crate) damage: DamageRegion,
32}
33
34/// Unified single-backend rendering facade orchestrating lazy Software, Hardware, and Hybrid execution.
35#[derive(Data, Debug)]
36pub struct Renderer {
37    /// Active render configuration.
38    #[get(type(copy))]
39    pub(crate) config: RenderConfig,
40    /// Resolved active render mode (never `Auto`).
41    #[get(type(copy))]
42    pub(crate) active_mode: RenderMode,
43    /// Resolved active graphics backend.
44    #[get(type(copy))]
45    pub(crate) active_backend: GraphicsBackend,
46    /// Strictly single active rendering backend instantiated for the resolved mode.
47    #[get(skip)]
48    #[get_mut(skip)]
49    #[set(skip)]
50    pub(crate) active_backend_impl: ActiveRenderBackend,
51    /// Lazily allocated CPU reference software fallback instantiated only on fallback or reference readback.
52    #[get(skip)]
53    #[get_mut(skip)]
54    #[set(skip)]
55    pub(crate) fallback_software: Option<Box<SoftwareRenderer>>,
56    /// Single shared font provider, glyph atlas, and text shaping service across all render paths.
57    pub(crate) font_service: FontAtlasService,
58    /// Tracked physical surface width in pixels for lazy backend instantiation.
59    #[get(type(copy))]
60    #[get_mut(skip)]
61    #[set(pub(crate))]
62    pub(crate) surface_width: u32,
63    /// Tracked physical surface height in pixels for lazy backend instantiation.
64    #[get(type(copy))]
65    #[get_mut(skip)]
66    #[set(pub(crate))]
67    pub(crate) surface_height: u32,
68    /// Reusable scene-to-display-list compiler handle.
69    #[get(skip)]
70    #[get_mut(skip)]
71    #[set(skip)]
72    pub(crate) paint_pass: PaintPass,
73    /// Cross-frame retained `DisplayList` and subtree `DrawCommand` fragment cache.
74    #[get(pub(crate))]
75    #[get_mut(skip)]
76    #[set(skip)]
77    pub(crate) paint_fragment_cache: PaintFragmentCache,
78    /// Reusable frame display list.
79    pub(crate) display_list: DisplayList,
80    /// Monotonic frame counter.
81    #[get(type(copy))]
82    pub(crate) frame_index: u64,
83    /// Whether to compute full-framebuffer FNV-1a pixel hashes on each frame (enabled for headless parity tests).
84    #[get(type(copy))]
85    pub(crate) compute_pixel_hash: bool,
86    /// Whether per-frame timing instrumentation (`Instant::now`) is active inside software band scheduling.
87    #[get(type(copy))]
88    pub(crate) telemetry_enabled: bool,
89    /// Active render mode of the most recent hashed frame (`None` before first render or after mode switch).
90    #[get(skip)]
91    #[get_mut(skip)]
92    #[set(skip)]
93    pub(crate) last_hashed_mode: Option<RenderMode>,
94    /// Physical framebuffer dimensions `(phys_w, phys_h)` of the most recent hashed frame.
95    #[get(skip)]
96    #[get_mut(skip)]
97    #[set(skip)]
98    pub(crate) last_hashed_dims: (u32, u32),
99    /// Telemetry from the most recent frame.
100    #[get(type(copy))]
101    pub(crate) last_stats: FrameStats,
102    /// Non-degrading runtime fallback policy engine (never downgrades shadows, blur, AA, clipping, or resolution).
103    pub(crate) fallback_policy: FallbackPolicyEngine,
104    /// Cumulative frames executed via the composite-only fast path without relayout or full repaint.
105    #[get(type(copy))]
106    #[get_mut(skip)]
107    #[set(skip)]
108    pub(crate) composite_fast_path_frames: u64,
109    /// Cumulative frames routed to full CPU reference rasterization by `FallbackPolicyEngine`.
110    #[get(type(copy))]
111    #[get_mut(skip)]
112    #[set(skip)]
113    pub(crate) cpu_fallback_frames: u64,
114    /// Unified 5-stage adaptive render router governing startup cache, probing, selection, handoff, and faults.
115    pub(crate) adaptive_router: AdaptiveRenderRouter,
116    /// Truthful per-frame observability snapshot from the most recent rendered or skipped frame.
117    #[get(type(copy))]
118    pub(crate) last_adaptive_metrics: AdaptiveFrameMetrics,
119}