// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
#pragma warning disable SA1649 // Scene command types are grouped together in one file.
namespace SixLabors.ImageSharp.Drawing.Processing.Backends {
///
/// Visitor contract for one flush-scoped composition scene command.
///
public interface ICompositionSceneCommandVisitor
{
///
/// Visits one fill-path or layer-based composition command.
///
/// The command being visited.
public void Visit(PathCompositionSceneCommand command);
///
/// Visits one stroked path command.
///
/// The command being visited.
public void Visit(StrokePathCompositionSceneCommand command);
///
/// Visits one explicit stroked line-segment command.
///
/// The command being visited.
public void Visit(LineSegmentCompositionSceneCommand command);
///
/// Visits one explicit stroked polyline command.
///
/// The command being visited.
public void Visit(PolylineCompositionSceneCommand command);
}
///
/// Base type for one draw-order command in a flush-scoped scene stream.
///
public abstract class CompositionSceneCommand
{
///
/// Dispatches the command to a visitor without a per-item kind switch at the call site.
///
/// The visitor receiving the command.
public abstract void Accept(ICompositionSceneCommandVisitor visitor);
}
///
/// Scene command wrapper for fill-path and layer-based composition commands.
///
public sealed class PathCompositionSceneCommand : CompositionSceneCommand
{
///
/// Initializes a new instance of the class.
///
/// The wrapped composition command.
public PathCompositionSceneCommand(in CompositionCommand command)
=> this.Command = command;
///
/// Gets the wrapped composition command.
///
public CompositionCommand Command { get; internal set; }
///
public override void Accept(ICompositionSceneCommandVisitor visitor) => visitor.Visit(this);
}
///
/// Scene command wrapper for stroked path commands.
///
public sealed class StrokePathCompositionSceneCommand : CompositionSceneCommand
{
///
/// Initializes a new instance of the class.
///
/// The wrapped stroke path command.
public StrokePathCompositionSceneCommand(in StrokePathCommand command)
=> this.Command = command;
///
/// Gets the wrapped stroke path command.
///
public StrokePathCommand Command { get; internal set; }
///
public override void Accept(ICompositionSceneCommandVisitor visitor) => visitor.Visit(this);
}
///
/// Scene command wrapper for explicit stroked line-segment commands.
///
public sealed class LineSegmentCompositionSceneCommand : CompositionSceneCommand
{
///
/// Initializes a new instance of the class.
///
/// The wrapped stroke line-segment command.
public LineSegmentCompositionSceneCommand(in StrokeLineSegmentCommand command)
=> this.Command = command;
///
/// Gets the wrapped stroke line-segment command.
///
public StrokeLineSegmentCommand Command { get; }
///
public override void Accept(ICompositionSceneCommandVisitor visitor) => visitor.Visit(this);
}
///
/// Scene command wrapper for explicit stroked polyline commands.
///
public sealed class PolylineCompositionSceneCommand : CompositionSceneCommand
{
///
/// Initializes a new instance of the class.
///
/// The wrapped stroke polyline command.
public PolylineCompositionSceneCommand(in StrokePolylineCommand command)
=> this.Command = command;
///
/// Gets the wrapped stroke polyline command.
///
public StrokePolylineCommand Command { get; }
///
public override void Accept(ICompositionSceneCommandVisitor visitor) => visitor.Visit(this);
}
}