mirror of https://github.com/penpot/penpot.git
🐛 Fix using cache on first zoom after pan
This commit is contained in:
parent
d635f5a8dc
commit
a948e49e51
|
|
@ -275,6 +275,14 @@ pub extern "C" fn set_view_end() {
|
||||||
}
|
}
|
||||||
performance::end_measure!("set_view_end::rebuild_tiles");
|
performance::end_measure!("set_view_end::rebuild_tiles");
|
||||||
performance::end_timed_log!("rebuild_tiles", _rebuild_start);
|
performance::end_timed_log!("rebuild_tiles", _rebuild_start);
|
||||||
|
} else {
|
||||||
|
// During pan, we only clear the tile index without
|
||||||
|
// invalidating cached textures, which is more efficient.
|
||||||
|
let _clear_start = performance::begin_timed_log!("clear_tile_index");
|
||||||
|
performance::begin_measure!("set_view_end::clear_tile_index");
|
||||||
|
state.clear_tile_index();
|
||||||
|
performance::end_measure!("set_view_end::clear_tile_index");
|
||||||
|
performance::end_timed_log!("clear_tile_index", _clear_start);
|
||||||
}
|
}
|
||||||
performance::end_measure!("set_view_end");
|
performance::end_measure!("set_view_end");
|
||||||
performance::end_timed_log!("set_view_end", _end_start);
|
performance::end_timed_log!("set_view_end", _end_start);
|
||||||
|
|
|
||||||
|
|
@ -1962,6 +1962,17 @@ impl RenderState {
|
||||||
performance::end_measure!("rebuild_tiles_shallow");
|
performance::end_measure!("rebuild_tiles_shallow");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clears the tile index without invalidating cached tile textures.
|
||||||
|
/// This is useful when tile positions don't change (e.g., during pan operations)
|
||||||
|
/// but the tile index needs to be synchronized. The cached tile textures remain
|
||||||
|
/// valid since they don't depend on the current view position, only on zoom level.
|
||||||
|
/// This is much more efficient than clearing the entire cache surface.
|
||||||
|
pub fn clear_tile_index(&mut self) {
|
||||||
|
performance::begin_measure!("clear_tile_index");
|
||||||
|
self.surfaces.clear_tiles();
|
||||||
|
performance::end_measure!("clear_tile_index");
|
||||||
|
}
|
||||||
|
|
||||||
pub fn rebuild_tiles_from(&mut self, tree: ShapesPoolRef, base_id: Option<&Uuid>) {
|
pub fn rebuild_tiles_from(&mut self, tree: ShapesPoolRef, base_id: Option<&Uuid>) {
|
||||||
performance::begin_measure!("rebuild_tiles");
|
performance::begin_measure!("rebuild_tiles");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,10 @@ impl Surfaces {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_tiles(&mut self) {
|
||||||
|
self.tiles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn resize(&mut self, gpu_state: &mut GpuState, new_width: i32, new_height: i32) {
|
pub fn resize(&mut self, gpu_state: &mut GpuState, new_width: i32, new_height: i32) {
|
||||||
self.reset_from_target(gpu_state.create_target_surface(new_width, new_height));
|
self.reset_from_target(gpu_state.create_target_surface(new_width, new_height));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,10 @@ impl<'a> State<'a> {
|
||||||
self.render_state.rebuild_tiles_shallow(&self.shapes);
|
self.render_state.rebuild_tiles_shallow(&self.shapes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_tile_index(&mut self) {
|
||||||
|
self.render_state.clear_tile_index();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn rebuild_tiles(&mut self) {
|
pub fn rebuild_tiles(&mut self) {
|
||||||
self.render_state.rebuild_tiles_from(&self.shapes, None);
|
self.render_state.rebuild_tiles_from(&self.shapes, None);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue