Procházet zdrojové kódy

Fixed sample image

flabbet před 1 rokem
rodič
revize
71a9c5306c

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

@@ -50,7 +50,6 @@ public class CreateImageNode : Node
         surface.DrawingSurface.Canvas.RestoreToCount(saved);
         Output.Value = surface;
 
-
         RenderOutput.ChainToPainterValue();
     }
 

+ 6 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ModifyImageLeftNode.cs

@@ -2,6 +2,7 @@
 using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
 using PixiEditor.ChangeableDocument.Rendering;
 using PixiEditor.DrawingApi.Core;
+using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.DrawingApi.Core.Shaders.Generation.Expressions;
 using PixiEditor.DrawingApi.Core.Surfaces;
 using PixiEditor.Numerics;
@@ -30,6 +31,11 @@ public class ModifyImageLeftNode : Node, IPairNode, IPreviewRenderable
     private Half4 GetColor(FuncContext context)
     {
         context.ThrowOnMissingContext();
+        
+        if(Image.Value == null)
+        {
+            return new Half4("") { ConstantValue = Colors.Transparent };
+        }
 
         return context.SampleSurface(Image.Value.DrawingSurface, context.SamplePosition);
     }

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

@@ -16,7 +16,7 @@ public class ModifyImageRightNode : RenderNode, IPairNode, ICustomShaderNode
 {
     public Guid OtherNode { get; set; }
 
-    private Paint drawingPaint = new Paint() { BlendMode = BlendMode.Src };
+    private Paint drawingPaint = new Paint() { BlendMode = BlendMode.SrcOver };
 
     public FuncInputProperty<Float2> Coordinate { get; }
     public FuncInputProperty<Half4> Color { get; }
@@ -53,8 +53,6 @@ public class ModifyImageRightNode : RenderNode, IPairNode, ICustomShaderNode
             return;
         }
 
-        Texture surface = RequestTexture(0, size);
-
         ShaderBuilder builder = new(size);
         FuncContext context = new(renderContext, builder);
 
@@ -102,9 +100,7 @@ public class ModifyImageRightNode : RenderNode, IPairNode, ICustomShaderNode
             drawingPaint.Shader = drawingPaint.Shader.WithUpdatedUniforms(builder.Uniforms);
         }
 
-        surface.DrawingSurface.Canvas.DrawRect(0, 0, size.X, size.Y, drawingPaint);
-
-        targetSurface.Canvas.DrawSurface(surface.DrawingSurface, 0, 0);
+        targetSurface.Canvas.DrawRect(0, 0, size.X, size.Y, drawingPaint);
         builder.Dispose();
     }
 

+ 3 - 4
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/SampleImageNode.cs

@@ -28,20 +28,19 @@ public class SampleImageNode : Node
     {
         context.ThrowOnMissingContext();
 
-        /*if (Image.Value is null)
+        if (Image.Value is null)
         {
             return new Half4("");
         }
 
         Float2 uv = context.GetValue(Coordinate);
 
-        return context.SampleSurface(Image.Value, uv);*/
-        return new Half4("");// TODO: Implement this
+        return context.SampleSurface(Image.Value.DrawingSurface, uv);
     }
 
     protected override void OnExecute(RenderContext context)
     {
-        //return Image.Value;
+        
     }
 
     public override Node CreateCopy() => new SampleImageNode();

+ 5 - 1
src/PixiEditor.DrawingApi.Skia/Implementations/SkiaImageImplementation.cs

@@ -17,10 +17,14 @@ namespace PixiEditor.DrawingApi.Skia.Implementations
         private SkObjectImplementation<SKSurface>? _surfaceImplementation;
         private SkiaShaderImplementation shaderImpl;
         
-        public SkiaImageImplementation(SkObjectImplementation<SKData> imgDataImplementation, SkiaPixmapImplementation pixmapImplementation,  SkiaShaderImplementation shaderImplementation)
+        public SkiaImageImplementation(SkObjectImplementation<SKData> imgDataImplementation, SkiaPixmapImplementation pixmapImplementation)
         {
             _imgImplementation = imgDataImplementation;
             _pixmapImplementation = pixmapImplementation;
+        }
+        
+        public void SetShaderImplementation(SkiaShaderImplementation shaderImplementation)
+        {
             shaderImpl = shaderImplementation;
         }
         

+ 4 - 3
src/PixiEditor.DrawingApi.Skia/SkiaDrawingBackend.cs

@@ -68,15 +68,16 @@ namespace PixiEditor.DrawingApi.Skia
             SkiaPixmapImplementation pixmapImpl = new SkiaPixmapImplementation(colorSpaceImpl);
             PixmapImplementation = pixmapImpl;
 
-            SkiaShaderImplementation shader = null;
 
-            SkiaImageImplementation imgImpl = new SkiaImageImplementation(dataImpl, pixmapImpl, shader);
+            SkiaImageImplementation imgImpl = new SkiaImageImplementation(dataImpl, pixmapImpl);
             ImageImplementation = imgImpl;
             SkiaBitmapImplementation bitmapImpl = new SkiaBitmapImplementation(imgImpl, pixmapImpl);
             BitmapImplementation = bitmapImpl;
 
-            shader = new SkiaShaderImplementation(bitmapImpl);
+            var shader = new SkiaShaderImplementation(bitmapImpl);
             ShaderImplementation = shader;
+            
+            imgImpl.SetShaderImplementation(shader);
 
             SkiaPaintImplementation paintImpl = new SkiaPaintImplementation(colorFilterImpl, imageFilterImpl, shader);
             PaintImplementation = paintImpl;