Browse Source

Merge branch 'master' into language-update-18-1

Krzysztof Krysiński 3 months ago
parent
commit
dcf08db09d

+ 7 - 0
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/FilterNodes/ApplyFilterNode.cs

@@ -26,6 +26,13 @@ public class ApplyFilterNode : RenderNode, IRenderInput
         AllowHighDpiRendering = true;
         AllowHighDpiRendering = true;
     }
     }
 
 
+
+    protected override void Paint(RenderContext context, DrawingSurface surface)
+    {
+        AllowHighDpiRendering = (Background.Connection.Node as RenderNode)?.AllowHighDpiRendering ?? true;
+        base.Paint(context, surface);
+    }
+
     protected override void OnPaint(RenderContext context, DrawingSurface surface)
     protected override void OnPaint(RenderContext context, DrawingSurface surface)
     {
     {
         if (_paint == null)
         if (_paint == null)

+ 3 - 2
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ImageLayerNode.cs

@@ -54,6 +54,7 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         int scaled = workingSurface.Canvas.Save();
         int scaled = workingSurface.Canvas.Save();
         float multiplier = (float)ctx.ChunkResolution.InvertedMultiplier();
         float multiplier = (float)ctx.ChunkResolution.InvertedMultiplier();
         workingSurface.Canvas.Translate(GetScenePosition(ctx.FrameTime));
         workingSurface.Canvas.Translate(GetScenePosition(ctx.FrameTime));
+
         base.DrawLayerInScene(ctx, workingSurface, useFilters);
         base.DrawLayerInScene(ctx, workingSurface, useFilters);
 
 
         workingSurface.Canvas.RestoreToCount(scaled);
         workingSurface.Canvas.RestoreToCount(scaled);
@@ -61,13 +62,13 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
 
 
     protected internal override void DrawLayerOnTexture(SceneObjectRenderContext ctx,
     protected internal override void DrawLayerOnTexture(SceneObjectRenderContext ctx,
         DrawingSurface workingSurface,
         DrawingSurface workingSurface,
-        bool useFilters)
+        bool useFilters, Paint paint)
     {
     {
         int scaled = workingSurface.Canvas.Save();
         int scaled = workingSurface.Canvas.Save();
         workingSurface.Canvas.Translate(GetScenePosition(ctx.FrameTime) * ctx.ChunkResolution.Multiplier());
         workingSurface.Canvas.Translate(GetScenePosition(ctx.FrameTime) * ctx.ChunkResolution.Multiplier());
         workingSurface.Canvas.Scale((float)ctx.ChunkResolution.Multiplier());
         workingSurface.Canvas.Scale((float)ctx.ChunkResolution.Multiplier());
 
 
-        DrawLayerOnto(ctx, workingSurface, useFilters);
+        DrawLayerOnto(ctx, workingSurface, useFilters, paint);
 
 
         workingSurface.Canvas.RestoreToCount(scaled);
         workingSurface.Canvas.RestoreToCount(scaled);
     }
     }

+ 33 - 14
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/LayerNode.cs

@@ -32,7 +32,7 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
         blendPaint.BlendMode = Drawie.Backend.Core.Surfaces.BlendMode.SrcOver;
         blendPaint.BlendMode = Drawie.Backend.Core.Surfaces.BlendMode.SrcOver;
 
 
         RenderContent(sceneContext, sceneContext.RenderSurface,
         RenderContent(sceneContext, sceneContext.RenderSurface,
-            sceneContext.TargetPropertyOutput != FilterlessOutput);
+            sceneContext.TargetPropertyOutput == Output);
     }
     }
 
 
     private void RenderContent(SceneObjectRenderContext context, DrawingSurface renderOnto, bool useFilters)
     private void RenderContent(SceneObjectRenderContext context, DrawingSurface renderOnto, bool useFilters)
@@ -44,7 +44,24 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
                 blendPaint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
                 blendPaint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
             }
             }
 
 
-            DrawLayerInScene(context, renderOnto, useFilters);
+            if (AllowHighDpiRendering)
+            {
+                DrawLayerInScene(context, renderOnto, useFilters);
+            }
+            else
+            {
+                using var targetPaint = new Paint
+                {
+                    Color = new Color(255, 255, 255, 255),
+                    BlendMode = Drawie.Backend.Core.Surfaces.BlendMode.SrcOver
+                };
+
+                using var tempSurface = Texture.ForProcessing(context.DocumentSize, context.ProcessingColorSpace);
+                DrawLayerOnTexture(context, tempSurface.DrawingSurface, useFilters, targetPaint);
+
+                renderOnto.Canvas.DrawSurface(tempSurface.DrawingSurface, 0, 0, blendPaint);
+            }
+
             return;
             return;
         }
         }
 
 
