mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 10:56:13 +02:00
✨ Write shapes directly to wasm memory
This commit is contained in:
parent
29e0964ebc
commit
4623f36042
9 changed files with 186 additions and 139 deletions
31
render-wasm/src/shapes.rs
Normal file
31
render-wasm/src/shapes.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use crate::render::{render_rect, State};
|
||||
use skia_safe as skia;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Selrect {
|
||||
pub x1: f32,
|
||||
pub y1: f32,
|
||||
pub x2: f32,
|
||||
pub y2: f32,
|
||||
}
|
||||
|
||||
pub type Shape = Selrect; // temp
|
||||
|
||||
pub static mut SHAPES_BUFFER: [Shape; 2048] = [Selrect {
|
||||
x1: 0.0,
|
||||
y1: 0.0,
|
||||
x2: 0.0,
|
||||
y2: 0.0,
|
||||
}; 2048];
|
||||
|
||||
pub(crate) fn draw_all(state: &mut State) {
|
||||
let shapes;
|
||||
unsafe {
|
||||
shapes = SHAPES_BUFFER.iter();
|
||||
}
|
||||
|
||||
for shape in shapes {
|
||||
let r = skia::Rect::new(shape.x1, shape.y1, shape.x2, shape.y2);
|
||||
render_rect(&mut state.surface, r, skia::Color::RED);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue