Explorar o código

Fixed emoji rendering with color space

Krzysztof Krysiński hai 4 meses
pai
achega
15a20ea132

+ 0 - 5
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/ImageLayerNode.cs

@@ -47,11 +47,6 @@ public class ImageLayerNode : LayerNode, IReadOnlyImageNode
         return (RectD?)GetLayerImageAtFrame(frameTime.Frame).FindTightCommittedBounds();
     }
 
-    protected override VecI GetTargetSize(RenderContext ctx)
-    {
-        return (GetFrameWithImage(ctx.FrameTime).Data as ChunkyImage).LatestSize;
-    }
-
     protected internal override void DrawLayerInScene(SceneObjectRenderContext ctx,
         DrawingSurface workingSurface,
         bool useFilters = true)

+ 20 - 22
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/LayerNode.cs

@@ -111,7 +111,6 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
         target.Canvas.RestoreToCount(scaled);
     }
 
-    protected abstract VecI GetTargetSize(RenderContext ctx);
 
     protected internal virtual void DrawLayerInScene(SceneObjectRenderContext ctx,
         DrawingSurface workingSurface,
@@ -125,35 +124,34 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
     {
         blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * ctx.Opacity * 255));
 
+        var targetSurface = workingSurface;
+        Texture? tex = null;
+        int saved = -1;
+        if (!ctx.ProcessingColorSpace.IsSrgb)
+        {
+            saved = workingSurface.Canvas.Save();
+
+            tex = Texture.ForProcessing(workingSurface,
+                ColorSpace.CreateSrgb());
+            targetSurface = tex.DrawingSurface;
+            workingSurface.Canvas.SetMatrix(Matrix3X3.Identity);
+        }
         if (useFilters && Filters.Value != null)
         {
             blendPaint.SetFilters(Filters.Value);
-
-            var targetSurface = workingSurface;
-            Texture? tex = null;
-            int saved = -1;
-            if (!ctx.ProcessingColorSpace.IsSrgb)
-            {
-                saved = workingSurface.Canvas.Save();
-
-                tex = Texture.ForProcessing(workingSurface, ColorSpace.CreateSrgb()); // filters are meant to be applied in sRGB
-                targetSurface = tex.DrawingSurface;
-                workingSurface.Canvas.SetMatrix(Matrix3X3.Identity);
-            }
-
             DrawWithFilters(ctx, targetSurface, blendPaint);
-
-            if(targetSurface != workingSurface)
-            {
-                workingSurface.Canvas.DrawSurface(targetSurface, 0, 0);
-                tex.Dispose();
-                workingSurface.Canvas.RestoreToCount(saved);
-            }
         }
         else
         {
             blendPaint.SetFilters(null);
-            DrawWithoutFilters(ctx, workingSurface, blendPaint);
+            DrawWithoutFilters(ctx, targetSurface, blendPaint);
+        }
+
+        if (targetSurface != workingSurface)
+        {
+            workingSurface.Canvas.DrawSurface(targetSurface, 0, 0);
+            tex.Dispose();
+            workingSurface.Canvas.RestoreToCount(saved);
         }
     }
 

+ 16 - 6
src/PixiEditor.ChangeableDocument/Changeables/Graph/Nodes/VectorLayerNode.cs

@@ -9,6 +9,7 @@ using Drawie.Backend.Core;
 using Drawie.Backend.Core.ColorsImpl;
 using Drawie.Backend.Core.Numerics;
 using Drawie.Backend.Core.Surfaces;
+using Drawie.Backend.Core.Surfaces.ImageData;
 using Drawie.Backend.Core.Surfaces.PaintImpl;
 using Drawie.Numerics;
 
@@ -51,11 +52,6 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
         Shape = CreateOutput<ShapeVectorData>("Shape", "SHAPE", null);
     }
 
-    protected override VecI GetTargetSize(RenderContext ctx)
-    {
-        return ctx.DocumentSize;
-    }
-
     protected override void DrawWithoutFilters(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
         Paint paint)
     {
@@ -120,7 +116,21 @@ public class VectorLayerNode : LayerNode, ITransformableObject, IReadOnlyVectorN
         }
 
         Matrix3X3 matrix = ShapeData.TransformationMatrix;
-        Rasterize(renderOn, paint);
+
+        if (!context.ProcessingColorSpace.IsSrgb)
+        {
+            int saved = renderOn.Canvas.Save();
+            Texture tex = Texture.ForProcessing(renderOn, ColorSpace.CreateSrgb());
+            renderOn.Canvas.SetMatrix(Matrix3X3.Identity);
+            Rasterize(tex.DrawingSurface, paint);
+            renderOn.Canvas.DrawSurface(tex.DrawingSurface, 0, 0);
+            renderOn.Canvas.RestoreToCount(saved);
+        }
+        else
+        {
+            Rasterize(renderOn, paint);
+        }
+
         return true;
     }