🎉 Improve tile shapes iteration

This commit is contained in:
Alejandro Alonso 2025-03-20 10:21:03 +01:00
parent 2d61644b05
commit 9ea3c54b92
2 changed files with 21 additions and 19 deletions

View file

@ -668,7 +668,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() {
@ -712,12 +711,15 @@ 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
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: Uuid::nil(),
id: *id,
visited_children: false,
clip_bounds: None,
visited_mask: false,
@ -725,6 +727,8 @@ impl RenderState {
});
}
}
}
}
} else {
should_stop = true;
}
@ -772,10 +776,12 @@ impl RenderState {
while let Some(shape_id) = nodes.pop() {
if let Some(shape) = tree.get(&shape_id) {
let mut shape = shape.clone();
if shape_id != Uuid::nil() {
if let Some(modifier) = modifiers.get(&shape_id) {
shape.apply_transform(modifier);
}
self.update_tile_for(&shape);
}
for child_id in shape.children_ids().iter() {
nodes.push(*child_id);
}

View file

@ -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<Uuid>> {
return self.grid.get(&tile);
}