Browse Source

Removed To Texture Node, logic moved to Create Image node

flabbet 10 months ago
parent
commit
6f3e9095dc

+ 6 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/CreateImageNode.cs

@@ -17,12 +17,15 @@ public class CreateImageNode : Node
     public InputProperty<VecI> Size { get; }
     public InputProperty<VecI> Size { get; }
     
     
     public InputProperty<Color> Fill { get; }
     public InputProperty<Color> Fill { get; }
+    
+    public RenderInputProperty Content { get; }
 
 
     public CreateImageNode()
     public CreateImageNode()
     {
     {
         Output = CreateOutput<Texture>(nameof(Output), "EMPTY_IMAGE", null);
         Output = CreateOutput<Texture>(nameof(Output), "EMPTY_IMAGE", null);
         Size = CreateInput(nameof(Size), "SIZE", new VecI(32, 32)).WithRules(v => v.Min(VecI.One));
         Size = CreateInput(nameof(Size), "SIZE", new VecI(32, 32)).WithRules(v => v.Min(VecI.One));
-        Fill = CreateInput(nameof(Fill), "FILL", new Color(0, 0, 0, 255));
+        Fill = CreateInput(nameof(Fill), "FILL", Colors.Transparent);
+        Content = CreateRenderInput(nameof(Content), "CONTENT");
     }
     }
 
 
     protected override void OnExecute(RenderContext context)
     protected override void OnExecute(RenderContext context)
@@ -37,6 +40,8 @@ public class CreateImageNode : Node
         _paint.Color = Fill.Value;
         _paint.Color = Fill.Value;
         surface.DrawingSurface.Canvas.DrawPaint(_paint);
         surface.DrawingSurface.Canvas.DrawPaint(_paint);
 
 
+        Content.Value?.Paint(context, surface.DrawingSurface);
+
         Output.Value = surface;
         Output.Value = surface;
     }
     }
  
  

+ 0 - 37
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ToTextureNode.cs

@@ -1,37 +0,0 @@
-using PixiEditor.ChangeableDocument.Rendering;
-using PixiEditor.DrawingApi.Core;
-using PixiEditor.Numerics;
-
-namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
-
-[NodeInfo("ToTexture")]
-public class ToTextureNode : Node
-{
-    public RenderInputProperty RenderInput { get; }
-    public InputProperty<VecI> Size { get; }
-    public OutputProperty<Texture> Texture { get; }
-
-    public ToTextureNode()
-    {
-        RenderInput = CreateRenderInput("RenderInput", "RENDER_INPUT");
-        Size = CreateInput("Size", "SIZE", VecI.One).WithRules(x => 
-            x.Min(VecI.One));
-        Texture = CreateOutput<Texture>("Texture", "TEXTURE", null);
-    }
-    
-    protected override void OnExecute(RenderContext context)
-    {
-        if(RenderInput.Value == null)
-        {
-            return;
-        }
-
-        Texture.Value = RequestTexture(0, Size.Value);
-        RenderInput.Value.Paint(context, Texture.Value.DrawingSurface);
-    }
-
-    public override Node CreateCopy()
-    {
-        return new ToTextureNode();
-    }
-}

+ 4 - 4
src/PixiEditor/Models/DocumentModels/ActionAccumulator.cs

@@ -90,8 +90,8 @@ internal class ActionAccumulator
             List<IChangeInfo> optimizedChanges = ChangeInfoListOptimizer.Optimize(changes);
             List<IChangeInfo> optimizedChanges = ChangeInfoListOptimizer.Optimize(changes);
             bool undoBoundaryPassed =
             bool undoBoundaryPassed =
                 toExecute.Any(static action => action.action is ChangeBoundary_Action or Redo_Action or Undo_Action);
                 toExecute.Any(static action => action.action is ChangeBoundary_Action or Redo_Action or Undo_Action);
-            bool viewportRefreshRequest =
-                toExecute.Any(static action => action.action is RefreshViewport_PassthroughAction);
+            /*bool viewportRefreshRequest =
+                toExecute.Any(static action => action.action is RefreshViewport_PassthroughAction);*/
             foreach (IChangeInfo info in optimizedChanges)
             foreach (IChangeInfo info in optimizedChanges)
             {
             {
                 internals.Updater.ApplyChangeFromChangeInfo(info);
                 internals.Updater.ApplyChangeFromChangeInfo(info);
@@ -106,12 +106,12 @@ internal class ActionAccumulator
             if (DrawingBackendApi.Current.IsHardwareAccelerated)
             if (DrawingBackendApi.Current.IsHardwareAccelerated)
             {
             {
                 canvasUpdater.UpdateGatheredChunksSync(affectedAreas,
                 canvasUpdater.UpdateGatheredChunksSync(affectedAreas,
-                    undoBoundaryPassed || viewportRefreshRequest);
+                    undoBoundaryPassed);
             }
             }
             else
             else
             {
             {
                 await canvasUpdater.UpdateGatheredChunks(affectedAreas,
                 await canvasUpdater.UpdateGatheredChunks(affectedAreas,
-                    undoBoundaryPassed || viewportRefreshRequest);
+                    undoBoundaryPassed);
             }
             }
 
 
             previewUpdater.UpdatePreviews(undoBoundaryPassed, affectedAreas.ImagePreviewAreas.Keys, affectedAreas.MaskPreviewAreas.Keys,
             previewUpdater.UpdatePreviews(undoBoundaryPassed, affectedAreas.ImagePreviewAreas.Keys, affectedAreas.MaskPreviewAreas.Keys,

+ 0 - 7
src/PixiEditor/ViewModels/Document/Nodes/ToTextureNodeViewModel.cs

@@ -1,7 +0,0 @@
-using PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
-using PixiEditor.ViewModels.Nodes;
-
-namespace PixiEditor.ViewModels.Document.Nodes;
-
-[NodeViewModel("TO_TEXTURE_NODE", "Image", null)]
-internal class ToTextureNodeViewModel : NodeViewModel<ToTextureNode>;