diff --git a/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs b/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs index 69bcf97737..8638162ff5 100644 --- a/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs +++ b/src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs @@ -56,8 +56,8 @@ namespace Perspex.Direct2D1.Media renderer.Render(visual, null, transform, drawRect); var result = new BitmapBrush(brt, brt.Bitmap); - result.ExtendModeX = ExtendMode.Wrap; - result.ExtendModeY = ExtendMode.Wrap; + result.ExtendModeX = (brush.TileMode & TileMode.FlipX) != 0 ? ExtendMode.Mirror : ExtendMode.Wrap; + result.ExtendModeY = (brush.TileMode & TileMode.FlipY) != 0 ? ExtendMode.Mirror : ExtendMode.Wrap; if (brush.TileMode != TileMode.None) { diff --git a/tests/Perspex.RenderTests/Media/VisualBrushTests.cs b/tests/Perspex.RenderTests/Media/VisualBrushTests.cs index 6a9bc51c3c..7b32a223ce 100644 --- a/tests/Perspex.RenderTests/Media/VisualBrushTests.cs +++ b/tests/Perspex.RenderTests/Media/VisualBrushTests.cs @@ -475,5 +475,122 @@ namespace Perspex.Direct2D1.RenderTests.Media this.RenderToFile(target); this.CompareImages(); } + + [Fact] + public void VisualBrush_FlipX() + { + Decorator target = new Decorator + { + Padding = new Thickness(8), + Width = 200, + Height = 200, + Child = new Rectangle + { + Fill = new VisualBrush + { + Stretch = Stretch.None, + TileMode = TileMode.FlipX, + DestinationRect = new RelativeRect(0, 0, 0.5, 0.5, OriginUnit.Percent), + Visual = new Border + { + Width = 92, + Height = 92, + Background = Brushes.Red, + BorderBrush = Brushes.Black, + BorderThickness = 2, + Child = new TextBlock + { + Text = "Perspex", + FontSize = 12, + FontFamily = "Arial", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + } + } + } + } + }; + + this.RenderToFile(target); + this.CompareImages(); + } + + [Fact] + public void VisualBrush_FlipY() + { + Decorator target = new Decorator + { + Padding = new Thickness(8), + Width = 200, + Height = 200, + Child = new Rectangle + { + Fill = new VisualBrush + { + Stretch = Stretch.None, + TileMode = TileMode.FlipY, + DestinationRect = new RelativeRect(0, 0, 0.5, 0.5, OriginUnit.Percent), + Visual = new Border + { + Width = 92, + Height = 92, + Background = Brushes.Red, + BorderBrush = Brushes.Black, + BorderThickness = 2, + Child = new TextBlock + { + Text = "Perspex", + FontSize = 12, + FontFamily = "Arial", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + } + } + } + } + }; + + this.RenderToFile(target); + this.CompareImages(); + } + + [Fact] + public void VisualBrush_FlipXY() + { + Decorator target = new Decorator + { + Padding = new Thickness(8), + Width = 200, + Height = 200, + Child = new Rectangle + { + Fill = new VisualBrush + { + Stretch = Stretch.None, + TileMode = TileMode.FlipXY, + DestinationRect = new RelativeRect(0, 0, 0.5, 0.5, OriginUnit.Percent), + Visual = new Border + { + Width = 92, + Height = 92, + Background = Brushes.Red, + BorderBrush = Brushes.Black, + BorderThickness = 2, + Child = new TextBlock + { + Text = "Perspex", + FontSize = 12, + FontFamily = "Arial", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + } + } + } + } + }; + + this.RenderToFile(target); + this.CompareImages(); + } } } diff --git a/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipX.expected.png b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipX.expected.png new file mode 100644 index 0000000000..da7003b419 Binary files /dev/null and b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipX.expected.png differ diff --git a/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipXY.expected.png b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipXY.expected.png new file mode 100644 index 0000000000..4bfcdb2dd3 Binary files /dev/null and b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipXY.expected.png differ diff --git a/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipY.expected.png b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipY.expected.png new file mode 100644 index 0000000000..74a01bb78c Binary files /dev/null and b/tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_FlipY.expected.png differ