Browse Source

Removed rendering cache stuff

flabbet 10 months ago
parent
commit
f84ecec51d

+ 0 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Animable/TimeNode.cs

@@ -9,7 +9,6 @@ public class TimeNode : Node
     public OutputProperty<int> ActiveFrame { get; set; }
     public OutputProperty<double> NormalizedTime { get; set; }
 
-    protected override bool AffectedByAnimation => true;
 
     public TimeNode()
     {

+ 0 - 23
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ImageLayerNode.cs

@@ -32,12 +32,6 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         Color = PixiEditor.DrawingApi.Core.ColorsImpl.Colors.Transparent
     };
 
-    // Handled by overriden CacheChanged
-    protected override bool AffectedByAnimation => true;
-
-    protected override bool AffectedByChunkResolution => true;
-
-
     private Texture fullResrenderedSurface; 
 
     public ImageLayerNode(VecI size)
@@ -94,8 +88,6 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         DrawLayer(workingSurface, paint, ctx.ChunkResolution); 
     }
 
-    // Draw with filters is a bit tricky since some filters sample data from chunks surrounding the chunk being drawn,
-    // this is why we need to do intermediate drawing to a temporary surface and then apply filters to that surface
     protected override void DrawWithFilters(SceneObjectRenderContext context, DrawingSurface workingSurface,
         Paint paint)
     {
@@ -138,21 +130,6 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         return true;
     }
 
-    private void DrawChunk(ChunkyImage frameImage, RenderContext context, Texture tempSurface, VecI vecI,
-        Paint paint)
-    {
-        /*VecI chunkPos = context.ChunkToUpdate.Value + vecI;
-        if (frameImage.LatestOrCommittedChunkExists(chunkPos))
-        {
-            frameImage.DrawMostUpToDateChunkOn(
-                chunkPos,
-                context.ChunkResolution,
-                tempSurface.DrawingSurface,
-                chunkPos * context.ChunkResolution.PixelSize(),
-                paint);
-        }*/
-    }
-
     private KeyFrameData GetFrameWithImage(KeyFrameTime frame)
     {
         var imageFrame = keyFrames.OrderBy(x => x.StartFrame).LastOrDefault(x => x.IsInFrame(frame.Frame));

+ 12 - 21
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Node.cs

@@ -26,10 +26,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
     public IReadOnlyList<OutputProperty> OutputProperties => outputs;
     public IReadOnlyList<KeyFrameData> KeyFrames => keyFrames;
 
-    protected virtual bool AffectedByAnimation { get; }
-
-    protected virtual bool AffectedByChunkResolution { get; }
-
 
     IReadOnlyList<IInputProperty> IReadOnlyNode.InputProperties => inputs;
     IReadOnlyList<IOutputProperty> IReadOnlyNode.OutputProperties => outputs;
@@ -41,11 +37,9 @@ public abstract class Node : IReadOnlyNode, IDisposable
         get => displayName;
         set => displayName = value;
     }
+    
+    protected virtual bool ExecuteOnlyOnCacheChange => false;
 
-    private KeyFrameTime _lastFrameTime = new KeyFrameTime(-1, 0);
-    private ChunkResolution? _lastResolution;
-    private bool _keyFramesDirty;
-    private Texture? _lastCachedResult;
     private bool _isDisposed;
 
     private Dictionary<int, Texture> _managedTextures = new();
@@ -59,19 +53,24 @@ public abstract class Node : IReadOnlyNode, IDisposable
     {
         if (_isDisposed) throw new ObjectDisposedException("Node was disposed before execution.");
 
+        if (ExecuteOnlyOnCacheChange && !CacheChanged(context))
+        {
+            return;
+        }
+        
         OnExecute(context);
 
-        UpdateCache(context);
+        if (ExecuteOnlyOnCacheChange)
+        {
+            UpdateCache(context);
+        }
     }
 
     protected abstract void OnExecute(RenderContext context);
 
     protected virtual bool CacheChanged(RenderContext context)
     {
-        return (!context.FrameTime.Equals(_lastFrameTime) && AffectedByAnimation)
-               || (AffectedByAnimation && _keyFramesDirty)
-               || (context.ChunkResolution != _lastResolution && AffectedByChunkResolution)
-               || inputs.Any(x => x.CacheChanged);
+        return inputs.Any(x => x.CacheChanged);
     }
 
     protected virtual void UpdateCache(RenderContext context)
@@ -80,10 +79,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
         {
             input.UpdateCache();
         }
-
-        _lastFrameTime = context.FrameTime;
-        _lastResolution = context.ChunkResolution;
-        _keyFramesDirty = false;
     }
 
     protected Texture RequestTexture(int id, VecI size, bool clear = true)
@@ -176,7 +171,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
     public void RemoveKeyFrame(Guid keyFrameId)
     {
         keyFrames.RemoveAll(x => x.KeyFrameGuid == keyFrameId);
-        _keyFramesDirty = true;
     }
 
     public void SetKeyFrameLength(Guid id, int startFrame, int duration)
@@ -186,7 +180,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
         {
             frame.StartFrame = startFrame;
             frame.Duration = duration;
-            _keyFramesDirty = true;
         }
     }
 
@@ -196,7 +189,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
         if (frame is not null)
         {
             frame.IsVisible = isVisible;
-            _keyFramesDirty = true;
         }
     }
 
@@ -208,7 +200,6 @@ public abstract class Node : IReadOnlyNode, IDisposable
         }
 
         keyFrames.Add(value);
-        _keyFramesDirty = true;
     }
 
     protected FuncInputProperty<T> CreateFuncInput<T>(string propName, string displayName, T defaultValue)

+ 0 - 2
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Shapes/RasterizeShapeNode.cs

@@ -16,8 +16,6 @@ public class RasterizeShapeNode : Node
     public InputProperty<ShapeVectorData> Data { get; }
 
 
-    protected override bool AffectedByChunkResolution => true;
-
     private Paint rasterizePaint = new Paint();
 
     public RasterizeShapeNode()

+ 0 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/StructureNode.cs

@@ -86,7 +86,6 @@ public abstract class StructureNode : Node, IReadOnlyStructureNode, IRenderInput
         return prop;
     }
 
-    protected override bool AffectedByChunkResolution => true;
 
     protected override void OnExecute(RenderContext context)
     {

+ 0 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/VectorLayerNode.cs

@@ -33,7 +33,6 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
     public ShapeVectorData? ShapeData { get; set; }
     IReadOnlyShapeVectorData IReadOnlyVectorNode.ShapeData => ShapeData;
 
-    protected override bool AffectedByChunkResolution => true;
 
     private int lastCacheHash;