|
@@ -25,17 +25,19 @@ public class ApplyFilterNode : RenderNode, IRenderInput
|
|
public RenderInputProperty Background { get; }
|
|
public RenderInputProperty Background { get; }
|
|
|
|
|
|
public RenderInputProperty Mask { get; }
|
|
public RenderInputProperty Mask { get; }
|
|
|
|
+
|
|
|
|
+ public InputProperty<bool> InvertMask { get; }
|
|
|
|
|
|
public ApplyFilterNode()
|
|
public ApplyFilterNode()
|
|
{
|
|
{
|
|
Background = CreateRenderInput("Input", "IMAGE");
|
|
Background = CreateRenderInput("Input", "IMAGE");
|
|
Filter = CreateInput<Filter>("Filter", "FILTER", null);
|
|
Filter = CreateInput<Filter>("Filter", "FILTER", null);
|
|
Mask = CreateRenderInput("Mask", "MASK");
|
|
Mask = CreateRenderInput("Mask", "MASK");
|
|
|
|
+ InvertMask = CreateInput("InvertMask", "INVERT_MASK", false);
|
|
Output.FirstInChain = null;
|
|
Output.FirstInChain = null;
|
|
AllowHighDpiRendering = true;
|
|
AllowHighDpiRendering = true;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
protected override void Paint(RenderContext context, DrawingSurface surface)
|
|
protected override void Paint(RenderContext context, DrawingSurface surface)
|
|
{
|
|
{
|
|
AllowHighDpiRendering = (Background.Connection.Node as RenderNode)?.AllowHighDpiRendering ?? true;
|
|
AllowHighDpiRendering = (Background.Connection.Node as RenderNode)?.AllowHighDpiRendering ?? true;
|
|
@@ -105,6 +107,7 @@ public class ApplyFilterNode : RenderNode, IRenderInput
|
|
|
|
|
|
private void ApplyWithMask(RenderContext context, DrawingSurface processedSurface, DrawingSurface finalSurface)
|
|
private void ApplyWithMask(RenderContext context, DrawingSurface processedSurface, DrawingSurface finalSurface)
|
|
{
|
|
{
|
|
|
|
+ _maskPaint.BlendMode = !InvertMask.Value ? BlendMode.DstIn : BlendMode.DstOut;
|
|
var maskLayer = processedSurface.Canvas.SaveLayer(_maskPaint);
|
|
var maskLayer = processedSurface.Canvas.SaveLayer(_maskPaint);
|
|
Mask.Value?.Paint(context, processedSurface);
|
|
Mask.Value?.Paint(context, processedSurface);
|
|
processedSurface.Canvas.RestoreToCount(maskLayer);
|
|
processedSurface.Canvas.RestoreToCount(maskLayer);
|