Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

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

MikeeIf8f581eea00f
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 0e9a6417a..b31935feb 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -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);
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index 488d207df..5d8e5fceb 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -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))