🐛 Fix wasm glitches

This commit is contained in:
Alejandro Alonso 2025-02-12 10:21:17 +01:00 committed by Aitor Moreno
parent 26a2ef8fb7
commit 64e6d0b1f8
5 changed files with 68 additions and 14 deletions

View file

@ -47,6 +47,13 @@ pub extern "C" fn clean_up() {
mem::free_bytes();
}
#[no_mangle]
pub extern "C" fn clear_cache() {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
let render_state = state.render_state();
render_state.clear_cache();
}
#[no_mangle]
pub extern "C" fn set_render_options(debug: u32, dpr: f32) {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
@ -98,7 +105,9 @@ pub extern "C" fn resize_viewbox(width: i32, height: i32) {
#[no_mangle]
pub extern "C" fn set_view(zoom: f32, x: f32, y: f32) {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
state.render_state().viewbox.set_all(zoom, x, y);
let render_state = state.render_state();
render_state.invalidate_cache_if_needed();
render_state.viewbox.set_all(zoom, x, y);
}
#[no_mangle]