🎉 Improve frame rendering

This commit is contained in:
AzazelN28 2024-11-20 13:49:45 +01:00
parent 59fdf64c66
commit 2db1740ce8
6 changed files with 59 additions and 31 deletions

View file

@ -2,6 +2,7 @@ pub mod render;
pub mod shapes;
pub mod state;
pub mod utils;
pub mod view;
use skia_safe as skia;
@ -43,9 +44,9 @@ pub unsafe extern "C" fn resize_surface(width: i32, height: i32) {
}
#[no_mangle]
pub unsafe extern "C" fn draw_all_shapes(zoom: f32, pan_x: f32, pan_y: f32) {
pub unsafe extern "C" fn render() {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
state.draw_all_shapes(zoom, pan_x, pan_y);
state.draw_all_shapes(state.view.zoom, state.view.x, state.view.y);
}
#[no_mangle]
@ -54,6 +55,14 @@ pub extern "C" fn reset_canvas() {
state.render_state().reset_canvas();
}
#[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.view.x = x;
state.view.y = y;
state.view.zoom = zoom;
}
#[no_mangle]
pub extern "C" fn use_shape(a: u32, b: u32, c: u32, d: u32) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");