Browse Source

Trying to make tiling work right...

pull/111/head
Steven Kirk 11 years ago
parent
commit
4787e24880
  1. 2
      src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs
  2. 6
      tests/Perspex.RenderTests/Media/VisualBrushTests.cs
  3. BIN
      tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile.expected.png
  4. BIN
      tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_DestinationRect.expected.png

2
src/Windows/Perspex.Direct2D1/Media/VisualBrushImpl.cs

@ -29,7 +29,7 @@ namespace Perspex.Direct2D1.Media
var sourceRect = brush.SourceRect.ToPixels(layoutable.Bounds.Size);
var destinationRect = brush.DestinationRect.ToPixels(targetSize);
var bitmapSize = brush.TileMode == TileMode.None ? targetSize : sourceRect.Size;
var bitmapSize = brush.TileMode == TileMode.None ? targetSize : destinationRect.Size;
var scale = brush.Stretch.CalculateScaling(destinationRect.Size, sourceRect.Size);
var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
var options = CompatibleRenderTargetOptions.None;

6
tests/Perspex.RenderTests/Media/VisualBrushTests.cs

@ -411,6 +411,7 @@ namespace Perspex.Direct2D1.RenderTests.Media
{
Stretch = Stretch.None,
TileMode = TileMode.Tile,
DestinationRect = new RelativeRect(0.25, 0.25, 0.5, 0.5, OriginUnit.Percent),
Visual = new Border
{
Width = 92,
@ -436,7 +437,7 @@ namespace Perspex.Direct2D1.RenderTests.Media
}
[Fact]
public void VisualBrush_Tile_DestinationRect()
public void VisualBrush_Tile_Alignment_BottomRight()
{
Decorator target = new Decorator
{
@ -449,7 +450,8 @@ namespace Perspex.Direct2D1.RenderTests.Media
{
Stretch = Stretch.None,
TileMode = TileMode.Tile,
DestinationRect = new RelativeRect(0.25, 0.25, 0.5, 0.5, OriginUnit.Percent),
AlignmentX = AlignmentX.Right,
AlignmentY = AlignmentY.Bottom,
Visual = new Border
{
Width = 92,

BIN
tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile.expected.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
tests/TestFiles/Direct2D1/Media/VisualBrush/VisualBrush_Tile_DestinationRect.expected.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save