|
@@ -3,6 +3,7 @@ using PixiEditor.ChangeableDocument.Helpers;
|
|
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.Numerics;
|
|
using Drawie.Backend.Core.Surfaces;
|
|
using Drawie.Backend.Core.Surfaces;
|
|
using Drawie.Backend.Core.Surfaces.ImageData;
|
|
using Drawie.Backend.Core.Surfaces.ImageData;
|
|
using Drawie.Backend.Core.Surfaces.PaintImpl;
|
|
using Drawie.Backend.Core.Surfaces.PaintImpl;
|
|
@@ -23,7 +24,7 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
|
|
{
|
|
{
|
|
if (!IsVisible.Value || Opacity.Value <= 0 || IsEmptyMask())
|
|
if (!IsVisible.Value || Opacity.Value <= 0 || IsEmptyMask())
|
|
{
|
|
{
|
|
- Output.Value = Background.Value;
|
|
|
|
|
|
+ Output.Value = Background.Value;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -49,7 +50,8 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- var outputWorkingSurface = TryInitWorkingSurface(size, context.ChunkResolution, context.ProcessingColorSpace, 1);
|
|
|
|
|
|
+ var outputWorkingSurface =
|
|
|
|
+ TryInitWorkingSurface(size, context.ChunkResolution, context.ProcessingColorSpace, 1);
|
|
outputWorkingSurface.DrawingSurface.Canvas.Clear();
|
|
outputWorkingSurface.DrawingSurface.Canvas.Clear();
|
|
|
|
|
|
DrawLayerOnTexture(context, outputWorkingSurface.DrawingSurface, useFilters);
|
|
DrawLayerOnTexture(context, outputWorkingSurface.DrawingSurface, useFilters);
|
|
@@ -69,10 +71,11 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
|
|
}
|
|
}
|
|
|
|
|
|
blendPaint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
|
|
blendPaint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
|
|
- DrawWithResolution(outputWorkingSurface.DrawingSurface, renderOnto, context.ChunkResolution, size);
|
|
|
|
|
|
+ DrawWithResolution(outputWorkingSurface.DrawingSurface, renderOnto, context.ChunkResolution);
|
|
}
|
|
}
|
|
|
|
|
|
- protected internal virtual void DrawLayerOnTexture(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
|
|
|
|
|
|
+ protected internal virtual void DrawLayerOnTexture(SceneObjectRenderContext ctx,
|
|
|
|
+ DrawingSurface workingSurface,
|
|
bool useFilters)
|
|
bool useFilters)
|
|
{
|
|
{
|
|
int scaled = workingSurface.Canvas.Save();
|
|
int scaled = workingSurface.Canvas.Save();
|
|
@@ -83,7 +86,7 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
|
|
workingSurface.Canvas.RestoreToCount(scaled);
|
|
workingSurface.Canvas.RestoreToCount(scaled);
|
|
}
|
|
}
|
|
|
|
|
|
- private void DrawWithResolution(DrawingSurface source, DrawingSurface target, ChunkResolution resolution, VecI size)
|
|
|
|
|
|
+ private void DrawWithResolution(DrawingSurface source, DrawingSurface target, ChunkResolution resolution)
|
|
{
|
|
{
|
|
int scaled = target.Canvas.Save();
|
|
int scaled = target.Canvas.Save();
|
|
float multiplier = (float)resolution.InvertedMultiplier();
|
|
float multiplier = (float)resolution.InvertedMultiplier();
|
|
@@ -96,20 +99,42 @@ public abstract class LayerNode : StructureNode, IReadOnlyLayerNode, IClipSource
|
|
|
|
|
|
protected abstract VecI GetTargetSize(RenderContext ctx);
|
|
protected abstract VecI GetTargetSize(RenderContext ctx);
|
|
|
|
|
|
- protected internal virtual void DrawLayerInScene(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
|
|
|
|
|
|
+ protected internal virtual void DrawLayerInScene(SceneObjectRenderContext ctx,
|
|
|
|
+ DrawingSurface workingSurface,
|
|
bool useFilters = true)
|
|
bool useFilters = true)
|
|
{
|
|
{
|
|
DrawLayerOnto(ctx, workingSurface, useFilters);
|
|
DrawLayerOnto(ctx, workingSurface, useFilters);
|
|
}
|
|
}
|
|
|
|
|
|
- protected void DrawLayerOnto(SceneObjectRenderContext ctx, DrawingSurface workingSurface, bool useFilters)
|
|
|
|
|
|
+ protected void DrawLayerOnto(SceneObjectRenderContext ctx, DrawingSurface workingSurface,
|
|
|
|
+ bool useFilters)
|
|
{
|
|
{
|
|
blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * ctx.Opacity * 255));
|
|
blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * ctx.Opacity * 255));
|
|
|
|
|
|
if (useFilters && Filters.Value != null)
|
|
if (useFilters && Filters.Value != null)
|
|
{
|
|
{
|
|
blendPaint.SetFilters(Filters.Value);
|
|
blendPaint.SetFilters(Filters.Value);
|
|
- DrawWithFilters(ctx, workingSurface, blendPaint);
|
|
|
|
|
|
+
|
|
|
|
+ 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
|
|
else
|
|
{
|
|
{
|