🎉 Non blocking render wasm (#5726)

This commit is contained in:
Alejandro 2025-02-10 11:46:56 +01:00 committed by GitHub
parent f65f7d68e6
commit 8f11a925df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 210 additions and 174 deletions

View file

@ -58,34 +58,28 @@ pub extern "C" fn set_render_options(debug: u32, dpr: f32) {
#[no_mangle]
pub extern "C" fn set_canvas_background(raw_color: u32) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
let color = skia::Color::new(raw_color);
state.set_background_color(color);
}
#[no_mangle]
pub unsafe extern "C" fn render() {
pub unsafe extern "C" fn render(timestamp: i32) {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
state.render_all(true);
state.start_render_loop(timestamp).expect("Error rendering");
}
#[no_mangle]
pub unsafe extern "C" fn render_without_cache() {
pub unsafe extern "C" fn render_from_cache() {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
state.render_all(false);
state.render_from_cache();
}
#[no_mangle]
pub unsafe extern "C" fn zoom() {
let state: &mut Box<State<'_>> =
unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
state.zoom();
}
#[no_mangle]
pub unsafe extern "C" fn pan() {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
state.pan();
pub unsafe extern "C" fn process_animation_frame(timestamp: i32) {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
state
.process_animation_frame(timestamp)
.expect("Error processing animation frame");
}
#[no_mangle]