|
@@ -5,6 +5,7 @@ using PixiEditor.ChangeableDocument.Changeables.Graph.Context;
|
|
using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
|
|
using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
|
|
using PixiEditor.ChangeableDocument.Changeables.Interfaces;
|
|
using PixiEditor.ChangeableDocument.Changeables.Interfaces;
|
|
using PixiEditor.ChangeableDocument.Rendering;
|
|
using PixiEditor.ChangeableDocument.Rendering;
|
|
|
|
+using PixiEditor.Common;
|
|
using PixiEditor.DrawingApi.Core;
|
|
using PixiEditor.DrawingApi.Core;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.ColorsImpl;
|
|
using PixiEditor.DrawingApi.Core.Shaders;
|
|
using PixiEditor.DrawingApi.Core.Shaders;
|
|
@@ -66,13 +67,13 @@ public abstract class Node : IReadOnlyNode, IDisposable
|
|
private bool _keyFramesDirty;
|
|
private bool _keyFramesDirty;
|
|
private Texture? _lastCachedResult;
|
|
private Texture? _lastCachedResult;
|
|
private bool _isDisposed;
|
|
private bool _isDisposed;
|
|
-
|
|
|
|
|
|
+
|
|
private Dictionary<int, Texture> _managedTextures = new();
|
|
private Dictionary<int, Texture> _managedTextures = new();
|
|
|
|
|
|
public Texture? Execute(RenderingContext context)
|
|
public Texture? Execute(RenderingContext context)
|
|
{
|
|
{
|
|
var result = ExecuteInternal(context);
|
|
var result = ExecuteInternal(context);
|
|
-
|
|
|
|
|
|
+
|
|
if (result is null)
|
|
if (result is null)
|
|
{
|
|
{
|
|
return null;
|
|
return null;
|
|
@@ -84,8 +85,8 @@ public abstract class Node : IReadOnlyNode, IDisposable
|
|
|
|
|
|
internal Texture? ExecuteInternal(RenderingContext context)
|
|
internal Texture? ExecuteInternal(RenderingContext context)
|
|
{
|
|
{
|
|
- if(_isDisposed) throw new ObjectDisposedException("Node was disposed before execution.");
|
|
|
|
-
|
|
|
|
|
|
+ if (_isDisposed) throw new ObjectDisposedException("Node was disposed before execution.");
|
|
|
|
+
|
|
if (!CacheChanged(context)) return CachedResult;
|
|
if (!CacheChanged(context)) return CachedResult;
|
|
|
|
|
|
CachedResult = OnExecute(context);
|
|
CachedResult = OnExecute(context);
|
|
@@ -93,7 +94,7 @@ public abstract class Node : IReadOnlyNode, IDisposable
|
|
{
|
|
{
|
|
throw new ObjectDisposedException("Texture was disposed after execution.");
|
|
throw new ObjectDisposedException("Texture was disposed after execution.");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
UpdateCache(context);
|
|
UpdateCache(context);
|
|
return CachedResult;
|
|
return CachedResult;
|
|
}
|
|
}
|
|
@@ -133,15 +134,15 @@ public abstract class Node : IReadOnlyNode, IDisposable
|
|
_managedTextures[id] = texture;
|
|
_managedTextures[id] = texture;
|
|
return texture;
|
|
return texture;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (clear)
|
|
if (clear)
|
|
{
|
|
{
|
|
texture.DrawingSurface.Canvas.Clear(Colors.Transparent);
|
|
texture.DrawingSurface.Canvas.Clear(Colors.Transparent);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return texture;
|
|
return texture;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
_managedTextures[id] = new Texture(size);
|
|
_managedTextures[id] = new Texture(size);
|
|
return _managedTextures[id];
|
|
return _managedTextures[id];
|
|
}
|
|
}
|
|
@@ -315,7 +316,7 @@ public abstract class Node : IReadOnlyNode, IDisposable
|
|
keyFrame.Dispose();
|
|
keyFrame.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach (var texture in _managedTextures)
|
|
foreach (var texture in _managedTextures)
|
|
{
|
|
{
|
|
texture.Value.Dispose();
|
|
texture.Value.Dispose();
|
|
@@ -370,18 +371,19 @@ public abstract class Node : IReadOnlyNode, IDisposable
|
|
{
|
|
{
|
|
var cloneOutput = outputs[i];
|
|
var cloneOutput = outputs[i];
|
|
var newOutput = cloneOutput.Clone(clone);
|
|
var newOutput = cloneOutput.Clone(clone);
|
|
- clone.outputs[i].Value = newOutput.Value;
|
|
|
|
|
|
+ clone.outputs[i].Value = newOutput.Value;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
foreach (var keyFrame in keyFrames)
|
|
foreach (var keyFrame in keyFrames)
|
|
{
|
|
{
|
|
KeyFrameData newKeyFrame = new KeyFrameData(keyFrame.KeyFrameGuid, keyFrame.StartFrame, keyFrame.Duration,
|
|
KeyFrameData newKeyFrame = new KeyFrameData(keyFrame.KeyFrameGuid, keyFrame.StartFrame, keyFrame.Duration,
|
|
keyFrame.AffectedElement)
|
|
keyFrame.AffectedElement)
|
|
{
|
|
{
|
|
- IsVisible = keyFrame.IsVisible, Duration = keyFrame.Duration,
|
|
|
|
|
|
+ IsVisible = keyFrame.IsVisible,
|
|
|
|
+ Duration = keyFrame.Duration,
|
|
Data = keyFrame.Data is ICloneable cloneable ? cloneable.Clone() : keyFrame.Data
|
|
Data = keyFrame.Data is ICloneable cloneable ? cloneable.Clone() : keyFrame.Data
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
clone.keyFrames.Add(newKeyFrame);
|
|
clone.keyFrames.Add(newKeyFrame);
|
|
}
|
|
}
|
|
|
|
|