mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🔧 Rebuild indices on zoom change, not pan
This commit is contained in:
@@ -251,10 +251,15 @@ pub extern "C" fn set_view_end() {
|
|||||||
state.render_state.options.set_fast_mode(false);
|
state.render_state.options.set_fast_mode(false);
|
||||||
// We can have renders in progress
|
// We can have renders in progress
|
||||||
state.render_state.cancel_animation_frame();
|
state.render_state.cancel_animation_frame();
|
||||||
if state.render_state.options.is_profile_rebuild_tiles() {
|
// Only rebuild tile indices when zoom has changed.
|
||||||
state.rebuild_tiles();
|
// During pan-only operations, shapes stay in the same tiles
|
||||||
} else {
|
// because tile_size = 1/scale * TILE_SIZE (depends only on zoom).
|
||||||
state.rebuild_tiles_shallow();
|
if state.render_state.zoom_changed() {
|
||||||
|
if state.render_state.options.is_profile_rebuild_tiles() {
|
||||||
|
state.rebuild_tiles();
|
||||||
|
} else {
|
||||||
|
state.rebuild_tiles_shallow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2057,6 +2057,12 @@ impl RenderState {
|
|||||||
self.cached_viewbox.zoom() * self.options.dpr()
|
self.cached_viewbox.zoom() * self.options.dpr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the zoom level has changed since the last cached viewbox.
|
||||||
|
/// Used to optimize pan-only operations where tile indices don't need to be rebuilt.
|
||||||
|
pub fn zoom_changed(&self) -> bool {
|
||||||
|
(self.viewbox.zoom - self.cached_viewbox.zoom).abs() > f32::EPSILON
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mark_touched(&mut self, uuid: Uuid) {
|
pub fn mark_touched(&mut self, uuid: Uuid) {
|
||||||
self.touched_ids.insert(uuid);
|
self.touched_ids.insert(uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user