🎉 Refactor naming anidated shapes with children for wasm render

This commit is contained in:
Alejandro Alonso 2024-11-13 11:48:29 +01:00
parent 7e5115ecd9
commit c1d213a0cd
5 changed files with 15 additions and 15 deletions

View file

@ -130,19 +130,19 @@ pub unsafe extern "C" fn set_shape_transform(a: f32, b: f32, c: f32, d: f32, e:
}
#[no_mangle]
pub extern "C" fn add_child_shape(a: u32, b: u32, c: u32, d: u32) {
pub extern "C" fn add_shape_child(a: u32, b: u32, c: u32, d: u32) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
let id = uuid_from_u32_quartet(a, b, c, d);
if let Some(shape) = state.current_shape.as_deref_mut() {
shape.shapes.push(id);
shape.children.push(id);
}
}
#[no_mangle]
pub extern "C" fn clear_child_shapes() {
pub extern "C" fn clear_shape_children() {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape.as_deref_mut() {
shape.shapes.clear();
shape.children.clear();
}
}

View file

@ -84,7 +84,7 @@ pub(crate) fn render_shape_tree(state: &mut State, id: Uuid) {
render_single_shape(&mut state.render_state.surface, shape);
// draw all the children shapes
let shape_ids = shape.shapes.clone();
let shape_ids = shape.children.clone();
for shape_id in shape_ids {
render_shape_tree(state, shape_id);
}

View file

@ -73,7 +73,7 @@ impl Fill {
p.set_style(skia::PaintStyle::Fill);
p.set_anti_alias(true);
// TODO: get proper blend mode. See https://tree.taiga.io/project/penpot/task/9275
p.set_blend_mode(skia::BlendMode::DstOver);
p.set_blend_mode(skia::BlendMode::SrcOver);
p
}
}
@ -83,7 +83,7 @@ impl Fill {
#[derive(Debug, Clone)]
pub struct Shape {
pub id: Uuid,
pub shapes: Vec<Uuid>,
pub children: Vec::<Uuid>,
pub kind: Kind,
pub selrect: Rect,
pub transform: Matrix,
@ -95,7 +95,7 @@ impl Shape {
pub fn new(id: Uuid) -> Self {
Self {
id,
shapes: vec![],
children: Vec::<Uuid>::new(),
kind: Kind::Rect,
selrect: Rect::default(),
transform: Matrix::identity(),