perf(ui): reuse exact tile bounds for selection and layer edges (#116)

Use the existing weak-identity cache rather than rescanning unchanged boundary pixels. Dense cold scans can cost more; repeated reads reuse exact bounds.
This commit is contained in:
MikeeI authored and GitHub committed 2026-10-05 01:23:20 -04:00
1 parent 66fd3fc0fa
commit f8f581eea0
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -1024,7 +1024,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
// View › Show › Layer Edges: the active layer's content bounds.
if app.ui.view.shows(app.ui.view.show.layer_edges)
&& let Some(st) = app.session.documents().get(idx)
&& let Some(b) = st.active_layer.and_then(|id| st.doc.layer(id)).and_then(|l| l.surface()).map(|s| s.content_bounds())
&& let Some(b) = st.active_layer.and_then(|id| st.doc.layer(id)).and_then(|l| l.surface()).map(photocraft_compose::bounds::content_bounds)
&& !b.is_empty()
{
painter.rect_stroke(xf.doc_rect(b), 0, Stroke::new(1.0, Color32::from_rgb(0x2d, 0x8c, 0xeb)), egui::StrokeKind::Outside);
+1 -1
View File
@@ -842,7 +842,7 @@ fn info_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let fx = move |px: f64| units.format(px, dpi, size.width as f64);
let units_y = app.session.prefs().units_and_rulers.clone();
let fy = move |px: f64| units_y.format(px, dpi, size.height as f64);
let sel = st.doc.selection.as_ref().map(|m| m.content_bounds());
let sel = st.doc.selection.as_ref().map(photocraft_compose::bounds::content_bounds);
let pos = app
.hover_doc
.map(|p| (p[0].floor() as i32, p[1].floor() as i32))