Merge pull request #6526 from penpot/superalex-improve-zoom-performance-and-behaviour

🐛 Fix zoom performance and behaviour
This commit is contained in:
Aitor Moreno 2025-05-22 12:15:38 +02:00 committed by GitHub
commit d54a7d0401
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 60 additions and 30 deletions

View file

@ -91,9 +91,19 @@ pub extern "C" fn set_canvas_background(raw_color: u32) {
}
#[no_mangle]
pub extern "C" fn render(timestamp: i32) {
pub extern "C" fn render(_: i32) {
with_state!(state, {
state.start_render_loop(timestamp).expect("Error rendering");
state
.start_render_loop(performance::get_time())
.expect("Error rendering");
});
}
#[no_mangle]
pub extern "C" fn render_from_cache(_: i32) {
with_state!(state, {
let render_state = state.render_state();
render_state.render_from_cache();
});
}
@ -137,17 +147,16 @@ pub extern "C" fn resize_viewbox(width: i32, height: i32) {
pub extern "C" fn set_view(zoom: f32, x: f32, y: f32) {
with_state!(state, {
let render_state = state.render_state();
let zoom_changed = zoom != render_state.viewbox.zoom;
render_state.viewbox.set_all(zoom, x, y);
if zoom_changed {
with_state!(state, {
if state.render_state.options.is_profile_rebuild_tiles() {
state.rebuild_tiles();
} else {
state.rebuild_tiles_shallow();
}
});
}
with_state!(state, {
// We can have renders in progress
state.render_state.cancel_animation_frame();
if state.render_state.options.is_profile_rebuild_tiles() {
state.rebuild_tiles();
} else {
state.rebuild_tiles_shallow();
}
});
});
}