From 0484d23b128fe0f808f9988ea2a01d6b441f8f4a Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 17 Mar 2026 16:18:18 +0100 Subject: [PATCH] :bug: Fix clipped rounded corners artifacts --- render-wasm/src/render.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/render-wasm/src/render.rs b/render-wasm/src/render.rs index ce5781ca63..f1611ec2b2 100644 --- a/render-wasm/src/render.rs +++ b/render-wasm/src/render.rs @@ -742,22 +742,27 @@ impl RenderState { // set clipping 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| { 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 // semi-transparent content larger than the frame. 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| { s.canvas().clip_rrect(rrect, skia::ClipOp::Intersect, false); }); } else { self.surfaces.apply_mut(surface_ids, |s| { - s.canvas() - .clip_rect(*bounds, skia::ClipOp::Intersect, false); + s.canvas().clip_rect(bounds, skia::ClipOp::Intersect, false); }); } @@ -770,7 +775,7 @@ impl RenderState { paint.set_stroke_width(4.); self.surfaces .canvas(fills_surface_id) - .draw_rect(*bounds, &paint); + .draw_rect(bounds, &paint); } self.surfaces.apply_mut(surface_ids, |s| {