Browse Source

Merge branch 'master' into fixes/osx-shadow-invalidation

Dan Walmsley 4 years ago
parent
commit
8d429b3fd1

+ 2 - 2
readme.md

@@ -14,7 +14,7 @@ To see the status of some of our features, please see our [Roadmap](https://gith
 
 ## 🚀 Getting Started
 
-The Avalonia [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=AvaloniaTeam.AvaloniaforVisualStudio) contains project and control templates that will help you get started, or you can use the .NET Core CLI. For a starter guide see our [documentation](https://avaloniaui.net/docs/quickstart/create-new-project).
+The Avalonia [Visual Studio Extension](https://marketplace.visualstudio.com/items?itemName=AvaloniaTeam.AvaloniaforVisualStudio) contains project and control templates that will help you get started, or you can use the .NET Core CLI. For a starter guide see our [documentation](https://docs.avaloniaui.net/docs/getting-started).
 
 Avalonia is delivered via <b>NuGet</b> package manager. You can find the packages here: https://www.nuget.org/packages/Avalonia/
 
@@ -52,7 +52,7 @@ We also have a [nightly build](https://github.com/AvaloniaUI/Avalonia/wiki/Using
 
 ## Documentation
 
-Documentation can be found on our website at https://avaloniaui.net/docs/. We also have a [tutorial](https://avaloniaui.net/docs/tutorial/) over there for newcomers.
+Documentation can be found at https://docs.avaloniaui.net. We also have a [tutorial](https://docs.avaloniaui.net/docs/getting-started/programming-with-avalonia) over there for newcomers.
 
 ## Building and Using
 

+ 5 - 2
src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs

@@ -408,9 +408,12 @@ namespace Avalonia.Rendering.SceneGraph
 
                 var dirty = Owner.Layers.GetOrAdd(Owner._node.LayerRoot).Dirty;
 
-                foreach (var operation in Owner._node.DrawOperations)
+                var drawOperations = Owner._node.DrawOperations;
+                var drawOperationsCount = drawOperations.Count;
+
+                for (var i = 0; i < drawOperationsCount; i++)
                 {
-                    dirty.Add(operation.Item.Bounds);
+                    dirty.Add(drawOperations[i].Item.Bounds);
                 }
 
                 Owner._node = Node;

+ 1 - 1
src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs

@@ -84,7 +84,7 @@ namespace Avalonia.Rendering.SceneGraph
             return transform == Transform &&
                    Equals(brush, Brush) &&
                    Equals(Pen, pen) &&
-                   Media.BoxShadows.Equals(BoxShadows, boxShadows) &&
+                   BoxShadows.Equals(boxShadows) &&
                    rect.Equals(Rect);
         }
 

+ 24 - 6
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

@@ -1,5 +1,5 @@
 using System;
-using System.Linq;
+using System.Collections.Generic;
 using Avalonia.Media;
 using Avalonia.Platform;
 using Avalonia.Threading;
@@ -247,11 +247,26 @@ namespace Avalonia.Rendering.SceneGraph
 
                     if (forceRecurse)
                     {
-                        foreach (var child in visual.VisualChildren.OrderBy(x => x, ZIndexComparer.Instance))
+                        var visualChildren = (IList<IVisual>) visual.VisualChildren;
+
+                        if (visualChildren.Count == 1)
                         {
-                            var childNode = GetOrCreateChildNode(scene, child, node);
+                            var childNode = GetOrCreateChildNode(scene, visualChildren[0], node);
                             Update(context, scene, (VisualNode)childNode, clip, forceRecurse);
                         }
+                        else if (visualChildren.Count > 1)
+                        {
+                            var sortedChildren = new IVisual[visualChildren.Count];
+                            visualChildren.CopyTo(sortedChildren, 0);
+
+                            Array.Sort(sortedChildren, ZIndexComparer.ComparisonInstance);
+
+                            foreach (var child in sortedChildren)
+                            {
+                                var childNode = GetOrCreateChildNode(scene, child, node);
+                                Update(context, scene, (VisualNode)childNode, clip, forceRecurse);
+                            }
+                        }
 
                         node.SubTreeUpdated = true;
                         contextImpl.TrimChildren();
@@ -308,13 +323,17 @@ namespace Avalonia.Rendering.SceneGraph
 
         private static void Deindex(Scene scene, VisualNode node)
         {
-            foreach (VisualNode child in node.Children)
+            var nodeChildren = node.Children;
+            var nodeChildrenCount = nodeChildren.Count;
+
+            for (var i = 0; i < nodeChildrenCount; i++)
             {
-                if (child is VisualNode visual)
+                if (nodeChildren[i] is VisualNode visual)
                 {
                     Deindex(scene, visual);
                 }
             }
+
             scene.Remove(node);
 
             node.SubTreeUpdated = true;
@@ -323,7 +342,6 @@ namespace Avalonia.Rendering.SceneGraph
 
             node.Visual.TransformedBounds = null;
 
-
             if (node.LayerRoot == node.Visual && node.Visual != scene.Root.Visual)
             {
                 scene.Layers.Remove(node.LayerRoot);

+ 5 - 2
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

@@ -365,9 +365,12 @@ namespace Avalonia.Rendering.SceneGraph
         {
             var result = new Rect();
 
-            foreach (var operation in DrawOperations)
+            if (_drawOperations != null)
             {
-                result = result.Union(operation.Item.Bounds);
+                foreach (var operation in _drawOperations)
+                {
+                    result = result.Union(operation.Item.Bounds);
+                }
             }
 
             _bounds = result;

+ 3 - 1
src/Avalonia.Visuals/Rendering/ZIndexComparer.cs

@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using Avalonia.VisualTree;
 
 namespace Avalonia.Rendering
@@ -6,6 +7,7 @@ namespace Avalonia.Rendering
     public class ZIndexComparer : IComparer<IVisual>
     {
         public static readonly ZIndexComparer Instance = new ZIndexComparer();
+        public static readonly Comparison<IVisual> ComparisonInstance = Instance.Compare;
 
         public int Compare(IVisual x, IVisual y) => (x?.ZIndex ?? 0).CompareTo(y?.ZIndex ?? 0);
     }