From 7b8fccf785493621111ab993881e6ffa6a5d28ab Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 7 Nov 2026 03:47:31 -0800 Subject: [PATCH] Tests: huge-selection vertex counts leave out the art's raster The huge type-on-a-path selection test compares the canvas mesh drawn with the Rectangle tool against the one drawn with the Selection tool. When the render worker's frame lands between the two (a slow first frame under heavy load), the art's textured quad shows in only one of them, and the test counted its 4 vertices as brackets. canvas_vertices and frame_vertices now skip the mesh drawn with the canvas art texture, so the counts hold only what the overlays draw. A huge selection of type, images, symbols or meshes used the same comparison. --- crates/ui-egui/src/canvas/tests.rs | 9 +++++++-- crates/ui-egui/src/tests/pathtype.rs | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index f630d801d..d289a0403 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -1602,13 +1602,18 @@ fn shapes(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec { } /// Two headless canvas frames → the vertices of the second one's tessellated mesh, which the -/// GPU takes in one buffer. +/// GPU takes in one buffer, without the art's raster: the render worker's frame can land in +/// either frame of a comparison. fn frame_vertices(app: &mut VectorcraftApp, ctx: &egui::Context) -> usize { frame(app, ctx, vec![]); let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() }; let mut out = ctx.run_ui(raw, |ui| show(app, ui)); out.textures_delta.clear(); - let mesh = |p: &egui::ClippedPrimitive| if let egui::epaint::Primitive::Mesh(m) = &p.primitive { m.vertices.len() } else { 0 }; + let art = app.canvas.texture.as_ref().map(|t| t.id()); + let mesh = |p: &egui::ClippedPrimitive| match &p.primitive { + egui::epaint::Primitive::Mesh(m) if Some(m.texture_id) != art => m.vertices.len(), + _ => 0, + }; ctx.tessellate(out.shapes, out.pixels_per_point).iter().map(mesh).sum() } diff --git a/crates/ui-egui/src/tests/pathtype.rs b/crates/ui-egui/src/tests/pathtype.rs index 46f5eff67..4a14c1e0f 100644 --- a/crates/ui-egui/src/tests/pathtype.rs +++ b/crates/ui-egui/src/tests/pathtype.rs @@ -30,13 +30,18 @@ fn open_options(app: &mut VectorcraftApp) { } /// Two headless canvas frames → the vertices of the second one's tessellated mesh, which the GPU -/// takes in one buffer. +/// takes in one buffer, without the art's raster: the render worker's frame can land in either +/// frame of a comparison. fn canvas_vertices(app: &mut VectorcraftApp, ctx: &egui::Context) -> usize { let raw = || egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0))), ..Default::default() }; ctx.run_ui(raw(), |ui| crate::canvas::show(app, ui)).textures_delta.clear(); let mut out = ctx.run_ui(raw(), |ui| crate::canvas::show(app, ui)); out.textures_delta.clear(); - let mesh = |p: &egui::ClippedPrimitive| if let egui::epaint::Primitive::Mesh(m) = &p.primitive { m.vertices.len() } else { 0 }; + let art = app.canvas.texture.as_ref().map(|t| t.id()); + let mesh = |p: &egui::ClippedPrimitive| match &p.primitive { + egui::epaint::Primitive::Mesh(m) if Some(m.texture_id) != art => m.vertices.len(), + _ => 0, + }; ctx.tessellate(out.shapes, out.pixels_per_point).iter().map(mesh).sum() }