Bladeren bron

Added intermediate filter applying to NestedDocumentNode

Krzysztof Krysiński 2 dagen geleden
bovenliggende
commit
3c89bc6b3e

+ 2 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/CacheTriggerFlags.cs

@@ -7,5 +7,6 @@ public enum CacheTriggerFlags
     Inputs = 1,
     Timeline = 2,
     RenderSize = 4,
-    All = Inputs | Timeline | RenderSize
+    ChunkResolution = 8,
+    All = Inputs | Timeline | RenderSize | ChunkResolution
 }

+ 1 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/FilterNodes/BlurNode.cs

@@ -15,7 +15,7 @@ public class BlurNode : FilterNode
 
     protected override bool ExecuteOnlyOnCacheChange => true;
 
-    protected override CacheTriggerFlags CacheTrigger => CacheTriggerFlags.Inputs | CacheTriggerFlags.RenderSize;
+    protected override CacheTriggerFlags CacheTrigger => CacheTriggerFlags.Inputs | CacheTriggerFlags.RenderSize | CacheTriggerFlags.ChunkResolution;
 
     public BlurNode()
     {

+ 13 - 8
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/NestedDocumentNode.cs

@@ -132,7 +132,7 @@ public class NestedDocumentNode : LayerNode, IInputDependentOutputs, ITransforma
                 continue;
             }
 
-            if(!variable.Value.IsExposed)
+            if (!variable.Value.IsExposed)
                 continue;
 
             AddInputProperty(new InputProperty(this, variable.Key, variable.Key, variable.Value.Value,
@@ -164,10 +164,10 @@ public class NestedDocumentNode : LayerNode, IInputDependentOutputs, ITransforma
                 continue;
 
             bool shouldRemove = document.DocumentInstance.NodeGraph.Blackboard.Variables
-                .All(x => x.Key != input.InternalPropertyName ||
-                          x.Value.Type != input.ValueType) ||
-                              !document.DocumentInstance.NodeGraph.Blackboard.Variables[input.InternalPropertyName]
-                                  .IsExposed;
+                                    .All(x => x.Key != input.InternalPropertyName ||
+                                              x.Value.Type != input.ValueType) ||
+                                !document.DocumentInstance.NodeGraph.Blackboard.Variables[input.InternalPropertyName]
+                                    .IsExposed;
 
             if (shouldRemove)
             {
@@ -302,12 +302,17 @@ public class NestedDocumentNode : LayerNode, IInputDependentOutputs, ITransforma
         if (NestedDocument.Value is null)
             return;
 
-        int saved = workingSurface.SaveLayer(paint);
-
-        workingSurface.SetMatrix(workingSurface.TotalMatrix.Concat(TransformationMatrix));
+        Texture? intermediate = null;
+        var latestSize = new RectI(VecI.Zero, lastDocument.DocumentInstance.Size);
+        intermediate = RequestTexture(1336, latestSize.Size, ColorSpace.CreateSrgb());
 
+        ctx.RenderSurface = intermediate.DrawingSurface.Canvas;
+        ctx.RenderOutputSize = latestSize.Size;
         ExecuteNested(ctx);
 
+        int saved = workingSurface.Save();
+        workingSurface.SetMatrix(workingSurface.TotalMatrix.Concat(TransformationMatrix));
+        workingSurface.DrawSurface(intermediate.DrawingSurface, 0, 0, paint);
         workingSurface.RestoreToCount(saved);
     }
 

+ 9 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/Node.cs

@@ -49,6 +49,8 @@ public abstract class Node : IReadOnlyNode, IDisposable
 
     private VecI lastRenderSize = new VecI(0, 0);
 
+    private ChunkResolution lastChunkResolution = ChunkResolution.Full;
+
     public bool IsDisposed => _isDisposed;
     private bool _isDisposed;
 
@@ -97,6 +99,11 @@ public abstract class Node : IReadOnlyNode, IDisposable
             changed |= lastRenderSize != context.RenderOutputSize;
         }
 
+        if (CacheTrigger.HasFlag(CacheTriggerFlags.ChunkResolution))
+        {
+            changed |= lastChunkResolution != context.ChunkResolution;
+        }
+
         if (CacheTrigger.HasFlag(CacheTriggerFlags.Timeline))
         {
             changed |= lastFrameTime.Frame != context.FrameTime.Frame ||
@@ -122,6 +129,8 @@ public abstract class Node : IReadOnlyNode, IDisposable
         lastRenderSize = context.RenderOutputSize;
 
         lastContentCacheHash = GetContentCacheHash();
+
+        lastChunkResolution = context.ChunkResolution;
     }
 
     public void TraverseBackwards(Func<IReadOnlyNode, IInputProperty, bool> action,