Browse Source

Added failing render test.

Deferred rendering does not yet support clipping in `Visual.Render`.
scenegraph-after-breakage
Steven Kirk 9 years ago
parent
commit
7e1efb33e2
  1. 60
      tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs
  2. BIN
      tests/TestFiles/Cairo/Controls/CustomRender/Clip.expected.png
  3. BIN
      tests/TestFiles/Direct2D1/Controls/CustomRender/Clip.expected.png
  4. BIN
      tests/TestFiles/Skia/Controls/CustomRender/Clip.expected.png

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

@ -1,6 +1,7 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Layout;
@ -23,37 +24,68 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
}
[Fact]
public async Task Opacity()
public async Task Clip()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new OpacityRenderer(),
Child = new CustomRenderer((control, context) =>
{
context.FillRectangle(
Brushes.Red,
control.Bounds,
4);
using (context.PushClip(control.Bounds.Deflate(20)))
{
context.FillRectangle(
Brushes.Blue,
control.Bounds,
4);
}
}),
};
await RenderToFile(target);
CompareImages();
}
class OpacityRenderer : Control
[Fact]
public async Task Opacity()
{
public override void Render(DrawingContext context)
Decorator target = new Decorator
{
context.FillRectangle(
Brushes.Red,
Bounds,
4);
using (context.PushOpacity(0.5))
Padding = new Thickness(8),
Width = 200,
Height = 200,
Child = new CustomRenderer((control, context) =>
{
context.FillRectangle(
Brushes.Blue,
Bounds.Deflate(20),
Brushes.Red,
control.Bounds,
4);
}
}
using (context.PushOpacity(0.5))
{
context.FillRectangle(
Brushes.Blue,
control.Bounds.Deflate(20),
4);
}
}),
};
await RenderToFile(target);
CompareImages();
}
class CustomRenderer : Control
{
private Action<CustomRenderer, DrawingContext> _render;
public CustomRenderer(Action<CustomRenderer, DrawingContext> render) => _render = render;
public override void Render(DrawingContext context) => _render(this, context);
}
}
}

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Loading…
Cancel
Save