mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 08:31:38 +02:00
🎉 Avoid full tiles rebuild on set modifiers
This commit is contained in:
parent
a109f11926
commit
6953a57333
3 changed files with 20 additions and 4 deletions
|
@ -613,10 +613,7 @@ pub extern "C" fn set_modifiers() {
|
|||
for entry in entries {
|
||||
state.modifiers.insert(entry.id, entry.transform);
|
||||
}
|
||||
// TODO: Do a more specific rebuild of tiles. For
|
||||
// example: using only the selected shapes to rebuild
|
||||
// the tiles affected by the selected shapes.
|
||||
state.rebuild_tiles();
|
||||
state.rebuild_modifier_tiles();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -844,6 +844,20 @@ impl RenderState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn rebuild_modifier_tiles(
|
||||
&mut self,
|
||||
tree: &mut HashMap<Uuid, Shape>,
|
||||
modifiers: &HashMap<Uuid, Matrix>,
|
||||
) {
|
||||
for (uuid, matrix) in modifiers {
|
||||
if let Some(shape) = tree.get(uuid) {
|
||||
let mut shape = shape.clone();
|
||||
shape.apply_transform(matrix);
|
||||
self.update_tile_for(&shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_scale(&self) -> f32 {
|
||||
self.viewbox.zoom() * self.options.dpr()
|
||||
}
|
||||
|
|
|
@ -111,4 +111,9 @@ impl<'a> State<'a> {
|
|||
self.render_state
|
||||
.rebuild_tiles(&mut self.shapes, &self.modifiers);
|
||||
}
|
||||
|
||||
pub fn rebuild_modifier_tiles(&mut self) {
|
||||
self.render_state
|
||||
.rebuild_modifier_tiles(&mut self.shapes, &self.modifiers);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue