Browse Source

Fixed #10539

pull/10954/head
Nikita Tsukanov 3 years ago
parent
commit
fc96e2949f
  1. 4
      src/Avalonia.Base/Media/DrawingContext.cs
  2. 51
      tests/Avalonia.RenderTests/Media/BoxShadowTests.cs
  3. BIN
      tests/TestFiles/Skia/Media/BoxShadow/BoxShadowShouldBeRenderedEvenWithNullBrushAndPen.expected.png

4
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
/// </remarks>
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);
}

51
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

BIN
tests/TestFiles/Skia/Media/BoxShadow/BoxShadowShouldBeRenderedEvenWithNullBrushAndPen.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Loading…
Cancel
Save