1use std::collections::BTreeMap;
2
3use sui_core::{DirtyRegion, Size, WindowId};
4use sui_platform::AccessibilitySnapshot;
5use sui_runtime::{FocusState, WidgetGraphSnapshot};
6use sui_scene::SceneFrame;
7
8#[derive(Debug, Clone, PartialEq)]
9pub struct SceneSummary {
10 pub viewport: Size,
11 pub dirty_regions: Vec<DirtyRegion>,
12 pub command_count: usize,
13 pub command_breakdown: Vec<(String, usize)>,
14}
15
16impl SceneSummary {
17 pub(crate) fn from_frame(frame: &SceneFrame) -> Self {
18 let mut command_breakdown = BTreeMap::<String, usize>::new();
19 let mut command_count = 0usize;
20 frame.scene.visit_commands(&mut |command| {
21 command_count += 1;
22 *command_breakdown
23 .entry(command.diagnostic_name().to_string())
24 .or_default() += 1;
25 });
26
27 Self {
28 viewport: frame.viewport,
29 dirty_regions: frame.dirty_regions.clone(),
30 command_count,
31 command_breakdown: command_breakdown.into_iter().collect(),
32 }
33 }
34}
35
36#[derive(Debug, Clone, PartialEq)]
37pub struct WindowSnapshot {
38 pub window_id: WindowId,
39 pub title: String,
40 pub accessibility: AccessibilitySnapshot,
41 pub widget_graph: WidgetGraphSnapshot,
42 pub focus_state: FocusState,
43 pub scene_summary: Option<SceneSummary>,
44}