mirror of
https://github.com/penpot/penpot.git
synced 2025-05-26 02:36:10 +02:00
Merge pull request #6121 from penpot/superalex-tada-improve-tile-shapes-iteration-2
🎉 Improve tile shapes iteration
This commit is contained in:
commit
4c12af957c
2 changed files with 21 additions and 19 deletions
|
@ -688,7 +688,6 @@ impl RenderState {
|
||||||
});
|
});
|
||||||
|
|
||||||
if element.is_recursive() {
|
if element.is_recursive() {
|
||||||
// Fix this
|
|
||||||
let children_clip_bounds = node_render_state
|
let children_clip_bounds = node_render_state
|
||||||
.get_children_clip_bounds(element, modifiers.get(&element.id));
|
.get_children_clip_bounds(element, modifiers.get(&element.id));
|
||||||
for child_id in element.children_ids().iter().rev() {
|
for child_id in element.children_ids().iter().rev() {
|
||||||
|
@ -732,17 +731,22 @@ impl RenderState {
|
||||||
if let Some(next_tile) = self.pending_tiles.pop() {
|
if let Some(next_tile) = self.pending_tiles.pop() {
|
||||||
self.update_render_context(next_tile);
|
self.update_render_context(next_tile);
|
||||||
if !self.surfaces.has_cached_tile_surface(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 let Some(ids) = self.tiles.get_shapes_at(next_tile) {
|
||||||
if self.tiles.has_shapes_at(next_tile) {
|
for id in ids {
|
||||||
// TODO: This should be more efficient, we should be able to know exactly what shapes tree
|
let element = tree.get_mut(&id).ok_or(
|
||||||
// are included for this tile
|
"Error: Element with root_id {id} not found in the tree."
|
||||||
self.pending_nodes.push(NodeRenderState {
|
.to_string(),
|
||||||
id: Uuid::nil(),
|
)?;
|
||||||
visited_children: false,
|
if element.parent_id == Some(Uuid::nil()) {
|
||||||
clip_bounds: None,
|
self.pending_nodes.push(NodeRenderState {
|
||||||
visited_mask: false,
|
id: *id,
|
||||||
mask: false,
|
visited_children: false,
|
||||||
});
|
clip_bounds: None,
|
||||||
|
visited_mask: false,
|
||||||
|
mask: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -792,10 +796,12 @@ impl RenderState {
|
||||||
while let Some(shape_id) = nodes.pop() {
|
while let Some(shape_id) = nodes.pop() {
|
||||||
if let Some(shape) = tree.get(&shape_id) {
|
if let Some(shape) = tree.get(&shape_id) {
|
||||||
let mut shape = shape.clone();
|
let mut shape = shape.clone();
|
||||||
if let Some(modifier) = modifiers.get(&shape_id) {
|
if shape_id != Uuid::nil() {
|
||||||
shape.apply_transform(modifier);
|
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() {
|
for child_id in shape.children_ids().iter() {
|
||||||
nodes.push(*child_id);
|
nodes.push(*child_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>> {
|
pub fn get_shapes_at(&mut self, tile: Tile) -> Option<&IndexSet<Uuid>> {
|
||||||
return self.grid.get(&tile);
|
return self.grid.get(&tile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue