// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Drawing.Processing { /// /// Identifies the kind of replay item stored in a drawing canvas timeline. /// internal enum DrawingCanvasTimelineEntryKind { /// /// A contiguous range of draw commands. /// CommandRange, /// /// An apply barrier. /// ApplyBarrier, /// /// An existing retained scene recorded through . /// Scene } /// /// Represents one ordered item in the canvas replay timeline. /// /// /// Command ranges reference contiguous draw commands; they are not backend scene objects yet. /// Apply barriers and retained scene references point into side buffers by index, keeping this /// type compact while preserving the exact order in which the canvas recorded replay work. /// internal readonly struct DrawingCanvasTimelineEntry { private DrawingCanvasTimelineEntry( DrawingCanvasTimelineEntryKind kind, int index, int count, bool hasLayers) { this.Kind = kind; this.Index = index; this.Count = count; this.HasLayers = hasLayers; } /// /// Gets the kind of replay item represented by this entry. /// public DrawingCanvasTimelineEntryKind Kind { get; } /// /// Gets the command start index for command ranges, or the side-buffer index for barriers and scenes. /// public int Index { get; } /// /// Gets the number of commands represented by a command-range entry. /// public int Count { get; } /// /// Gets a value indicating whether the command range contains layer boundary commands. /// public bool HasLayers { get; } /// /// Creates a command-range entry. /// /// The first command index. /// The command count. /// Indicates whether the command range contains layer boundary commands. /// The command-range entry. public static DrawingCanvasTimelineEntry CreateCommandRange(int startIndex, int count, bool hasLayers) => new(DrawingCanvasTimelineEntryKind.CommandRange, startIndex, count, hasLayers); /// /// Creates an apply-barrier entry. /// /// The apply-barrier index. /// The apply-barrier entry. public static DrawingCanvasTimelineEntry CreateApplyBarrier(int index) => new(DrawingCanvasTimelineEntryKind.ApplyBarrier, index, 0, false); /// /// Creates an entry for an existing retained scene recorded through . /// /// The retained-scene reference index. /// The retained-scene entry. public static DrawingCanvasTimelineEntry CreateScene(int index) => new(DrawingCanvasTimelineEntryKind.Scene, index, 0, false); } }