Krzysztof Krysiński 5 месяцев назад
Родитель
Сommit
660430df3f

+ 6 - 3
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/LayerNode.cs

@@ -123,6 +123,7 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
         bool useFilters)
     {
         blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * ctx.Opacity * 255));
+        var finalPaint = blendPaint;
 
         var targetSurface = workingSurface;
         Texture? tex = null;
@@ -135,21 +136,23 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
                 ColorSpace.CreateSrgb());
             targetSurface = tex.DrawingSurface;
             workingSurface.Canvas.SetMatrix(Matrix3X3.Identity);
+
+            finalPaint = new Paint();
         }
         if (useFilters && Filters.Value != null)
         {
             blendPaint.SetFilters(Filters.Value);
-            DrawWithFilters(ctx, targetSurface, blendPaint);
+            DrawWithFilters(ctx, targetSurface, finalPaint);
         }
         else
         {
             blendPaint.SetFilters(null);
-            DrawWithoutFilters(ctx, targetSurface, blendPaint);
+            DrawWithoutFilters(ctx, targetSurface, finalPaint);
         }
 
         if (targetSurface != workingSurface)
         {
-            workingSurface.Canvas.DrawSurface(targetSurface, 0, 0);
+            workingSurface.Canvas.DrawSurface(targetSurface, 0, 0, blendPaint);
             tex.Dispose();
             workingSurface.Canvas.RestoreToCount(saved);
         }

+ 14 - 13
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/MergeNode.cs

@@ -17,11 +17,11 @@ public class MergeNode : RenderNode
     public RenderInputProperty Bottom { get; }
 
     private Paint paint = new Paint();
-    
+
     private int topLayer;
     private int bottomLayer;
-    
-    public MergeNode() 
+
+    public MergeNode()
     {
         BlendMode = CreateInput("BlendMode", "BlendMode", Enums.BlendMode.Normal);
         Top = CreateRenderInput("Top", "TOP");
@@ -36,16 +36,17 @@ public class MergeNode : RenderNode
 
     protected override void OnPaint(RenderContext context, DrawingSurface target)
     {
-        if(Top.Value == null && Bottom.Value == null)
+        if (Top.Value == null && Bottom.Value == null)
         {
             return;
         }
-        
-        if(target == null || target.DeviceClipBounds.Size == VecI.Zero)
+
+        if (target == null || target.DeviceClipBounds.Size == VecI.Zero)
         {
             return;
         }
 
+        AllowHighDpiRendering = true;
         Merge(target, context);
     }
 
@@ -59,7 +60,7 @@ public class MergeNode : RenderNode
 
             paint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
             target.Canvas.SaveLayer(paint);
-            
+
             Top.Value?.Paint(context, target);
             target.Canvas.RestoreToCount(saved);
             return;
@@ -71,13 +72,13 @@ public class MergeNode : RenderNode
 
     public override RectD? GetPreviewBounds(int frame, string elementToRenderName = "")
     {
-        if(Top.Value == null && Bottom.Value == null)
+        if (Top.Value == null && Bottom.Value == null)
         {
             return null;
         }
 
-        RectD? totalBounds = null; 
-        
+        RectD? totalBounds = null;
+
         if (Top.Connection != null && Top.Connection.Node is IPreviewRenderable topPreview)
         {
             var topBounds = topPreview.GetPreviewBounds(frame, elementToRenderName);
@@ -86,16 +87,16 @@ public class MergeNode : RenderNode
                 totalBounds = totalBounds?.Union(topBounds.Value) ?? topBounds;
             }
         }
-        
+
         if (Bottom.Connection != null && Bottom.Connection.Node is IPreviewRenderable bottomPreview)
         {
             var bottomBounds = bottomPreview.GetPreviewBounds(frame, elementToRenderName);
             if (bottomBounds != null)
             {
                 totalBounds = totalBounds?.Union(bottomBounds.Value) ?? bottomBounds;
-            } 
+            }
         }
-        
+
         return totalBounds;
     }
 

+ 11 - 1
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/RenderNode.cs

@@ -1,5 +1,6 @@
 using Drawie.Backend.Core;
 using Drawie.Backend.Core.ColorsImpl;
+using Drawie.Backend.Core.Numerics;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
 using PixiEditor.ChangeableDocument.Rendering;
 using Drawie.Backend.Core.Surfaces;
@@ -49,7 +50,16 @@ public abstract class RenderNode : Node, IPreviewRenderable, IHighDpiRenderNode
                                && surface.DeviceClipBounds.Size != context.DocumentSize;
         if (useIntermediate)
         {
-            Texture intermediate = textureCache.RequestTexture(0, context.DocumentSize, context.ProcessingColorSpace);
+            Texture intermediate = textureCache.RequestTexture(-6451, context.DocumentSize, context.ProcessingColorSpace);
+
+            int saved = intermediate.DrawingSurface.Canvas.Save();
+            Matrix3X3 fitMatrix = Matrix3X3.CreateScale(
+                (float)context.DocumentSize.X / surface.DeviceClipBounds.Size.X,
+                (float)context.DocumentSize.Y / surface.DeviceClipBounds.Size.Y);
+            intermediate.DrawingSurface.Canvas.SetMatrix(fitMatrix);
+            intermediate.DrawingSurface.Canvas.DrawSurface(surface, 0, 0);
+            intermediate.DrawingSurface.Canvas.RestoreToCount(saved);
+
             target = intermediate.DrawingSurface;
         }
 

BIN
tests/SampleFiles/Blending/FolderFolderBlend.pixi


BIN
tests/SampleFiles/Blending/LayerFolderBlend.pixi


BIN
tests/SampleFiles/Blending/TwoLayersBlend.pixi


BIN
tests/SampleFiles/Nodes/VectorRasterMergeNode.pixi