Browse Source

Added failing custom render tests.

Deferred rendering does not yet support geometry clipping or opacity masks from `Visual.Render`.
scenegraph-after-breakage
Steven Kirk 9 years ago
parent
commit
27ec199a3d
  1. 71
      tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs
  2. BIN
      tests/TestFiles/Cairo/Controls/CustomRender/GeometryClip.expected.png
  3. BIN
      tests/TestFiles/Cairo/Controls/CustomRender/OpacityMask.expected.png
  4. BIN
      tests/TestFiles/Direct2D1/Controls/CustomRender/GeometryClip.expected.png
  5. BIN
      tests/TestFiles/Direct2D1/Controls/CustomRender/OpacityMask.expected.png
  6. BIN
      tests/TestFiles/Skia/Controls/CustomRender/GeometryClip.expected.png
  7. BIN
      tests/TestFiles/Skia/Controls/CustomRender/OpacityMask.expected.png

71
tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs

@ -52,6 +52,37 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
CompareImages();
}
[Fact]
public async Task GeometryClip()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new CustomRenderer((control, context) =>
{
var clip = new EllipseGeometry(new Rect(control.Bounds.Size));
context.FillRectangle(
Brushes.Red,
new Rect(control.Bounds.Size),
4);
using (context.PushGeometryClip(clip))
{
context.FillRectangle(
Brushes.Blue,
new Rect(control.Bounds.Size),
4);
}
}),
};
await RenderToFile(target);
CompareImages();
}
[Fact]
public async Task Opacity()
{
@ -81,6 +112,46 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
CompareImages();
}
[Fact]
public async Task OpacityMask()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new CustomRenderer((control, context) =>
{
var mask = new LinearGradientBrush
{
StartPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
EndPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
GradientStops = new[]
{
new GradientStop(Color.FromUInt32(0xffffffff), 0),
new GradientStop(Color.FromUInt32(0x00ffffff), 1)
},
};
context.FillRectangle(
Brushes.Red,
new Rect(control.Bounds.Size),
4);
using (context.PushOpacityMask(mask, new Rect(control.Bounds.Size)))
{
context.FillRectangle(
Brushes.Blue,
new Rect(control.Bounds.Size).Deflate(20),
4);
}
}),
};
await RenderToFile(target);
CompareImages();
}
class CustomRenderer : Control
{
private Action<CustomRenderer, DrawingContext> _render;

BIN
tests/TestFiles/Cairo/Controls/CustomRender/GeometryClip.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
tests/TestFiles/Cairo/Controls/CustomRender/OpacityMask.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
tests/TestFiles/Direct2D1/Controls/CustomRender/GeometryClip.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
tests/TestFiles/Direct2D1/Controls/CustomRender/OpacityMask.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
tests/TestFiles/Skia/Controls/CustomRender/GeometryClip.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
tests/TestFiles/Skia/Controls/CustomRender/OpacityMask.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Loading…
Cancel
Save