From fc96e2949fb6e65e7e74f7142fa26810b637f3d6 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 8 Apr 2023 19:25:49 +0600 Subject: [PATCH] Fixed #10539 --- src/Avalonia.Base/Media/DrawingContext.cs | 4 +- .../Media/BoxShadowTests.cs | 51 ++++++++++++++++++ ...nderedEvenWithNullBrushAndPen.expected.png | Bin 0 -> 533 bytes 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/Avalonia.RenderTests/Media/BoxShadowTests.cs create mode 100644 tests/TestFiles/Skia/Media/BoxShadow/BoxShadowShouldBeRenderedEvenWithNullBrushAndPen.expected.png 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 0000000000000000000000000000000000000000..6cb4974d51e26f089a55916417a31d8fa41508ed GIT binary patch literal 533 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yu@pObhHwBu4M$1`0|Vn3PZ!6K ziaBp@ALMmX6mfMl_;%l@tl-L#`O6EJHSK=T!n=kQs0$DHFwfTZ!OYFqX5Kqc`fd9B zgSWph{77SJR1o06Lln%HJFwqczb^fT^7%)16$DtA97i^h=+FOSPVqAFf~B@aVMGK7 cmI(Q?j-7KAJHLwI)*B#MPgg&ebxsLQ0B@vSrT_o{ literal 0 HcmV?d00001