diff --git a/src/Avalonia.Base/Media/DrawingContext.cs b/src/Avalonia.Base/Media/DrawingContext.cs index f2106f2f86..18d6968168 100644 --- a/src/Avalonia.Base/Media/DrawingContext.cs +++ b/src/Avalonia.Base/Media/DrawingContext.cs @@ -132,7 +132,7 @@ namespace Avalonia.Media double radiusX = 0, double radiusY = 0, BoxShadows boxShadows = default) { - if (brush == null && !PenIsVisible(pen)) + if (brush == null && !PenIsVisible(pen) && boxShadows.Count == 0) return; if (!MathUtilities.IsZero(radiusX)) { @@ -160,7 +160,7 @@ namespace Avalonia.Media /// public void DrawRectangle(IBrush? brush, IPen? pen, RoundedRect rrect, BoxShadows boxShadows = default) { - if (brush == null && !PenIsVisible(pen)) + if (brush == null && !PenIsVisible(pen) && boxShadows.Count == 0) return; DrawRectangleCore(brush, pen, rrect, boxShadows); } diff --git a/tests/Avalonia.RenderTests/Media/BoxShadowTests.cs b/tests/Avalonia.RenderTests/Media/BoxShadowTests.cs new file mode 100644 index 0000000000..a28fd49777 --- /dev/null +++ b/tests/Avalonia.RenderTests/Media/BoxShadowTests.cs @@ -0,0 +1,51 @@ +using System.Threading.Tasks; +using Avalonia.Controls; +using Avalonia.Media; +using Xunit; +#pragma warning disable CS0649 + +#if AVALONIA_SKIA +namespace Avalonia.Skia.RenderTests; + +public class BoxShadowTests : TestBase +{ + + public BoxShadowTests() : base(@"Media\BoxShadow") + { + } + + [Fact] + public async Task BoxShadowShouldBeRenderedEvenWithNullBrushAndPen() + { + var target = new Border + { + Width = 200, + Height = 200, + Background = null, + Child = new Border() + { + Background = null, + Margin = new Thickness(40), + BoxShadow = new BoxShadows(new BoxShadow + { + Blur = 0, + Color = Colors.Blue, + OffsetX = 10, + OffsetY = 15, + Spread = 0 + }), + Child = new Border + { + Background = Brushes.Red + } + } + }; + + await RenderToFile(target); + CompareImages(); + } + + +} + +#endif \ No newline at end of file diff --git a/tests/TestFiles/Skia/Media/BoxShadow/BoxShadowShouldBeRenderedEvenWithNullBrushAndPen.expected.png b/tests/TestFiles/Skia/Media/BoxShadow/BoxShadowShouldBeRenderedEvenWithNullBrushAndPen.expected.png new file mode 100644 index 0000000000..6cb4974d51 Binary files /dev/null and b/tests/TestFiles/Skia/Media/BoxShadow/BoxShadowShouldBeRenderedEvenWithNullBrushAndPen.expected.png differ