mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
🐛 Fix clipped rounded corners artifacts
This commit is contained in:
parent
0d2ec687d2
commit
0484d23b12
@ -742,22 +742,27 @@ impl RenderState {
|
|||||||
|
|
||||||
// set clipping
|
// set clipping
|
||||||
if let Some(clips) = clip_bounds.as_ref() {
|
if let Some(clips) = clip_bounds.as_ref() {
|
||||||
for (bounds, corners, transform) in clips.iter() {
|
let scale = self.get_scale();
|
||||||
|
for (mut bounds, corners, transform) in clips.iter() {
|
||||||
self.surfaces.apply_mut(surface_ids, |s| {
|
self.surfaces.apply_mut(surface_ids, |s| {
|
||||||
s.canvas().concat(transform);
|
s.canvas().concat(transform);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Outset clip by ~0.5 to include edge pixels that
|
||||||
|
// aliased clip misclassifies as outside (causing artifacts).
|
||||||
|
let outset = 0.5 / scale;
|
||||||
|
bounds.outset((outset, outset));
|
||||||
|
|
||||||
// Hard clip edge (antialias = false) to avoid alpha seam when clipping
|
// Hard clip edge (antialias = false) to avoid alpha seam when clipping
|
||||||
// semi-transparent content larger than the frame.
|
// semi-transparent content larger than the frame.
|
||||||
if let Some(corners) = corners {
|
if let Some(corners) = corners {
|
||||||
let rrect = RRect::new_rect_radii(*bounds, corners);
|
let rrect = RRect::new_rect_radii(bounds, corners);
|
||||||
self.surfaces.apply_mut(surface_ids, |s| {
|
self.surfaces.apply_mut(surface_ids, |s| {
|
||||||
s.canvas().clip_rrect(rrect, skia::ClipOp::Intersect, false);
|
s.canvas().clip_rrect(rrect, skia::ClipOp::Intersect, false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.surfaces.apply_mut(surface_ids, |s| {
|
self.surfaces.apply_mut(surface_ids, |s| {
|
||||||
s.canvas()
|
s.canvas().clip_rect(bounds, skia::ClipOp::Intersect, false);
|
||||||
.clip_rect(*bounds, skia::ClipOp::Intersect, false);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -770,7 +775,7 @@ impl RenderState {
|
|||||||
paint.set_stroke_width(4.);
|
paint.set_stroke_width(4.);
|
||||||
self.surfaces
|
self.surfaces
|
||||||
.canvas(fills_surface_id)
|
.canvas(fills_surface_id)
|
||||||
.draw_rect(*bounds, &paint);
|
.draw_rect(bounds, &paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.surfaces.apply_mut(surface_ids, |s| {
|
self.surfaces.apply_mut(surface_ids, |s| {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user