Send all fills of a shape in a single wasm call

This commit is contained in:
Belén Albeza 2025-06-03 15:37:36 +02:00
parent e9bd44b819
commit 9fc3f4858a
3 changed files with 43 additions and 20 deletions

View file

@ -495,6 +495,10 @@ impl Shape {
self.fills.iter()
}
pub fn set_fills(&mut self, fills: Vec<Fill>) {
self.fills = fills;
}
pub fn add_fill(&mut self, f: Fill) {
self.fills.push(f);
}

View file

@ -63,6 +63,15 @@ pub fn parse_fills_from_bytes(buffer: &[u8], num_fills: usize) -> Vec<shapes::Fi
.collect()
}
#[no_mangle]
pub extern "C" fn set_shape_fills() {
with_current_shape!(state, |shape: &mut Shape| {
let bytes = mem::bytes();
let fills = parse_fills_from_bytes(&bytes, bytes.len() / RAW_FILL_DATA_SIZE);
shape.set_fills(fills);
});
}
#[no_mangle]
pub extern "C" fn add_shape_fill() {
with_current_shape!(state, |shape: &mut Shape| {