Browse Source

Fix failing skia render test

Make sure we restore the transform in `EndRender` and use the same order of pushing/popping operations that `ImmediateRenderer` uses.
pull/1306/head
Steven Kirk 9 years ago
parent
commit
b3fca2360d
  1. 28
      src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

28
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

@ -22,6 +22,7 @@ namespace Avalonia.Rendering.SceneGraph
private List<IVisualNode> _children; private List<IVisualNode> _children;
private List<IDrawOperation> _drawOperations; private List<IDrawOperation> _drawOperations;
private bool _drawOperationsCloned; private bool _drawOperationsCloned;
private Matrix transformRestore;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VisualNode"/> class. /// Initializes a new instance of the <see cref="VisualNode"/> class.
@ -220,41 +221,43 @@ namespace Avalonia.Rendering.SceneGraph
/// <inheritdoc/> /// <inheritdoc/>
public void BeginRender(IDrawingContextImpl context, bool skipOpacity) public void BeginRender(IDrawingContextImpl context, bool skipOpacity)
{ {
transformRestore = context.Transform;
if (ClipToBounds) if (ClipToBounds)
{ {
context.Transform = Matrix.Identity; context.Transform = Matrix.Identity;
context.PushClip(ClipBounds); context.PushClip(ClipBounds);
} }
context.Transform = Transform;
if (Opacity != 1 && !skipOpacity) if (Opacity != 1 && !skipOpacity)
{ {
context.PushOpacity(Opacity); context.PushOpacity(Opacity);
} }
if (OpacityMask != null) if (GeometryClip != null)
{ {
context.PushOpacityMask(OpacityMask, ClipBounds); context.PushGeometryClip(GeometryClip);
} }
context.Transform = Transform; if (OpacityMask != null)
if (GeometryClip != null)
{ {
context.PushGeometryClip(GeometryClip); context.PushOpacityMask(OpacityMask, ClipBounds);
} }
} }
/// <inheritdoc/> /// <inheritdoc/>
public void EndRender(IDrawingContextImpl context, bool skipOpacity) public void EndRender(IDrawingContextImpl context, bool skipOpacity)
{ {
if (GeometryClip != null) if (OpacityMask != null)
{ {
context.PopGeometryClip(); context.PopOpacityMask();
} }
if (OpacityMask != null) if (GeometryClip != null)
{ {
context.PopOpacityMask(); context.PopGeometryClip();
} }
if (Opacity != 1 && !skipOpacity) if (Opacity != 1 && !skipOpacity)
@ -264,8 +267,11 @@ namespace Avalonia.Rendering.SceneGraph
if (ClipToBounds) if (ClipToBounds)
{ {
context.Transform = Matrix.Identity;
context.PopClip(); context.PopClip();
} }
context.Transform = transformRestore;
} }
private Rect CalculateBounds() private Rect CalculateBounds()

Loading…
Cancel
Save