Browse Source

Added color sample mode

flabbet 7 months ago
parent
commit
00205a378a

+ 1 - 1
src/Drawie

@@ -1 +1 @@
-Subproject commit c90f46c8ac9050511e5d65999c72b27e8b32ebfb
+Subproject commit ce63fc3f4fac69fd8108f828a776dd0a36d05a47

+ 2 - 2
src/PixiEditor.ChangeableDocument/Changeables/Graph/Context/FuncContext.cs

@@ -55,9 +55,9 @@ public class FuncContext
         SamplePosition = Builder.ConstructFloat2(OriginalPosition.X, OriginalPosition.Y);
         SamplePosition = Builder.ConstructFloat2(OriginalPosition.X, OriginalPosition.Y);
     }
     }
 
 
-    public Half4 SampleSurface(DrawingSurface surface, Expression pos)
+    public Half4 SampleSurface(DrawingSurface surface, Expression pos, ColorSampleMode sampleMode)
     {
     {
-        SurfaceSampler texName = Builder.AddOrGetSurface(surface);
+        SurfaceSampler texName = Builder.AddOrGetSurface(surface, sampleMode);
         return Builder.Sample(texName, pos);
         return Builder.Sample(texName, pos);
     }
     }
 
 

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

@@ -3,6 +3,7 @@ using Drawie.Backend.Core;
 using Drawie.Backend.Core.Bridge;
 using Drawie.Backend.Core.Bridge;
 using Drawie.Backend.Core.ColorsImpl;
 using Drawie.Backend.Core.ColorsImpl;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Backend.Core.Surfaces;
+using Drawie.Backend.Core.Surfaces.ImageData;
 using Drawie.Numerics;
 using Drawie.Numerics;
 
 
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
 namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
@@ -48,6 +49,7 @@ public class CreateImageNode : Node
         Content.Value?.Paint(ctx, surface.DrawingSurface);
         Content.Value?.Paint(ctx, surface.DrawingSurface);
 
 
         surface.DrawingSurface.Canvas.RestoreToCount(saved);
         surface.DrawingSurface.Canvas.RestoreToCount(saved);
+        
         Output.Value = surface;
         Output.Value = surface;
 
 
         RenderOutput.ChainToPainterValue();
         RenderOutput.ChainToPainterValue();

+ 5 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ModifyImageLeftNode.cs

@@ -3,6 +3,7 @@ using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
 using PixiEditor.ChangeableDocument.Rendering;
 using PixiEditor.ChangeableDocument.Rendering;
 using Drawie.Backend.Core;
 using Drawie.Backend.Core;
 using Drawie.Backend.Core.ColorsImpl;
 using Drawie.Backend.Core.ColorsImpl;
+using Drawie.Backend.Core.Shaders.Generation;
 using Drawie.Backend.Core.Shaders.Generation.Expressions;
 using Drawie.Backend.Core.Shaders.Generation.Expressions;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Numerics;
 using Drawie.Numerics;
@@ -18,6 +19,8 @@ public class ModifyImageLeftNode : Node, IPairNode, IPreviewRenderable
     public FuncOutputProperty<Float2> Coordinate { get; }
     public FuncOutputProperty<Float2> Coordinate { get; }
 
 
     public FuncOutputProperty<Half4> Color { get; }
     public FuncOutputProperty<Half4> Color { get; }
+    
+    public InputProperty<ColorSampleMode> SampleMode { get; }
 
 
     public Guid OtherNode { get; set; }
     public Guid OtherNode { get; set; }
     
     
@@ -26,6 +29,7 @@ public class ModifyImageLeftNode : Node, IPairNode, IPreviewRenderable
         Image = CreateInput<Texture?>("Surface", "IMAGE", null);
         Image = CreateInput<Texture?>("Surface", "IMAGE", null);
         Coordinate = CreateFuncOutput("Coordinate", "UV", ctx => ctx.OriginalPosition);
         Coordinate = CreateFuncOutput("Coordinate", "UV", ctx => ctx.OriginalPosition);
         Color = CreateFuncOutput("Color", "COLOR", GetColor);
         Color = CreateFuncOutput("Color", "COLOR", GetColor);
+        SampleMode = CreateInput("SampleMode", "COLOR_SAMPLE_MODE", ColorSampleMode.ColorManaged);
     }
     }
     
     
     private Half4 GetColor(FuncContext context)
     private Half4 GetColor(FuncContext context)
@@ -37,7 +41,7 @@ public class ModifyImageLeftNode : Node, IPairNode, IPreviewRenderable
             return new Half4("") { ConstantValue = Colors.Transparent };
             return new Half4("") { ConstantValue = Colors.Transparent };
         }
         }
 
 
