1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
use super::*;
/// Fluent builder helpers for `FrameRenderParams`.
impl FrameRenderParams {
/// Creates frame render parameters for `viewport` with `1.0` scale, white clear color, and full damage.
///
/// # Arguments
///
/// - `Size` - Logical viewport size.
///
/// # Returns
///
/// - `Self` - Ready render parameters.
#[must_use]
pub fn new(viewport: Size) -> Self {
Self {
viewport,
scale_factor: 1.0,
clear_color: COLOR_WHITE,
layout_stats: LayoutStats::default(),
damage: DamageRegion::full(),
}
}
/// Sets the active DPI scale factor.
///
/// # Arguments
///
/// - `Self` - Base parameters.
/// - `f32` - Scale factor.
///
/// # Returns
///
/// - `Self` - Updated parameters.
#[must_use]
pub fn with_scale(mut self, scale_factor: f32) -> Self {
self.set_scale_factor(scale_factor.max(0.5));
self
}
/// Sets the surface clear color.
///
/// # Arguments
///
/// - `Self` - Base parameters.
/// - `Color` - Clear color.
///
/// # Returns
///
/// - `Self` - Updated parameters.
#[must_use]
pub fn with_clear(mut self, clear_color: Color) -> Self {
self.set_clear_color(clear_color);
self
}
/// Attaches layout telemetry from the current frame.
///
/// # Arguments
///
/// - `Self` - Base parameters.
/// - `LayoutStats` - Layout pass statistics.
///
/// # Returns
///
/// - `Self` - Updated parameters.
#[must_use]
pub fn with_layout_stats(mut self, layout_stats: LayoutStats) -> Self {
self.set_layout_stats(layout_stats);
self
}
/// Sets the active dirty damage region.
///
/// # Arguments
///
/// - `Self` - Base parameters.
/// - `DamageRegion` - Damage region.
///
/// # Returns
///
/// - `Self` - Updated parameters.
#[must_use]
pub fn with_damage(mut self, damage: DamageRegion) -> Self {
self.set_damage(damage);
self
}
}
/// Multi-mode pipeline construction, live mode switching, and frame rendering for `Renderer`.
impl Renderer {
/// Creates a `Renderer` resolving the optimal backend for `platform` and `config`.
///
/// # Arguments
///
/// - `PlatformKind` - Active execution platform.
/// - `PlatformCapabilities` - Hardware capabilities reported by the platform backend.
/// - `u32` - Initial physical width.
/// - `u32` - Initial physical height.
/// - `RenderConfig` - Requested rendering configuration.
///
/// # Returns
///
/// - `Self` - Initialized multi-mode renderer facade.
#[must_use]
pub fn new(
platform: PlatformKind,
capabilities: PlatformCapabilities,
width: u32,
height: u32,
config: RenderConfig,
) -> Self {
let (active_mode, active_backend): (RenderMode, GraphicsBackend) =
Self::resolve_mode_and_backend(platform, capabilities, config);
let readback_mirror: bool = !config.get_direct_gpu_present();
let compute_pixel_hash: bool =
platform == PlatformKind::Headless || active_backend == GraphicsBackend::Headless;
let font_provider: NativeSystemFont = if platform == PlatformKind::Headless {
NativeSystemFont::deterministic()
} else {
NativeSystemFont::system()
};
let mut display_list: DisplayList = DisplayList::default();
display_list.get_mut_commands().reserve(128);
let (sw_w, sw_h): (u32, u32) = if active_mode == RenderMode::Software {
(width, height)
} else {
(1, 1)
};
let (hw_w, hw_h, hw_backend): (u32, u32, GraphicsBackend) =
if matches!(active_mode, RenderMode::Hardware | RenderMode::Auto) {
(width, height, active_backend)
} else {
(1, 1, GraphicsBackend::Headless)
};
let (hy_w, hy_h): (u32, u32) = if active_mode == RenderMode::Hybrid {
(width, height)
} else {
(1, 1)
};
let semantics: RenderSemanticsContract =
RenderSemanticsContract::from_render_config(config, 1.0);
Self {
config,
active_mode,
active_backend,
software: SoftwareRenderer::with_font_provider(
sw_w,
sw_h,
config,
font_provider.clone(),
),
hardware: HardwareRenderer::with_backend_and_font(
hw_backend,
hw_w,
hw_h,
config,
readback_mirror,
font_provider.clone(),
),
hybrid: HybridRenderer::with_backend_and_font(
active_backend,
hy_w,
hy_h,
config,
font_provider,
),
paint_pass: PaintPass,
paint_fragment_cache: PaintFragmentCache::default(),
display_list,
frame_index: 0,
compute_pixel_hash,
last_hashed_mode: None,
last_hashed_dims: (0, 0),
last_stats: FrameStats::default(),
fallback_policy: FallbackPolicyEngine::with_display_hz(60.0, semantics),
composite_fast_path_frames: 0,
cpu_fallback_frames: 0,
}
}
/// Enables or disables direct GPU rendering without steady-state CPU RGBA readback mirroring.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `bool` - `true` for GPU direct-draw (zero CPU RGBA mirror); `false` to enable software readback mirror.
pub fn set_direct_gpu_present(&mut self, enabled: bool) {
let mut cfg: RenderConfig = self.get_config();
cfg.set_direct_gpu_present(enabled);
self.set_config(cfg);
let Self {
hardware,
last_hashed_mode,
..
} = self;
hardware.set_enable_readback(!enabled);
*last_hashed_mode = None;
}
/// Captures the active visual semantics contract verifying zero quality degradation across fallback transitions.
///
/// # Arguments
///
/// - `&Self` - Renderer reference.
/// - `f32` - Active display scale factor.
///
/// # Returns
///
/// - `RenderSemanticsContract` - Immutable visual fidelity snapshot.
#[must_use]
pub fn semantics_contract(&self, scale_factor: f32) -> RenderSemanticsContract {
RenderSemanticsContract::from_render_config(self.get_config(), scale_factor)
}
/// Captures an on-demand CPU reference framebuffer for pixel-parity verification even while direct GPU draw is enabled.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `DamageRegion` - Damage region to rasterize into the reference framebuffer.
///
/// # Returns
///
/// - `&Framebuffer` - Rendered full-fidelity CPU reference RGBA8 framebuffer.
pub fn capture_reference_framebuffer(&mut self, damage: DamageRegion) -> &Framebuffer {
let Self {
active_mode,
software,
hardware,
hybrid,
display_list,
..
} = self;
match *active_mode {
RenderMode::Software => {
let (_, _): (usize, usize) = software.render(display_list, damage);
software.get_framebuffer()
}
RenderMode::Hybrid => hybrid.get_software().get_framebuffer(),
RenderMode::Hardware | RenderMode::Auto => {
hardware.capture_reference_readback(display_list, damage)
}
}
}
/// Evaluates `trigger` through `FallbackPolicyEngine` and applies strictly non-degrading cache trimming or CPU reference switching.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `FallbackTrigger` - Runtime pressure, frame overrun, or GPU fault trigger.
/// - `u64` - Monotonic clock timestamp in milliseconds.
///
/// # Returns
///
/// - `FallbackAction` - Strictly non-degrading action applied.
pub fn apply_fallback_trigger(
&mut self,
trigger: FallbackTrigger,
now_ms: u64,
) -> FallbackAction {
let action: FallbackAction = self
.get_mut_fallback_policy()
.evaluate_trigger(trigger, now_ms);
match action {
FallbackAction::TrimPrefetchAndColdCache { retain_ratio } => {
let Self {
software,
hardware,
paint_fragment_cache,
..
} = self;
let _: usize = hardware.trim_gpu_caches(retain_ratio);
let budget: usize =
((GLYPH_ATLAS_DEFAULT_BUDGET_BYTES as f32) * retain_ratio.clamp(0.1, 1.0))
.round()
.max(GLYPH_ATLAS_MIN_BUDGET_BYTES as f32) as usize;
software.get_mut_glyph_atlas().set_memory_budget(budget);
hardware
.get_mut_readback()
.get_mut_glyph_atlas()
.set_memory_budget(budget);
if retain_ratio <= FALLBACK_CRITICAL_RETAIN_RATIO + 0.01 {
paint_fragment_cache.clear();
}
}
FallbackAction::SwitchToCpuReference { .. } => {
let mut next_cfg: RenderConfig = self.get_config();
next_cfg.set_mode(RenderMode::Software);
self.set_config(next_cfg);
self.set_active_mode(RenderMode::Software);
self.set_active_backend(GraphicsBackend::SoftwareCpu);
let Self {
last_hashed_mode, ..
} = self;
*last_hashed_mode = None;
}
FallbackAction::None
| FallbackAction::AdjustPresentCadence { .. }
| FallbackAction::RouteLayerToCpuReference => {}
}
action
}
/// Resolves `(RenderMode, GraphicsBackend)` deterministically from platform capabilities and user preference.
///
/// # Arguments
///
/// - `PlatformKind` - Target platform.
/// - `PlatformCapabilities` - Hardware support flags.
/// - `RenderConfig` - User configuration.
///
/// # Returns
///
/// - `(RenderMode, GraphicsBackend)` - Concrete resolved mode and backend.
#[must_use]
pub fn resolve_mode_and_backend(
platform: PlatformKind,
capabilities: PlatformCapabilities,
config: RenderConfig,
) -> (RenderMode, GraphicsBackend) {
let default_gpu: GraphicsBackend = platform.default_graphics_backend();
let mode: RenderMode = match config.get_mode() {
RenderMode::Auto => {
if capabilities.get_hardware_gpu() {
RenderMode::Hardware
} else {
RenderMode::Software
}
}
explicit => explicit,
};
let backend: GraphicsBackend = match mode {
RenderMode::Software => match platform {
PlatformKind::Web | PlatformKind::MiniApp | PlatformKind::QuickApp => {
GraphicsBackend::Canvas2d
}
_ => GraphicsBackend::SoftwareCpu,
},
RenderMode::Hardware | RenderMode::Hybrid => {
config.preferred_backend_value().unwrap_or(default_gpu)
}
RenderMode::Auto => default_gpu,
};
(mode, backend)
}
/// Dynamically switches the active rendering mode at runtime without rebuilding the scene tree.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `PlatformKind` - Active platform kind.
/// - `PlatformCapabilities` - Platform hardware capabilities.
/// - `RenderMode` - Target render mode.
pub fn switch_mode(
&mut self,
platform: PlatformKind,
capabilities: PlatformCapabilities,
mode: RenderMode,
) {
let mut next_cfg: RenderConfig = self.get_config();
next_cfg.set_mode(mode);
let (resolved_mode, resolved_backend): (RenderMode, GraphicsBackend) =
Self::resolve_mode_and_backend(platform, capabilities, next_cfg);
self.set_config(next_cfg);
self.set_active_mode(resolved_mode);
self.set_active_backend(resolved_backend);
let Self {
hardware,
hybrid,
last_hashed_mode,
..
} = self;
*last_hashed_mode = None;
hardware.get_mut_driver().switch_backend(resolved_backend);
hybrid
.get_mut_compositor()
.set_backend_kind(resolved_backend);
}
/// Compiles `tree` into a `DisplayList`, executes the active render backend, and returns `FrameStats`.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `&SceneTree` - Laid-out scene tree.
/// - `Size` - Logical viewport dimensions.
/// - `f32` - Active DPI scale factor.
/// - `Color` - Surface clear color.
/// - `LayoutStats` - Telemetry from the layout pass.
/// - `DamageRegion` - Damaged screen region.
///
/// # Returns
///
/// - `Result<FrameStats, PlatformError>` - Frame performance and pixel-hash telemetry.
pub fn render_frame(
&mut self,
tree: &SceneTree,
viewport: Size,
scale_factor: f32,
clear_color: Color,
layout_stats: LayoutStats,
damage: DamageRegion,
) -> Result<FrameStats, PlatformError> {
let params: FrameRenderParams = FrameRenderParams::new(viewport)
.with_scale(scale_factor)
.with_clear(clear_color)
.with_layout_stats(layout_stats)
.with_damage(damage);
self.render_frame_composite_aware(tree, ¶ms, false)
}
/// Compiles `tree` into a `DisplayList`, honoring composite-only fast paths and non-degrading CPU reference fallback on unsupported GPU effects.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `&SceneTree` - Laid-out scene tree.
/// - `&FrameRenderParams` - Viewport, DPI, clear color, layout stats, and damage bundle.
/// - `bool` - Whether only composite/scroll properties changed with zero layout or paint mutations.
///
/// # Returns
///
/// - `Result<FrameStats, PlatformError>` - Frame performance, direct-draw, fallback, and pixel-hash telemetry.
pub fn render_frame_composite_aware(
&mut self,
tree: &SceneTree,
params: &FrameRenderParams,
composite_only: bool,
) -> Result<FrameStats, PlatformError> {
let viewport: Size = params.get_viewport();
let scale: f32 = params.get_scale_factor().max(0.5);
let clear_color: Color = params.get_clear_color();
let layout_stats: LayoutStats = params.get_layout_stats();
let damage: DamageRegion = params.get_damage();
let phys_w: u32 = ((viewport.get_width() * scale).round() as u32).max(1);
let phys_h: u32 = ((viewport.get_height() * scale).round() as u32).max(1);
let phys_dims: (u32, u32) = (phys_w, phys_h);
let Self {
active_mode,
active_backend,
software,
hardware,
hybrid,
paint_pass,
paint_fragment_cache,
display_list,
frame_index,
compute_pixel_hash,
last_hashed_mode,
last_hashed_dims,
last_stats,
fallback_policy,
composite_fast_path_frames,
cpu_fallback_frames,
..
} = self;
let mode: RenderMode = *active_mode;
let backend: GraphicsBackend = *active_backend;
let do_pixel_hash: bool = *compute_pixel_hash;
let hash_reusable: bool = *last_hashed_mode == Some(mode) && *last_hashed_dims == phys_dims;
if !damage.get_full_damage() && damage.bounds_rect().is_none() && hash_reusable {
*frame_index = frame_index.wrapping_add(1);
let stats: FrameStats = FrameStats {
frame_index: *frame_index,
active_mode: mode,
active_backend: backend,
layout_nodes: layout_stats.get_nodes_computed(),
layout_skipped: layout_stats.get_subtrees_skipped(),
draw_commands: 0,
draw_batches: 0,
pixels_shaded: 0,
frame_hash: last_stats.get_frame_hash(),
composite_only: false,
gpu_direct_draw: false,
cpu_rgba_upload_bytes: 0,
submit_outcome: FrameSubmitOutcome::SkippedNoDamage,
};
*last_stats = stats;
return Ok(stats);
}
let _: &PaintPass = paint_pass;
let layout_changed: bool = layout_stats.get_nodes_computed() > 0;
let took_composite_fast_path: bool = composite_only && !layout_changed;
if took_composite_fast_path {
*composite_fast_path_frames = composite_fast_path_frames.saturating_add(1);
}
PaintPass::build_retained(
tree,
viewport,
scale,
clear_color,
layout_changed,
display_list,
paint_fragment_cache,
);
let cmd_count: usize = display_list.len();
let mut gpu_direct_draw: bool = false;
let cpu_rgba_upload_bytes: usize;
let mut effective_mode: RenderMode = mode;
let mut effective_backend: GraphicsBackend = backend;
let (batches, pixels, hash): (usize, usize, u64) = match mode {
RenderMode::Software => {
let (b, p): (usize, usize) = software.render(display_list, damage);
cpu_rgba_upload_bytes = (phys_w as usize)
.saturating_mul(phys_h as usize)
.saturating_mul(4);
let h: u64 = if p == 0 && hash_reusable {
last_stats.get_frame_hash()
} else if do_pixel_hash {
software.get_framebuffer().fnv1a_hash()
} else {
display_list.fast_hash()
};
(b, p, h)
}
RenderMode::Hybrid => {
let (b, p): (usize, usize) = hybrid.render(display_list, damage)?;
cpu_rgba_upload_bytes = (phys_w as usize)
.saturating_mul(phys_h as usize)
.saturating_mul(4);
let h: u64 = if p == 0 && hash_reusable {
last_stats.get_frame_hash()
} else if do_pixel_hash {
hybrid.get_software().get_framebuffer().fnv1a_hash()
} else {
display_list.fast_hash()
};
(b, p, h)
}
RenderMode::Hardware | RenderMode::Auto => {
match hardware.render(display_list, damage) {
Ok((b, p)) => {
if hardware.get_has_unsupported_effect() {
let _: FallbackAction = fallback_policy.evaluate_trigger(
FallbackTrigger::MissingGpuEffectPath { isolatable: false },
0,
);
*cpu_fallback_frames = cpu_fallback_frames.saturating_add(1);
let (sb, sp): (usize, usize) = software.render(display_list, damage);
effective_mode = RenderMode::Software;
effective_backend = GraphicsBackend::SoftwareCpu;
cpu_rgba_upload_bytes = (phys_w as usize)
.saturating_mul(phys_h as usize)
.saturating_mul(4);
let h: u64 = if do_pixel_hash {
software.get_framebuffer().fnv1a_hash()
} else {
display_list.fast_hash()
};
(sb, sp, h)
} else {
gpu_direct_draw = !hardware.get_enable_readback();
cpu_rgba_upload_bytes = hardware.get_last_cpu_rgba_upload_bytes();
let h: u64 = if p == 0 && hash_reusable {
last_stats.get_frame_hash()
} else if hardware.get_enable_readback() {
if do_pixel_hash {
hardware.get_readback().get_framebuffer().fnv1a_hash()
} else {
display_list.fast_hash()
}
} else {
hardware.batch_hash()
};
(b, p, h)
}
}
Err(_) => {
let _: FallbackAction =
fallback_policy.evaluate_trigger(FallbackTrigger::DeviceLost, 0);
*cpu_fallback_frames = cpu_fallback_frames.saturating_add(1);
let (sb, sp): (usize, usize) = software.render(display_list, damage);
effective_mode = RenderMode::Software;
effective_backend = GraphicsBackend::SoftwareCpu;
cpu_rgba_upload_bytes = (phys_w as usize)
.saturating_mul(phys_h as usize)
.saturating_mul(4);
let h: u64 = if do_pixel_hash {
software.get_framebuffer().fnv1a_hash()
} else {
display_list.fast_hash()
};
(sb, sp, h)
}
}
}
};
*last_hashed_mode = Some(effective_mode);
*last_hashed_dims = phys_dims;
*frame_index = frame_index.wrapping_add(1);
let stats: FrameStats = FrameStats {
frame_index: *frame_index,
active_mode: effective_mode,
active_backend: effective_backend,
layout_nodes: layout_stats.get_nodes_computed(),
layout_skipped: layout_stats.get_subtrees_skipped(),
draw_commands: cmd_count,
draw_batches: batches,
pixels_shaded: pixels,
frame_hash: hash,
composite_only: took_composite_fast_path,
gpu_direct_draw,
cpu_rgba_upload_bytes,
submit_outcome: FrameSubmitOutcome::Submitted,
};
*last_stats = stats;
Ok(stats)
}
/// Renders `tree` using a compact `FrameRenderParams` descriptor and returns `FrameStats`.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
/// - `&SceneTree` - Laid-out scene tree.
/// - `&FrameRenderParams` - Viewport, DPI, clear color, layout stats, and damage bundle.
///
/// # Returns
///
/// - `Result<FrameStats, PlatformError>` - Frame performance and pixel-hash telemetry.
#[inline(always)]
pub fn render_with(
&mut self,
tree: &SceneTree,
params: &FrameRenderParams,
) -> Result<FrameStats, PlatformError> {
self.render_frame(
tree,
params.get_viewport(),
params.get_scale_factor(),
params.get_clear_color(),
params.get_layout_stats(),
params.get_damage(),
)
}
/// Advances the frame counter for an undamaged idle frame without rasterizing or hashing pixels.
///
/// # Arguments
///
/// - `&Self` - Mutable renderer.
///
/// # Returns
///
/// - `FrameStats` - Lightweight telemetry preserving the last rendered `frame_hash` with zero shaded pixels.
pub fn record_skipped_frame(&mut self) -> FrameStats {
let next_idx: u64 = self.get_frame_index().wrapping_add(1);
self.set_frame_index(next_idx);
let mut stats: FrameStats = self.get_last_stats();
stats.set_frame_index(next_idx);
stats.set_layout_nodes(0);
stats.set_draw_batches(0);
stats.set_pixels_shaded(0);
stats.set_composite_only(false);
stats.set_gpu_direct_draw(false);
stats.set_cpu_rgba_upload_bytes(0);
stats.set_submit_outcome(FrameSubmitOutcome::SkippedNoDamage);
self.set_last_stats(stats);
stats
}
/// Returns cumulative cross-frame `PaintFragmentCache` telemetry `(whole_list_hits, fragment_hits, fragment_misses, fragment_evictions)`.
///
/// # Arguments
///
/// - `&Self` - Renderer reference.
///
/// # Returns
///
/// - `(u64, u64, u64, u64)` - Tuple of whole-list hits, fragment hits, misses, and evictions.
#[must_use]
pub fn paint_fragment_cache_stats(&self) -> (u64, u64, u64, u64) {
self.get_paint_fragment_cache().stats()
}
/// Returns a reference to the latest CPU-accessible `Framebuffer` for software/hybrid/readback presentation.
///
/// # Arguments
///
/// - `&Self` - Renderer reference.
///
/// # Returns
///
/// - `Option<&Framebuffer>` - Active RGBA8 framebuffer if available in host memory.
#[must_use]
pub fn framebuffer(&self) -> Option<&Framebuffer> {
match self.get_active_mode() {
RenderMode::Software => Some(self.get_software().get_framebuffer()),
RenderMode::Hybrid => Some(self.get_hybrid().get_software().get_framebuffer()),
RenderMode::Hardware | RenderMode::Auto => {
if self.get_hardware().get_enable_readback() {
Some(self.get_hardware().get_readback().get_framebuffer())
} else {
None
}
}
}
}
}