Skip to content

armgit / klad

Public Imported from GitHub
0

A drawing app built for agent/human collaboration

Rust

The numbers panel shows the canvas work per frame

Indicode BV46ab22f71033
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7d36ee..d775905 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,6 +33,7 @@ The first builds, and klad's licences.
- Noise and haze no longer make every edit redraw the tiles around it.
- Drawings with many clipped layers and groups redraw several times faster: each tile skips the stacks that have nothing in it.
- A tap that wobbles selects a shape or strokes without nudging them: a drag starts once the pointer has moved 3 points on screen.
+- The numbers panel shows how long the canvas takes each frame, next to the rest of the interface.
- Switching layers no longer redraws the whole canvas when nothing on it changes.
- Fixed tiles that could stay blank or out of date when a panel or popup was laid out for the first time while the canvas was being redrawn.
diff --git a/crates/app/src/editor/panels.rs b/crates/app/src/editor/panels.rs
index a1a6eb6..038e21e 100644
--- a/crates/app/src/editor/panels.rs
+++ b/crates/app/src/editor/panels.rs
@@ -133,7 +133,9 @@ impl Editor {
.show(ui, |ui| self.check(|e| e.tool_options(ui)));
}
let panels = ms(start);
+ let drawing = Instant::now();
egui::CentralPanel::no_frame().show(ui, |ui| self.check(|e| e.canvas(ui)));
+ lock(&self.stats).canvas_ms.push(ms(drawing) as f32);
let after = Instant::now();
self.windows(&ctx);
self.first_steps_window(&ctx);
@@ -999,6 +1001,7 @@ impl Editor {
),
format!("pen to GPU {}", s.latency_ms.summary()),
format!("ui {}", s.ui_ms.spread()),
+ format!("canvas {}", s.canvas_ms.spread()),
format!("compose {}", s.compose_ms.summary()),
format!("tiles {}", s.tiles.summary()),
format!("upload {}", s.upload_ms.summary()),
diff --git a/crates/app/src/editor/ui_tests.rs b/crates/app/src/editor/ui_tests.rs
index 0ddba00..15fe597 100644
--- a/crates/app/src/editor/ui_tests.rs
+++ b/crates/app/src/editor/ui_tests.rs
@@ -457,6 +457,10 @@ fn every_control_is_pen_sized_and_has_a_hover_hint() {
h.state_mut().windows.brush = true;
h.state_mut().say(Tone::Error, "a test error with a close button");
h.run_steps(3);
+ assert!(
+ h.query_by_label_contains("canvas median").is_some(),
+ "the numbers show the canvas work"
+ );
checked += audit(&h, "windows open");
super::prefs::Section::ALL.into_iter().for_each(|section| {
h.state_mut().settings_section = section;
diff --git a/crates/app/src/stats.rs b/crates/app/src/stats.rs
index 203f24e..11d1b3d 100644
--- a/crates/app/src/stats.rs
+++ b/crates/app/src/stats.rs
@@ -65,6 +65,7 @@ pub struct Stats {
pub step_ms: Rolling,
pub frame_upload_ms: Rolling,
pub ui_ms: Rolling,
+ pub canvas_ms: Rolling,
}
pub fn lock<T>(mutex: &Mutex<T>) -> MutexGuard<'_, T> {