🐛 Fix zoom performance and behaviour

This commit is contained in:
Alejandro Alonso 2025-05-21 14:41:12 +02:00
parent ec29c4f5fe
commit 3597e5bb54
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();
}
});
});
}