mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
Merge pull request #6137 from penpot/superalex-rendering-wasm-performance
🎉 Avoid rendering too small shapes
This commit is contained in:
@@ -306,6 +306,8 @@ impl RenderState {
|
||||
s.canvas().save();
|
||||
});
|
||||
|
||||
let antialias = shape.should_use_antialias(self.get_scale());
|
||||
|
||||
// set clipping
|
||||
if let Some((bounds, corners, transform)) = clip_bounds {
|
||||
self.surfaces.apply_mut(surface_ids, |s| {
|
||||
@@ -315,11 +317,13 @@ impl RenderState {
|
||||
if let Some(corners) = corners {
|
||||
let rrect = RRect::new_rect_radii(bounds, &corners);
|
||||
self.surfaces.apply_mut(surface_ids, |s| {
|
||||
s.canvas().clip_rrect(rrect, skia::ClipOp::Intersect, true);
|
||||
s.canvas()
|
||||
.clip_rrect(rrect, skia::ClipOp::Intersect, antialias);
|
||||
});
|
||||
} else {
|
||||
self.surfaces.apply_mut(surface_ids, |s| {
|
||||
s.canvas().clip_rect(bounds, skia::ClipOp::Intersect, true);
|
||||
s.canvas()
|
||||
.clip_rect(bounds, skia::ClipOp::Intersect, antialias);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -392,15 +396,15 @@ impl RenderState {
|
||||
);
|
||||
|
||||
for fill in shape.fills().rev() {
|
||||
fills::render(self, &shape, fill);
|
||||
fills::render(self, &shape, fill, antialias);
|
||||
}
|
||||
|
||||
for stroke in shape.strokes().rev() {
|
||||
strokes::render(self, &shape, stroke);
|
||||
strokes::render(self, &shape, stroke, antialias);
|
||||
}
|
||||
|
||||
shadows::render_inner_shadows(self, &shape);
|
||||
shadows::render_drop_shadows(self, &shape);
|
||||
shadows::render_inner_shadows(self, &shape, antialias);
|
||||
shadows::render_drop_shadows(self, &shape, antialias);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -588,7 +592,7 @@ impl RenderState {
|
||||
if !self.render_in_progress {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let scale = self.get_scale();
|
||||
let mut should_stop = false;
|
||||
while !should_stop {
|
||||
if let Some(current_tile) = self.current_tile {
|
||||
@@ -665,6 +669,7 @@ impl RenderState {
|
||||
}
|
||||
if !transformed_element.extrect().intersects(self.render_area)
|
||||
|| transformed_element.hidden()
|
||||
|| transformed_element.visually_insignificant(scale)
|
||||
{
|
||||
debug::render_debug_shape(self, &transformed_element, false);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user