From d1e79bc19bb080a84eca20011077a4e6339e4fcf Mon Sep 17 00:00:00 2001 From: aalhitennf Date: Thu, 7 Nov 2024 23:37:23 +0200 Subject: [PATCH] Fix vello renderer box shadow (#675) --- vello/src/lib.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/vello/src/lib.rs b/vello/src/lib.rs index df5374c9..6c0cd7d1 100644 --- a/vello/src/lib.rs +++ b/vello/src/lib.rs @@ -202,18 +202,29 @@ impl Renderer for VelloRenderer { fn fill<'b>(&mut self, path: &impl Shape, brush: impl Into>, blur_radius: f64) { let brush: BrushRef<'b> = brush.into(); - if blur_radius > 0. { + if let Some(rounded) = path.as_rounded_rect() { + let BrushRef::Solid(color) = brush else { + return; + }; + let rect_radius = rounded.radii().top_left; + let rect = rounded.rect(); + self.scene.draw_blurred_rounded_rect( + self.transform.then_scale(self.window_scale), + rect, + color, + rect_radius, + blur_radius, + ); + } else if let Some(rect) = path.as_rect() { let BrushRef::Solid(color) = brush else { return; }; - let rect = path.as_rounded_rect().unwrap_or_default().rect(); - self.scene.draw_blurred_rounded_rect( self.transform.then_scale(self.window_scale), rect, color, + 0., blur_radius, - 3., ); } else { self.scene.fill(