Browse Source

Fix Border clip regression (#20648)

pull/20654/head
Nikita Tsukanov 1 month ago
committed by GitHub
parent
commit
30b451da52
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionVisual/ServerCompositionVisual.Render.cs
  2. 33
      tests/Avalonia.RenderTests/Controls/BorderTests.cs
  3. BIN
      tests/TestFiles/Skia/Controls/Border/Border_Clips_To_Round_Bounds_NonUniform.expected.png
  4. BIN
      tests/TestFiles/Skia/Controls/Border/Border_Clips_To_Round_Bounds_Uniform.expected.png

2
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionVisual/ServerCompositionVisual.Render.cs

@ -110,7 +110,7 @@ partial class ServerCompositionVisual
_walkContext.PushClip(effectiveClip);
if (visual.ClipToBounds)
_canvas.PushClip(new Rect(0, 0, visual.Size.X, visual.Size.Y));
visual.PushClipToBounds(_canvas);
if (visual.Clip != null)
_canvas.PushGeometryClip(visual.Clip);

33
tests/Avalonia.RenderTests/Controls/BorderTests.cs

@ -424,5 +424,38 @@ namespace Avalonia.Skia.RenderTests
await RenderToFile(target);
CompareImages();
}
[Theory,
InlineData(true),
InlineData(false)]
public async Task Border_Clips_To_Round_Bounds(bool uniform)
{
var cornerRadius = uniform
? new CornerRadius(20)
: new CornerRadius(20, 10, 30, 5);
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new Border
{
CornerRadius = cornerRadius,
Background = Brushes.LightBlue,
ClipToBounds = true,
Child = new Border
{
Width = 300,
Height = 300,
Background = Brushes.Red,
}
}
};
var testSuffix = nameof(Border_Clips_To_Round_Bounds) + "_" + (uniform ? "Uniform" : "NonUniform");
await RenderToFile(target, testSuffix);
CompareImages(testSuffix);
}
}
}

BIN
tests/TestFiles/Skia/Controls/Border/Border_Clips_To_Round_Bounds_NonUniform.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
tests/TestFiles/Skia/Controls/Border/Border_Clips_To_Round_Bounds_Uniform.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Loading…
Cancel
Save