1
0
Эх сурвалжийг харах

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.
Steven Kirk 8 жил өмнө
parent
commit
b3fca2360d

+ 17 - 11
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

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