mirror of
https://github.com/penpot/penpot.git
synced 2025-05-14 11:26:38 +02:00
🎉 Improve performace for zoom and pan with wasm render
This commit is contained in:
parent
7b57509d2d
commit
ec8799d806
5 changed files with 84 additions and 14 deletions
|
@ -3,6 +3,7 @@ pub mod shapes;
|
|||
pub mod state;
|
||||
pub mod utils;
|
||||
pub mod view;
|
||||
pub mod images;
|
||||
|
||||
use skia_safe as skia;
|
||||
|
||||
|
@ -46,7 +47,13 @@ pub unsafe extern "C" fn resize_surface(width: i32, height: i32) {
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn render() {
|
||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||
state.draw_all_shapes(state.view.zoom, state.view.x, state.view.y);
|
||||
state.draw_all_shapes();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn navigate() {
|
||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||
state.navigate();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -56,11 +63,13 @@ pub extern "C" fn reset_canvas() {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn set_view(zoom: f32, x: f32, y: f32) {
|
||||
pub extern "C" fn set_view(zoom: f32, x: f32, y: f32, width: f32, height: f32) {
|
||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||
state.view.zoom = zoom;
|
||||
state.view.x = x;
|
||||
state.view.y = y;
|
||||
state.view.zoom = zoom;
|
||||
state.view.width = width;
|
||||
state.view.height = height;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue