diff --git a/render-wasm/src/render.rs b/render-wasm/src/render.rs index bd0d074e41..ce3fd18902 100644 --- a/render-wasm/src/render.rs +++ b/render-wasm/src/render.rs @@ -688,7 +688,6 @@ impl RenderState { }); if element.is_recursive() { - // Fix this let children_clip_bounds = node_render_state .get_children_clip_bounds(element, modifiers.get(&element.id)); for child_id in element.children_ids().iter().rev() { @@ -732,17 +731,22 @@ impl RenderState { if let Some(next_tile) = self.pending_tiles.pop() { self.update_render_context(next_tile); if !self.surfaces.has_cached_tile_surface(next_tile) { - // If the tile is empty or it doesn't exists we don't do anything with it - if self.tiles.has_shapes_at(next_tile) { - // TODO: This should be more efficient, we should be able to know exactly what shapes tree - // are included for this tile - self.pending_nodes.push(NodeRenderState { - id: Uuid::nil(), - visited_children: false, - clip_bounds: None, - visited_mask: false, - mask: false, - }); + if let Some(ids) = self.tiles.get_shapes_at(next_tile) { + for id in ids { + let element = tree.get_mut(&id).ok_or( + "Error: Element with root_id {id} not found in the tree." + .to_string(), + )?; + if element.parent_id == Some(Uuid::nil()) { + self.pending_nodes.push(NodeRenderState { + id: *id, + visited_children: false, + clip_bounds: None, + visited_mask: false, + mask: false, + }); + } + } } } } else { @@ -792,10 +796,12 @@ impl RenderState { while let Some(shape_id) = nodes.pop() { if let Some(shape) = tree.get(&shape_id) { let mut shape = shape.clone(); - if let Some(modifier) = modifiers.get(&shape_id) { - shape.apply_transform(modifier); + if shape_id != Uuid::nil() { + if let Some(modifier) = modifiers.get(&shape_id) { + shape.apply_transform(modifier); + } + self.update_tile_for(&shape); } - self.update_tile_for(&shape); for child_id in shape.children_ids().iter() { nodes.push(*child_id); } diff --git a/render-wasm/src/render/tiles.rs b/render-wasm/src/render/tiles.rs index b0befba35e..9931c423a0 100644 --- a/render-wasm/src/render/tiles.rs +++ b/render-wasm/src/render/tiles.rs @@ -60,10 +60,6 @@ impl TileHashMap { } } - pub fn has_shapes_at(&mut self, tile: Tile) -> bool { - return self.grid.contains_key(&tile); - } - pub fn get_shapes_at(&mut self, tile: Tile) -> Option<&IndexSet> { return self.grid.get(&tile); }