From ce60f607cf497c8e68a690d1201f257bf9a92f83 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 19 Oct 2021 14:28:05 +0200 Subject: [PATCH] Added failing tests for #6359. --- .../Controls/CustomRenderTests.cs | 48 ++++++++++++++++++ .../Clip_With_Transform.expected.png | Bin 0 -> 621 bytes .../GeometryClip_With_Transform.expected.png | Bin 0 -> 621 bytes 3 files changed, 48 insertions(+) create mode 100644 tests/TestFiles/Skia/Controls/CustomRender/Clip_With_Transform.expected.png create mode 100644 tests/TestFiles/Skia/Controls/CustomRender/GeometryClip_With_Transform.expected.png diff --git a/tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs b/tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs index 8002b572bd..14f5b7c6c7 100644 --- a/tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs +++ b/tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs @@ -78,6 +78,54 @@ namespace Avalonia.Direct2D1.RenderTests.Controls CompareImages(); } + [Fact] + public async Task GeometryClip_With_Transform() + { + var target = new Border + { + Background = Brushes.White, + Width = 200, + Height = 200, + Child = new CustomRenderer((control, context) => + { + using (var transform = context.PushPreTransform(Matrix.CreateTranslation(100, 100))) + using (var clip = context.PushClip(new Rect(0, 0, 100, 100))) + { + context.FillRectangle(Brushes.Blue, new Rect(0, 0, 200, 200)); + } + + context.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100)); + }), + }; + + await RenderToFile(target); + CompareImages(); + } + + [Fact] + public async Task Clip_With_Transform() + { + var target = new Border + { + Background = Brushes.White, + Width = 200, + Height = 200, + Child = new CustomRenderer((control, context) => + { + using (var transform = context.PushPreTransform(Matrix.CreateTranslation(100, 100))) + using (var clip = context.PushClip(new Rect(0, 0, 100, 100))) + { + context.FillRectangle(Brushes.Blue, new Rect(0, 0, 200, 200)); + } + + context.FillRectangle(Brushes.Red, new Rect(0, 0, 100, 100)); + }), + }; + + await RenderToFile(target); + CompareImages(); + } + [Fact] public async Task Opacity() { diff --git a/tests/TestFiles/Skia/Controls/CustomRender/Clip_With_Transform.expected.png b/tests/TestFiles/Skia/Controls/CustomRender/Clip_With_Transform.expected.png new file mode 100644 index 0000000000000000000000000000000000000000..7c0bfa6fdc1234d417c98ea416e61ce614e1a8d9 GIT binary patch literal 621 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yu@pObhHwBu4M$1`0|S$ar;B4q z#hkZSH}W1Z;9)VeKJiamJ9ky~+om}W7#}XM%|81`?y-z{r5}I8Y)+OY2L+B1M(oLc q_JytPo88_9d-)OOb!b!{V()cg?|WSD{T`Tp7(8A5T-G@yGywn#5QfqK literal 0 HcmV?d00001 diff --git a/tests/TestFiles/Skia/Controls/CustomRender/GeometryClip_With_Transform.expected.png b/tests/TestFiles/Skia/Controls/CustomRender/GeometryClip_With_Transform.expected.png new file mode 100644 index 0000000000000000000000000000000000000000..7c0bfa6fdc1234d417c98ea416e61ce614e1a8d9 GIT binary patch literal 621 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5k4M?tyST_$yu@pObhHwBu4M$1`0|S$ar;B4q z#hkZSH}W1Z;9)VeKJiamJ9ky~+om}W7#}XM%|81`?y-z{r5}I8Y)+OY2L+B1M(oLc q_JytPo88_9d-)OOb!b!{V()cg?|WSD{T`Tp7(8A5T-G@yGywn#5QfqK literal 0 HcmV?d00001