@ -4,6 +4,7 @@
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Reactive.Disposables ;
using Avalonia.Media ;
using Avalonia.Platform ;
using Avalonia.Utilities ;
@ -23,6 +24,7 @@ namespace Avalonia.Rendering.SceneGraph
private double _ opacity ;
private List < IVisualNode > _ children ;
private List < IRef < IDrawOperation > > _d rawOperations ;
private IRef < IDisposable > _d rawOperationsRefCounter ;
private bool _d rawOperationsCloned ;
private Matrix transformRestore ;
@ -214,6 +216,7 @@ namespace Avalonia.Rendering.SceneGraph
_ opacity = Opacity ,
OpacityMask = OpacityMask ,
_d rawOperations = _d rawOperations ,
_d rawOperationsRefCounter = _d rawOperationsRefCounter ? . Clone ( ) ,
_d rawOperationsCloned = true ,
LayerRoot = LayerRoot ,
} ;
@ -315,10 +318,14 @@ namespace Avalonia.Rendering.SceneGraph
if ( _d rawOperations = = null )
{
_d rawOperations = new List < IRef < IDrawOperation > > ( ) ;
_d rawOperationsRefCounter = RefCountable . Create ( Disposable . Create ( DisposeDrawOperations ) ) ;
_d rawOperationsCloned = false ;
}
else if ( _d rawOperationsCloned )
{
_d rawOperations = new List < IRef < IDrawOperation > > ( _d rawOperations . Select ( op = > op . Clone ( ) ) ) ;
_d rawOperationsRefCounter . Dispose ( ) ;
_d rawOperationsRefCounter = RefCountable . Create ( Disposable . Create ( DisposeDrawOperations ) ) ;
_d rawOperationsCloned = false ;
}
}
@ -329,12 +336,14 @@ namespace Avalonia.Rendering.SceneGraph
{
child . Dispose ( ) ;
}
if ( ! _d rawOperationsCloned )
_d rawOperationsRefCounter ? . Dispose ( ) ;
}
private void DisposeDrawOperations ( )
{
foreach ( var operation in DrawOperations )
{
foreach ( var operation in DrawOperations )
{
operation . Dispose ( ) ;
}
operation . Dispose ( ) ;
}
}
}