|
@@ -9,7 +9,7 @@ using PixiEditor.Numerics;
|
|
|
namespace PixiEditor.ChangeableDocument.Changeables.Graph.Nodes;
|
|
|
|
|
|
[NodeInfo("Folder")]
|
|
|
-public class FolderNode : StructureNode, IReadOnlyFolderNode
|
|
|
+public class FolderNode : StructureNode, IReadOnlyFolderNode, IClipSource
|
|
|
{
|
|
|
public RenderInputProperty Content { get; }
|
|
|
|
|
@@ -18,9 +18,9 @@ public class FolderNode : StructureNode, IReadOnlyFolderNode
|
|
|
Content = CreateRenderInput("Content", "CONTENT", ctx =>
|
|
|
{
|
|
|
RectD? bounds = new RectD(VecI.Zero, ctx.DocumentSize);
|
|
|
-
|
|
|
+
|
|
|
// Folder doesn't need to do anything if no operations are present
|
|
|
- if (bounds == null || !HasOperations())
|
|
|
+ if (bounds == null || (!HasOperations() && BlendMode.Value == Enums.BlendMode.Normal))
|
|
|
{
|
|
|
return Output.GetFirstRenderTarget(ctx);
|
|
|
}
|
|
@@ -33,109 +33,50 @@ public class FolderNode : StructureNode, IReadOnlyFolderNode
|
|
|
|
|
|
public override Node CreateCopy() => new FolderNode { MemberName = MemberName };
|
|
|
|
|
|
+ public override VecD ScenePosition => Content.Value?.DeviceClipBounds.Size / 2f ?? VecD.Zero;
|
|
|
+ public override VecD SceneSize => Content.Value?.DeviceClipBounds.Size ?? VecD.Zero;
|
|
|
|
|
|
- protected override void OnExecute(RenderContext context)
|
|
|
+ public override void Render(SceneObjectRenderContext sceneContext)
|
|
|
{
|
|
|
- base.OnExecute(context);
|
|
|
-
|
|
|
- /*if(Background.Value == null && Content.Value == null)
|
|
|
- {
|
|
|
- Output.Value = null;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ RectD bounds = RectD.Create(VecI.Zero, sceneContext.DocumentSize);
|
|
|
if (!IsVisible.Value || Opacity.Value <= 0 || IsEmptyMask())
|
|
|
{
|
|
|
- Output.Value = Background.Value;
|
|
|
+ Output.Value = sceneContext.RenderSurface;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- blendPaint.Color = new Color(255, 255, 255, 255);
|
|
|
- blendPaint.BlendMode = DrawingApi.Core.Surfaces.BlendMode.Src;
|
|
|
-
|
|
|
- if (Content.Value == null)
|
|
|
+ if (Content.Connection == null || (!HasOperations() && BlendMode.Value == Enums.BlendMode.Normal))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- VecI size = Content.Value?.Size ?? VecI.Zero;
|
|
|
-
|
|
|
- var outputWorkingSurface = RequestTexture(0, size);
|
|
|
- var filterlessWorkingSurface = RequestTexture(1, size);
|
|
|
-
|
|
|
- if (Background.Value != null)
|
|
|
- {
|
|
|
- DrawBackground(filterlessWorkingSurface.DrawingSurface, context);
|
|
|
- blendPaint.BlendMode = RenderingContext.GetDrawingBlendMode(BlendMode.Value);
|
|
|
- }
|
|
|
+ VecI size = (VecI)bounds.Size;
|
|
|
+ var outputWorkingSurface = RequestTexture(0, size, false);
|
|
|
|
|
|
- if (Content.Value != null)
|
|
|
+ if (RenderTarget.Value != null)
|
|
|
{
|
|
|
- blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * 255));
|
|
|
- DrawSurface(filterlessWorkingSurface.DrawingSurface, Content.Value, context, null);
|
|
|
+ blendPaint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
|
|
|
}
|
|
|
|
|
|
- FilterlessOutput.Value = filterlessWorkingSurface;
|
|
|
+ ApplyMaskIfPresent(outputWorkingSurface.DrawingSurface, sceneContext);
|
|
|
|
|
|
- if (!HasOperations())
|
|
|
+ if (RenderTarget.Value != null)
|
|
|
{
|
|
|
- if (Background.Value != null)
|
|
|
- {
|
|
|
- blendPaint.Color = new Color(255, 255, 255, 255);
|
|
|
- blendPaint.BlendMode = DrawingApi.Core.Surfaces.BlendMode.Src;
|
|
|
- DrawBackground(outputWorkingSurface.DrawingSurface, context);
|
|
|
- blendPaint.BlendMode = RenderingContext.GetDrawingBlendMode(BlendMode.Value);
|
|
|
- }
|
|
|
-
|
|
|
- if (Content.Value != null)
|
|
|
+ Texture tempSurface = RequestTexture(1, outputWorkingSurface.Size);
|
|
|
+ if (RenderTarget.Connection.Node is IClipSource clipSource)
|
|
|
{
|
|
|
- blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * 255));
|
|
|
- DrawSurface(outputWorkingSurface.DrawingSurface, Content.Value.DrawingSurface, context, Filters.Value);
|
|
|
+ DrawClipSource(tempSurface.DrawingSurface, clipSource, sceneContext);
|
|
|
}
|
|
|
|
|
|
- Output.Value = outputWorkingSurface.DrawingSurface;
|
|
|
- }
|
|
|
-
|
|
|
- if (Content.Value != null)
|
|
|
- {
|
|
|
- DrawSurface(outputWorkingSurface.DrawingSurface, Content.Value.DrawingSurface, context, Filters.Value);
|
|
|
-
|
|
|
- ApplyMaskIfPresent(outputWorkingSurface, context);
|
|
|
- }
|
|
|
-
|
|
|
- if (Background.Value != null)
|
|
|
- {
|
|
|
- Texture tempSurface = RequestTexture(2, outputWorkingSurface.Size);
|
|
|
- DrawBackground(tempSurface.DrawingSurface, context);
|
|
|
-
|
|
|
- ApplyRasterClip(outputWorkingSurface, tempSurface);
|
|
|
-
|
|
|
- blendPaint.Color = blendPaint.Color.WithAlpha((byte)Math.Round(Opacity.Value * 255));
|
|
|
- blendPaint.BlendMode = RenderingContext.GetDrawingBlendMode(BlendMode.Value);
|
|
|
+ ApplyRasterClip(outputWorkingSurface.DrawingSurface, tempSurface.DrawingSurface);
|
|
|
+ blendPaint.BlendMode = RenderContext.GetDrawingBlendMode(BlendMode.Value);
|
|
|
tempSurface.DrawingSurface.Canvas.DrawSurface(outputWorkingSurface.DrawingSurface, 0, 0, blendPaint);
|
|
|
|
|
|
- Output.Value = tempSurface.DrawingSurface;
|
|
|
+ sceneContext.RenderSurface.Canvas.DrawSurface(tempSurface.DrawingSurface, 0, 0, blendPaint);
|
|
|
+ outputWorkingSurface.DrawingSurface.Canvas.Clear();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- Output.Value = outputWorkingSurface.DrawingSurface;*/
|
|
|
- }
|
|
|
-
|
|
|
- public override VecD ScenePosition => Content.Value?.DeviceClipBounds.Size / 2f ?? VecD.Zero;
|
|
|
- public override VecD SceneSize => Content.Value?.DeviceClipBounds.Size ?? VecD.Zero;
|
|
|
-
|
|
|
- public override void Render(SceneObjectRenderContext sceneContext)
|
|
|
- {
|
|
|
- RectD bounds = RectD.Create(VecI.Zero, sceneContext.DocumentSize);
|
|
|
-
|
|
|
- if(Content.Connection == null || !HasOperations())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- VecI size = (VecI)bounds.Size;
|
|
|
- var outputWorkingSurface = RequestTexture(0, size, false);
|
|
|
-
|
|
|
sceneContext.RenderSurface.Canvas.DrawSurface(outputWorkingSurface.DrawingSurface, 0, 0, blendPaint);
|
|
|
outputWorkingSurface.DrawingSurface.Canvas.Clear();
|
|
|
}
|
|
@@ -206,4 +147,20 @@ public class FolderNode : StructureNode, IReadOnlyFolderNode
|
|
|
MaskIsVisible = MaskIsVisible
|
|
|
};
|
|
|
}*/
|
|
|
+ public void DrawOnTexture(SceneObjectRenderContext context, DrawingSurface drawOnto)
|
|
|
+ {
|
|
|
+ if (Content.Connection != null)
|
|
|
+ {
|
|
|
+ var executionQueue = GraphUtils.CalculateExecutionQueue(Content.Connection.Node);
|
|
|
+
|
|
|
+ while (executionQueue.Count > 0)
|
|
|
+ {
|
|
|
+ IReadOnlyNode node = executionQueue.Dequeue();
|
|
|
+ if (node is IClipSource clipSource)
|
|
|
+ {
|
|
|
+ clipSource.DrawOnTexture(context, drawOnto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|