-        return context.SampleSurface(Image.Value.DrawingSurface, context.SamplePosition);
+        return context.SampleSurface(Image.Value.DrawingSurface, context.SamplePosition, SampleMode.Value);
     }
     }
 
 
     protected override void OnExecute(RenderContext context)
     protected override void OnExecute(RenderContext context)

+ 0 - 4
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ModifyImageRightNode.cs

@@ -122,12 +122,8 @@ public class ModifyImageRightNode : RenderNode, IPairNode, ICustomShaderNode
         var startNode = FindStartNode();
         var startNode = FindStartNode();
         if (drawingPaint != null && startNode != null && startNode.Image.Value != null)
         if (drawingPaint != null && startNode != null && startNode.Image.Value != null)
         {
         {
-            int saved = renderOn.Canvas.SaveLayer(drawingPaint);
-            
             renderOn.Canvas.DrawRect(0, 0, startNode.Image.Value.Size.X, startNode.Image.Value.Size.Y, drawingPaint);
             renderOn.Canvas.DrawRect(0, 0, startNode.Image.Value.Size.X, startNode.Image.Value.Size.Y, drawingPaint);
             
             
-            renderOn.Canvas.RestoreToCount(saved);
-            
             return true;
             return true;
         }
         }
 
 

+ 6 - 2
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/SampleImageNode.cs

@@ -2,6 +2,7 @@
 using PixiEditor.ChangeableDocument.Rendering;
 using PixiEditor.ChangeableDocument.Rendering;
 using Drawie.Backend.Core;
 using Drawie.Backend.Core;
 using Drawie.Backend.Core.ColorsImpl;
 using Drawie.Backend.Core.ColorsImpl;
+using Drawie.Backend.Core.Shaders.Generation;
 using Drawie.Backend.Core.Shaders.Generation.Expressions;
 using Drawie.Backend.Core.Shaders.Generation.Expressions;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Backend.Core.Surfaces;
 using Drawie.Numerics;
 using Drawie.Numerics;
@@ -17,11 +18,14 @@ public class SampleImageNode : Node
 
 
     public FuncOutputProperty<Half4> Color { get; }
     public FuncOutputProperty<Half4> Color { get; }
 
 
+    public InputProperty<ColorSampleMode> SampleMode { get; }
+
     public SampleImageNode()
     public SampleImageNode()
     {
     {
         Image = CreateInput<Texture>(nameof(Texture), "IMAGE", null);
         Image = CreateInput<Texture>(nameof(Texture), "IMAGE", null);
         Coordinate = CreateFuncInput<Float2>(nameof(Coordinate), "UV", VecD.Zero);
         Coordinate = CreateFuncInput<Float2>(nameof(Coordinate), "UV", VecD.Zero);
         Color = CreateFuncOutput(nameof(Color), "COLOR", GetColor);
         Color = CreateFuncOutput(nameof(Color), "COLOR", GetColor);
+        SampleMode = CreateInput(nameof(SampleMode), "COLOR_SAMPLE_MODE", ColorSampleMode.ColorManaged);
     }
     }
 
 
     private Half4 GetColor(FuncContext context)
     private Half4 GetColor(FuncContext context)
@@ -35,12 +39,12 @@ public class SampleImageNode : Node
 
 
         Expression uv = context.GetValue(Coordinate);
         Expression uv = context.GetValue(Coordinate);
 
 
-        return context.SampleSurface(Image.Value.DrawingSurface, uv);
+        return context.SampleSurface(Image.Value.DrawingSurface, uv, SampleMode.Value);
     }
     }
 
 
     protected override void OnExecute(RenderContext context)
     protected override void OnExecute(RenderContext context)
     {
     {
-        
+
     }
     }
 
 
     public override Node CreateCopy() => new SampleImageNode();
     public override Node CreateCopy() => new SampleImageNode();

+ 2 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -791,5 +791,6 @@
   "STROKE_CAP": "Stroke Cap",
   "STROKE_CAP": "Stroke Cap",
   "STROKE_JOIN": "Stroke Join",
   "STROKE_JOIN": "Stroke Join",
   "COPY_VISIBLE": "Copy visible",
   "COPY_VISIBLE": "Copy visible",
-    "COPY_VISIBLE_DESCRIPTIVE": "Copy visible pixels"
+    "COPY_VISIBLE_DESCRIPTIVE": "Copy visible pixels",
+  "COLOR_SAMPLE_MODE": "Sample mode"
 }
 }