ailloli_ui_editor/
frame.rs

1//! Neutral frame outputs and per-frame diagnostic counters.
2
3use crate::layout::EditorTextRun;
4use crate::{EditorPaintItem, EditorViewport};
5use ailloli_ui_core::Size;
6
7/// Per-frame performance counters measured by the editor engine.
8///
9/// Times are integer microseconds and may be zero below clock resolution.
10/// Counts are per frame; `used_fast_path` reports the large-document path.
11///
12/// # Examples
13///
14/// ```
15/// use ailloli_ui_editor::EditorFrameDebugMetrics;
16/// let name = std::any::type_name::<EditorFrameDebugMetrics>();
17/// assert!(name.ends_with("EditorFrameDebugMetrics"));
18/// ```
19#[derive(Debug, Clone, Copy, PartialEq)]
20pub struct EditorFrameDebugMetrics {
21    /// Monotonically wrapping engine frame ID.
22    pub frame_id: u64,
23    /// Visible paragraph layout time in microseconds.
24    pub visible_layout_us: u64,
25    /// Paragraph layouts reused from cache.
26    pub paragraph_cache_hits: usize,
27    /// Paragraph layouts newly prepared.
28    pub paragraph_cache_misses: usize,
29    /// Syntax refresh time in microseconds.
30    pub syntax_parse_us: u64,
31    /// Symbol indexing time in microseconds.
32    pub symbol_index_us: u64,
33    /// Number of neutral paint items emitted.
34    pub paint_item_count: usize,
35    /// Glyph uploads attributed by the adapter; zero in engine-only frames.
36    pub glyph_upload_count: usize,
37    /// Whether large-document fast-path thresholds selected reduced work.
38    pub used_fast_path: bool,
39}
40
41/// Complete editor frame generated by the engine for one viewport.
42///
43/// # Examples
44///
45/// ```
46/// use ailloli_ui_editor::EditorFrame;
47/// fn inspect(frame: &EditorFrame) {
48///     assert_eq!(frame.debug_metrics.paint_item_count, frame.paint_items.len());
49/// }
50/// ```
51#[derive(Debug, Clone)]
52pub struct EditorFrame {
53    /// Resolved widget/content/text/gutter geometry.
54    pub viewport: EditorViewport,
55    /// Full logical-pixel content size before viewport clipping.
56    pub content_size: Size,
57    /// Visible shaped paragraph runs.
58    pub runs: Vec<EditorTextRun>,
59    /// Adapter-neutral ordered paint commands.
60    pub paint_items: Vec<EditorPaintItem>,
61    /// Source paragraph indices represented in `runs`.
62    pub painted_paragraphs: Vec<usize>,
63    /// Work and timing counters for this frame.
64    pub debug_metrics: EditorFrameDebugMetrics,
65}