0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-23 15:26:29 -05:00

Merge pull request #5823 from penpot/superalex-render-wasm-cloning

🎉 Remove extra clonings from render wasm
This commit is contained in:
Aitor Moreno 2025-02-11 15:55:58 +01:00 committed by GitHub
commit 4594c7bf0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -392,7 +392,7 @@ impl RenderState {
));
self.final_surface
.canvas()
.draw_image(image.clone(), (0, 0), Some(&paint));
.draw_image(image, (0, 0), Some(&paint));
self.final_surface.canvas().restore();
self.drawing_surface.canvas().restore();
@ -408,7 +408,7 @@ impl RenderState {
pub fn render_shape_tree(
&mut self,
tree: &HashMap<Uuid, Shape>,
tree: &mut HashMap<Uuid, Shape>,
modifiers: &HashMap<Uuid, Matrix>,
timestamp: i32,
) -> Result<(), String> {
@ -418,17 +418,17 @@ impl RenderState {
let mut i = 0;
while let Some((node_id, visited_children, clip_bounds)) = self.pending_nodes.pop() {
let element = tree.get(&node_id).ok_or(
let element = tree.get_mut(&node_id).ok_or(
"Error: Element with root_id {node_id} not found in the tree.".to_string(),
)?;
if !visited_children {
if !node_id.is_nil() {
if !element.bounds().intersects(self.viewbox.area) || element.hidden() {
debug::render_debug_element(self, element, false);
debug::render_debug_element(self, &element, false);
continue;
} else {
debug::render_debug_element(self, element, true);
debug::render_debug_element(self, &element, true);
}
}
@ -447,11 +447,7 @@ impl RenderState {
self.drawing_surface.canvas().save();
if !node_id.is_nil() {
self.render_shape(
&mut element.clone(),
modifiers.get(&element.id),
clip_bounds,
);
self.render_shape(element, modifiers.get(&element.id), clip_bounds);
} else {
self.apply_drawing_to_render_canvas();
}