Browse Source
Merge pull request #1421 from AvaloniaUI/fixes/1420-opacity-dirtyrect
Force recursion into child scene graph nodes when Opacity changes.
pull/1432/head
Jeremy Koritzinsky
9 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
46 additions and
5 deletions
-
src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs
-
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
-
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs
-
tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/SceneBuilderTests.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>
|
|
|
|
|
|
|
|
@ -170,8 +170,9 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
var clipBounds = bounds.TransformToAABB(contextImpl.Transform).Intersect(clip); |
|
|
|
|
|
|
|
forceRecurse = forceRecurse || |
|
|
|
node.Transform != contextImpl.Transform || |
|
|
|
node.ClipBounds != clipBounds; |
|
|
|
node.ClipBounds != clipBounds || |
|
|
|
node.Opacity != opacity || |
|
|
|
node.Transform != contextImpl.Transform; |
|
|
|
|
|
|
|
node.Transform = contextImpl.Transform; |
|
|
|
node.ClipBounds = clipBounds; |
|
|
|
|
|
|
|
@ -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; } |
|
|
|
|
|
|
|
@ -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() |
|
|
|
{ |
|
|
|
|