@@ -59,7 +76,7 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
 
 
         renderOnto.Canvas.SetMatrix(Matrix3X3.Identity);
         renderOnto.Canvas.SetMatrix(Matrix3X3.Identity);
 
 
-        DrawLayerOnTexture(context, outputWorkingSurface.DrawingSurface, useFilters);
+        DrawLayerOnTexture(context, outputWorkingSurface.DrawingSurface, useFilters, blendPaint);
 
 
         ApplyMaskIfPresent(outputWorkingSurface.DrawingSurface, context);
         ApplyMaskIfPresent(outputWorkingSurface.DrawingSurface, context);
 
 
@@ -90,12 +107,12 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
 
 
     protected internal virtual void DrawLayerOnTexture(SceneObjectRenderContext ctx,
     protected internal virtual void DrawLayerOnTexture(SceneObjectRenderContext ctx,
         DrawingSurface workingSurface,
         DrawingSurface workingSurface,
-        bool useFilters)
+        bool useFilters, Paint paint)
     {
     {
         int scaled = workingSurface.Canvas.Save();
         int scaled = workingSurface.Canvas.Save();
         workingSurface.Canvas.Scale((float)ctx.ChunkResolution.Multiplier());
         workingSurface.Canvas.Scale((float)ctx.ChunkResolution.Multiplier());
 
 
-        DrawLayerOnto(ctx, workingSurface, useFilters);
+        DrawLayerOnto(ctx, workingSurface, useFilters, paint);
 
 
         workingSurface.Canvas.RestoreToCount(scaled);
         workingSurface.Canvas.RestoreToCount(scaled);
     }
     }
@@ -116,14 +133,14 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
         DrawingSurface workingSurface,
         DrawingSurface workingSurface,
         bool useFilters = true)
         bool useFilters = true)
     {
     {
-        DrawLayerOnto(ctx, workingSurface, useFilters);
+        DrawLayerOnto(ctx, workingSurface, useFilters, blendPaint);
     }
     }
 
 
     protected void DrawLayerOnto(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
     protected void DrawLayerOnto(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
-        bool useFilters)
+        bool useFilters, Paint paint)
     {
     {
-        blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * ctx.Opacity * 255));
-        var finalPaint = blendPaint;
+        paint.Color = paint.Color.WithAlpha((byte)Math.Round(Opacity.Value * ctx.Opacity * 255));
+        var finalPaint = paint;
 
 
         var targetSurface = workingSurface;
         var targetSurface = workingSurface;
         Texture? tex = null;
         Texture? tex = null;
@@ -134,30 +151,32 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
 
 
             tex = Texture.ForProcessing(workingSurface,
             tex = Texture.ForProcessing(workingSurface,
                 ColorSpace.CreateSrgb());
                 ColorSpace.CreateSrgb());
-            targetSurface = tex.DrawingSurface;
             workingSurface.Canvas.SetMatrix(Matrix3X3.Identity);
             workingSurface.Canvas.SetMatrix(Matrix3X3.Identity);
 
 
+            targetSurface = tex.DrawingSurface;
+
             finalPaint = new Paint();
             finalPaint = new Paint();
         }
         }
+
         if (useFilters && Filters.Value != null)
         if (useFilters && Filters.Value != null)
         {
         {
-            blendPaint.SetFilters(Filters.Value);
+            paint.SetFilters(Filters.Value);
             DrawWithFilters(ctx, targetSurface, finalPaint);
             DrawWithFilters(ctx, targetSurface, finalPaint);
         }
         }
         else
         else
         {
         {
-            blendPaint.SetFilters(null);
+            paint.SetFilters(null);
             DrawWithoutFilters(ctx, targetSurface, finalPaint);
             DrawWithoutFilters(ctx, targetSurface, finalPaint);
         }
         }
 
 
-        if (finalPaint != blendPaint)
+        if (finalPaint != paint)
         {
         {
             finalPaint.Dispose();
             finalPaint.Dispose();
         }
         }
 
 
         if (targetSurface != workingSurface)
         if (targetSurface != workingSurface)
         {
         {
-            workingSurface.Canvas.DrawSurface(targetSurface, 0, 0, blendPaint);
+            workingSurface.Canvas.DrawSurface(targetSurface, 0, 0, paint);
             tex.Dispose();
             tex.Dispose();
             workingSurface.Canvas.RestoreToCount(saved);
             workingSurface.Canvas.RestoreToCount(saved);
         }
         }

+ 7 - 0
tests/global.json

@@ -0,0 +1,7 @@
+{
+  "sdk": {
+    "version": "8.0.405",
+    "rollForward": "latestMinor",
+    "allowPrerelease": false
+  }
+}