Browse Source

Added failing test for #1420.

Steven Kirk 7 years ago
parent
commit
87d7f65eb8

+ 5 - 0
src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs

@@ -69,6 +69,11 @@ namespace Avalonia.Rendering.SceneGraph
         /// </summary>
         IReadOnlyList<IRef<IDrawOperation>> DrawOperations { get; }
 
+        /// <summary>
+        /// Gets the opacity of the scene graph node.
+        /// </summary>
+        double Opacity { get; }
+
         /// <summary>
         /// Sets up the drawing context for rendering the node's geometry.
         /// </summary>

+ 1 - 3
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

@@ -67,9 +67,7 @@ namespace Avalonia.Rendering.SceneGraph
         /// <inheritdoc/>
         public bool HasAncestorGeometryClip { get; }
 
-        /// <summary>
-        /// Gets or sets the opacity of the scene graph node.
-        /// </summary>
+        /// <inheritdoc/>
         public double Opacity
         {
             get { return _opacity; }

+ 37 - 0
tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/SceneBuilderTests.cs

@@ -656,6 +656,43 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph
             }
         }
 
+        [Fact]
+        public void Setting_Opacity_Should_Add_Descendent_Bounds_To_DirtyRects()
+        {
+            using (TestApplication())
+            {
+                Decorator decorator;
+                Border border;
+                var tree = new TestRoot
+                {
+                    Child = decorator = new Decorator
+                    {
+                        Child = border = new Border
+                        {
+                            Background = Brushes.Red,
+                            Width = 100,
+                            Height = 100,
+                        }
+                    }
+                };
+
+                tree.Measure(Size.Infinity);
+                tree.Arrange(new Rect(tree.DesiredSize));
+
+                var scene = new Scene(tree);
+                var sceneBuilder = new SceneBuilder();
+                sceneBuilder.UpdateAll(scene);
+
+                decorator.Opacity = 0.5;
+                scene = scene.CloneScene();
+                sceneBuilder.Update(scene, decorator);
+
+                Assert.NotEmpty(scene.Layers.Single().Dirty);
+                var dirty = scene.Layers.Single().Dirty.Single();
+                Assert.Equal(new Rect(0, 0, 100, 100), dirty);
+            }
+        }
+
         [Fact]
         public void Should_Set_GeometryClip()
         {