Browse Source

Adjusted expected test output.

The output images were off-center.
scenegraph-after-breakage
Steven Kirk 9 years ago
parent
commit
d6342e906a
  1. 64
      src/Avalonia.Visuals/Rendering/SceneGraph/ClipNode.cs
  2. 22
      src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs
  3. 10
      tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs
  4. BIN
      tests/TestFiles/Cairo/Controls/CustomRender/Clip.expected.png
  5. BIN
      tests/TestFiles/Cairo/Controls/CustomRender/Opacity.expected.png
  6. BIN
      tests/TestFiles/Direct2D1/Controls/CustomRender/Clip.expected.png
  7. BIN
      tests/TestFiles/Direct2D1/Controls/CustomRender/Opacity.expected.png
  8. BIN
      tests/TestFiles/Skia/Controls/CustomRender/Clip.expected.png
  9. BIN
      tests/TestFiles/Skia/Controls/CustomRender/Opacity.expected.png

64
src/Avalonia.Visuals/Rendering/SceneGraph/ClipNode.cs

@ -0,0 +1,64 @@
using System;
using Avalonia.Platform;
namespace Avalonia.Rendering.SceneGraph
{
/// <summary>
/// A node in the scene graph which represents a clip push or pop.
/// </summary>
internal class ClipNode : IDrawOperation
{
/// <summary>
/// Initializes a new instance of the <see cref="ClipNode"/> class that represents an
/// clip push.
/// </summary>
/// <param name="clip">The clip to push.</param>
public ClipNode(Rect clip)
{
Clip = clip;
}
/// <summary>
/// Initializes a new instance of the <see cref="ClipNode"/> class that represents an
/// opacity pop.
/// </summary>
public ClipNode()
{
}
/// <inheritdoc/>
public Rect Bounds => Rect.Empty;
/// <summary>
/// Gets the opacity to be pushed or null if the operation represents a pop.
/// </summary>
public Rect? Clip { get; }
/// <inheritdoc/>
public bool HitTest(Point p) => false;
/// <summary>
/// Determines if this draw operation equals another.
/// </summary>
/// <param name="clip">The clip of the other draw operation.</param>
/// <returns>True if the draw operations are the same, otherwise false.</returns>
/// <remarks>
/// The properties of the other draw operation are passed in as arguments to prevent
/// allocation of a not-yet-constructed draw operation object.
/// </remarks>
public bool Equals(Rect? clip) => Clip == clip;
/// <inheritdoc/>
public void Render(IDrawingContextImpl context)
{
if (Clip.HasValue)
{
context.PushClip(Clip.Value);
}
else
{
context.PopClip();
}
}
}
}

22
src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs

@ -196,7 +196,16 @@ namespace Avalonia.Rendering.SceneGraph
/// <inheritdoc/>
public void PopClip()
{
// TODO: Implement
var next = NextDrawAs<ClipNode>();
if (next == null || !next.Equals(null))
{
Add(new ClipNode());
}
else
{
++_drawOperationindex;
}
}
/// <inheritdoc/>
@ -229,7 +238,16 @@ namespace Avalonia.Rendering.SceneGraph
/// <inheritdoc/>
public void PushClip(Rect clip)
{
// TODO: Implement
var next = NextDrawAs<ClipNode>();
if (next == null || !next.Equals(clip))
{
Add(new ClipNode(clip));
}
else
{
++_drawOperationindex;
}
}
/// <inheritdoc/>

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

@ -35,14 +35,14 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
{
context.FillRectangle(
Brushes.Red,
control.Bounds,
new Rect(control.Bounds.Size),
4);
using (context.PushClip(control.Bounds.Deflate(20)))
using (context.PushClip(new Rect(control.Bounds.Size).Deflate(20)))
{
context.FillRectangle(
Brushes.Blue,
control.Bounds,
new Rect(control.Bounds.Size),
4);
}
}),
@ -64,14 +64,14 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
{
context.FillRectangle(
Brushes.Red,
control.Bounds,
new Rect(control.Bounds.Size),
4);
using (context.PushOpacity(0.5))
{
context.FillRectangle(
Brushes.Blue,
control.Bounds.Deflate(20),
new Rect(control.Bounds.Size).Deflate(20),
4);
}
}),

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 807 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 612 B

After

Width:  |  Height:  |  Size: 988 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 807 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 B

After

Width:  |  Height:  |  Size: 988 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 807 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 B

After

Width:  |  Height:  |  Size: 988 B

Loading…
Cancel
Save