diff --git a/src/ImageSharp/Advanced/IRowIntervalAction.cs b/src/ImageSharp/Advanced/IRowIntervalOperation.cs similarity index 81% rename from src/ImageSharp/Advanced/IRowIntervalAction.cs rename to src/ImageSharp/Advanced/IRowIntervalOperation.cs index a24cda320..9aa79e730 100644 --- a/src/ImageSharp/Advanced/IRowIntervalAction.cs +++ b/src/ImageSharp/Advanced/IRowIntervalOperation.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Advanced /// /// Defines the contract for an action that operates on a row interval. /// - public interface IRowIntervalAction + public interface IRowIntervalOperation { /// /// Invokes the method passing the row interval. @@ -40,13 +40,13 @@ namespace SixLabors.ImageSharp.Advanced } } - internal readonly struct WrappingRowIntervalAction + internal readonly struct WrappingRowIntervalOperation { private readonly WrappingRowIntervalInfo info; private readonly Action action; [MethodImpl(InliningOptions.ShortMethod)] - public WrappingRowIntervalAction(in WrappingRowIntervalInfo info, Action action) + public WrappingRowIntervalOperation(in WrappingRowIntervalInfo info, Action action) { this.info = info; this.action = action; @@ -69,17 +69,17 @@ namespace SixLabors.ImageSharp.Advanced } } - internal readonly struct WrappingRowIntervalAction - where T : struct, IRowIntervalAction + internal readonly struct WrappingRowIntervalOperation + where T : struct, IRowIntervalOperation { private readonly WrappingRowIntervalInfo info; - private readonly T action; + private readonly T operation; [MethodImpl(InliningOptions.ShortMethod)] - public WrappingRowIntervalAction(in WrappingRowIntervalInfo info, in T action) + public WrappingRowIntervalOperation(in WrappingRowIntervalInfo info, in T operation) { this.info = info; - this.action = action; + this.operation = operation; } [MethodImpl(InliningOptions.ShortMethod)] @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Advanced var rows = new RowInterval(yMin, yMax); // Skip the safety copy when invoking a potentially impure method on a readonly field - Unsafe.AsRef(this.action).Invoke(in rows); + Unsafe.AsRef(this.operation).Invoke(in rows); } } } diff --git a/src/ImageSharp/Advanced/IRowIntervalAction{TBuffer}.cs b/src/ImageSharp/Advanced/IRowIntervalOperation{TBuffer}.cs similarity index 83% rename from src/ImageSharp/Advanced/IRowIntervalAction{TBuffer}.cs rename to src/ImageSharp/Advanced/IRowIntervalOperation{TBuffer}.cs index 89ef2ab44..18ebc9fb9 100644 --- a/src/ImageSharp/Advanced/IRowIntervalAction{TBuffer}.cs +++ b/src/ImageSharp/Advanced/IRowIntervalOperation{TBuffer}.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Advanced /// Defines the contract for an action that operates on a row interval with a temporary buffer. /// /// The type of buffer elements. - public interface IRowIntervalAction + public interface IRowIntervalOperation where TBuffer : unmanaged { /// @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Advanced void Invoke(in RowInterval rows, Memory memory); } - internal readonly struct WrappingRowIntervalBufferAction + internal readonly struct WrappingRowIntervalBufferOperation where TBuffer : unmanaged { private readonly WrappingRowIntervalInfo info; @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Advanced private readonly Action> action; [MethodImpl(InliningOptions.ShortMethod)] - public WrappingRowIntervalBufferAction( + public WrappingRowIntervalBufferOperation( in WrappingRowIntervalInfo info, MemoryAllocator allocator, Action> action) @@ -59,23 +59,23 @@ namespace SixLabors.ImageSharp.Advanced } } - internal readonly struct WrappingRowIntervalBufferAction - where T : struct, IRowIntervalAction + internal readonly struct WrappingRowIntervalBufferOperation + where T : struct, IRowIntervalOperation where TBuffer : unmanaged { private readonly WrappingRowIntervalInfo info; private readonly MemoryAllocator allocator; - private readonly T action; + private readonly T operation; [MethodImpl(InliningOptions.ShortMethod)] - public WrappingRowIntervalBufferAction( + public WrappingRowIntervalBufferOperation( in WrappingRowIntervalInfo info, MemoryAllocator allocator, - in T action) + in T operation) { this.info = info; this.allocator = allocator; - this.action = action; + this.operation = operation; } [MethodImpl(InliningOptions.ShortMethod)] @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Advanced using IMemoryOwner buffer = this.allocator.Allocate(this.info.MaxX); - Unsafe.AsRef(this.action).Invoke(in rows, buffer.Memory); + Unsafe.AsRef(this.operation).Invoke(in rows, buffer.Memory); } } } diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.cs b/src/ImageSharp/Advanced/ParallelRowIterator.cs index 5c8a30f68..beef99c1c 100644 --- a/src/ImageSharp/Advanced/ParallelRowIterator.cs +++ b/src/ImageSharp/Advanced/ParallelRowIterator.cs @@ -5,7 +5,6 @@ using System; using System.Buffers; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.Advanced @@ -21,13 +20,13 @@ namespace SixLabors.ImageSharp.Advanced /// /// Iterate through the rows of a rectangle in optimized batches defined by -s. /// - /// The type of row action to perform. + /// The type of row operation to perform. /// The . /// The to get the parallel settings from. /// The method body defining the iteration logic on a single . [MethodImpl(InliningOptions.ShortMethod)] public static void IterateRows(Rectangle rectangle, Configuration configuration, in T body) - where T : struct, IRowIntervalAction + where T : struct, IRowIntervalOperation { var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRows(rectangle, in parallelSettings, in body); @@ -36,15 +35,15 @@ namespace SixLabors.ImageSharp.Advanced /// /// Iterate through the rows of a rectangle in optimized batches defined by -s. /// - /// The type of row action to perform. + /// The type of row operation to perform. /// The . /// The . - /// The method body defining the iteration logic on a single . + /// The method body defining the iteration logic on a single . public static void IterateRows( Rectangle rectangle, in ParallelExecutionSettings parallelSettings, - in T body) - where T : struct, IRowIntervalAction + in T operation) + where T : struct, IRowIntervalOperation { ValidateRectangle(rectangle); @@ -60,14 +59,14 @@ namespace SixLabors.ImageSharp.Advanced if (numOfSteps == 1) { var rows = new RowInterval(top, bottom); - Unsafe.AsRef(body).Invoke(in rows); + Unsafe.AsRef(operation).Invoke(in rows); return; } int verticalStep = DivideCeil(rectangle.Height, numOfSteps); var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; var rowInfo = new WrappingRowIntervalInfo(top, bottom, verticalStep); - var rowAction = new WrappingRowIntervalAction(in rowInfo, in body); + var rowAction = new WrappingRowIntervalOperation(in rowInfo, in operation); Parallel.For( 0, @@ -78,30 +77,35 @@ namespace SixLabors.ImageSharp.Advanced /// /// Iterate through the rows of a rectangle in optimized batches defined by -s - /// instantiating a temporary buffer for each invocation. + /// instantiating a temporary buffer for each invocation. /// - /// The type of row action to perform. + /// The type of row operation to perform. /// The type of buffer elements. /// The . /// The to get the parallel settings from. - /// The method body defining the iteration logic on a single . - public static void IterateRows(Rectangle rectangle, Configuration configuration, in T body) - where T : struct, IRowIntervalAction + /// The method body defining the iteration logic on a single . + public static void IterateRows(Rectangle rectangle, Configuration configuration, in T operation) + where T : struct, IRowIntervalOperation where TBuffer : unmanaged { var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); - IterateRows(rectangle, in parallelSettings, in body); + IterateRows(rectangle, in parallelSettings, in operation); } /// /// Iterate through the rows of a rectangle in optimized batches defined by -s - /// instantiating a temporary buffer for each invocation. + /// instantiating a temporary buffer for each invocation. /// - internal static void IterateRows( + /// The type of row operation to perform. + /// The type of buffer elements. + /// The . + /// The . + /// The method body defining the iteration logic on a single . + public static void IterateRows( Rectangle rectangle, in ParallelExecutionSettings parallelSettings, - in T body) - where T : struct, IRowIntervalAction + in T operation) + where T : struct, IRowIntervalOperation where TBuffer : unmanaged { ValidateRectangle(rectangle); @@ -121,7 +125,7 @@ namespace SixLabors.ImageSharp.Advanced var rows = new RowInterval(top, bottom); using (IMemoryOwner buffer = allocator.Allocate(width)) { - Unsafe.AsRef(body).Invoke(rows, buffer.Memory); + Unsafe.AsRef(operation).Invoke(rows, buffer.Memory); } return; @@ -130,13 +134,13 @@ namespace SixLabors.ImageSharp.Advanced int verticalStep = DivideCeil(height, numOfSteps); var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; var rowInfo = new WrappingRowIntervalInfo(top, bottom, verticalStep, width); - var rowAction = new WrappingRowIntervalBufferAction(in rowInfo, allocator, in body); + var rowOperation = new WrappingRowIntervalBufferOperation(in rowInfo, allocator, in operation); Parallel.For( 0, numOfSteps, parallelOptions, - rowAction.Invoke); + rowOperation.Invoke); } /// @@ -183,7 +187,7 @@ namespace SixLabors.ImageSharp.Advanced int verticalStep = DivideCeil(rectangle.Height, numOfSteps); var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; var rowInfo = new WrappingRowIntervalInfo(top, bottom, verticalStep); - var rowAction = new WrappingRowIntervalAction(in rowInfo, body); + var rowAction = new WrappingRowIntervalOperation(in rowInfo, body); Parallel.For( 0, @@ -242,7 +246,7 @@ namespace SixLabors.ImageSharp.Advanced int verticalStep = DivideCeil(rectangle.Height, numOfSteps); var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; var rowInfo = new WrappingRowIntervalInfo(top, bottom, verticalStep, width); - var rowAction = new WrappingRowIntervalBufferAction(in rowInfo, allocator, body); + var rowAction = new WrappingRowIntervalBufferOperation(in rowInfo, allocator, body); Parallel.For( 0, diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index c3bab8e65..e3dbad505 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -263,7 +263,7 @@ namespace SixLabors.ImageSharp ParallelRowIterator.IterateRows( this.Bounds(), configuration, - new RowIntervalAction(this, target, configuration)); + new RowIntervalOperation(this, target, configuration)); return target; } @@ -289,7 +289,7 @@ namespace SixLabors.ImageSharp /// /// A implementing the clone logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation where TPixel2 : struct, IPixel { private readonly ImageFrame source; @@ -297,7 +297,7 @@ namespace SixLabors.ImageSharp private readonly Configuration configuration; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( ImageFrame source, ImageFrame target, Configuration configuration) diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index 9e9dccc46..129edbb03 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -54,13 +54,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization ParallelRowIterator.IterateRows( workingRect, configuration, - new RowIntervalAction(source, upper, lower, threshold, startX, endX, isAlphaOnly)); + new RowIntervalOperation(source, upper, lower, threshold, startX, endX, isAlphaOnly)); } /// /// A implementing the clone logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly ImageFrame source; private readonly TPixel upper; @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization private readonly bool isAlphaOnly; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( ImageFrame source, TPixel upper, TPixel lower, diff --git a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs index 834120f84..3fb62ed19 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs @@ -268,10 +268,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution protected override void OnFrameApply(ImageFrame source) { // Preliminary gamma highlight pass - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( this.SourceRectangle, this.Configuration, - new ApplyGammaExposureRowIntervalAction(this.SourceRectangle, source.PixelBuffer, this.Configuration, this.gamma)); + new ApplyGammaExposureRowIntervalOperation(this.SourceRectangle, source.PixelBuffer, this.Configuration, this.gamma)); // Create a 0-filled buffer to use to store the result of the component convolutions using Buffer2D processingBuffer = this.Configuration.MemoryAllocator.Allocate2D(source.Size(), AllocationOptions.Clean); @@ -285,7 +285,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution ParallelRowIterator.IterateRows( this.SourceRectangle, this.Configuration, - new ApplyInverseGammaExposureRowIntervalAction(this.SourceRectangle, source.PixelBuffer, processingBuffer, this.Configuration, inverseGamma)); + new ApplyInverseGammaExposureRowIntervalOperation(this.SourceRectangle, source.PixelBuffer, processingBuffer, this.Configuration, inverseGamma)); } /// @@ -317,20 +317,20 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution ParallelRowIterator.IterateRows( sourceRectangle, configuration, - new ApplyVerticalConvolutionRowIntervalAction(ref sourceRectangle, firstPassBuffer, source.PixelBuffer, kernel)); + new ApplyVerticalConvolutionRowIntervalOperation(ref sourceRectangle, firstPassBuffer, source.PixelBuffer, kernel)); // Compute the horizontal 1D convolutions and accumulate the partial results on the target buffer ParallelRowIterator.IterateRows( sourceRectangle, configuration, - new ApplyHorizontalConvolutionRowIntervalAction(ref sourceRectangle, processingBuffer, firstPassBuffer, kernel, parameters.Z, parameters.W)); + new ApplyHorizontalConvolutionRowIntervalOperation(ref sourceRectangle, processingBuffer, firstPassBuffer, kernel, parameters.Z, parameters.W)); } } /// /// A implementing the vertical convolution logic for . /// - private readonly struct ApplyVerticalConvolutionRowIntervalAction : IRowIntervalAction + private readonly struct ApplyVerticalConvolutionRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Buffer2D targetValues; @@ -340,7 +340,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly int maxX; [MethodImpl(InliningOptions.ShortMethod)] - public ApplyVerticalConvolutionRowIntervalAction( + public ApplyVerticalConvolutionRowIntervalOperation( ref Rectangle bounds, Buffer2D targetValues, Buffer2D sourcePixels, @@ -373,7 +373,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// A implementing the horizontal convolution logic for . /// - private readonly struct ApplyHorizontalConvolutionRowIntervalAction : IRowIntervalAction + private readonly struct ApplyHorizontalConvolutionRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Buffer2D targetValues; @@ -385,7 +385,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly int maxX; [MethodImpl(InliningOptions.ShortMethod)] - public ApplyHorizontalConvolutionRowIntervalAction( + public ApplyHorizontalConvolutionRowIntervalOperation( ref Rectangle bounds, Buffer2D targetValues, Buffer2D sourceValues, @@ -422,7 +422,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// A implementing the gamma exposure logic for . /// - private readonly struct ApplyGammaExposureRowIntervalAction : IRowIntervalAction + private readonly struct ApplyGammaExposureRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Buffer2D targetPixels; @@ -430,7 +430,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly float gamma; [MethodImpl(InliningOptions.ShortMethod)] - public ApplyGammaExposureRowIntervalAction( + public ApplyGammaExposureRowIntervalOperation( Rectangle bounds, Buffer2D targetPixels, Configuration configuration, @@ -471,7 +471,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// A implementing the inverse gamma exposure logic for . /// - private readonly struct ApplyInverseGammaExposureRowIntervalAction : IRowIntervalAction + private readonly struct ApplyInverseGammaExposureRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Buffer2D targetPixels; @@ -480,7 +480,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly float inverseGamma; [MethodImpl(InliningOptions.ShortMethod)] - public ApplyInverseGammaExposureRowIntervalAction( + public ApplyInverseGammaExposureRowIntervalOperation( Rectangle bounds, Buffer2D targetPixels, Buffer2D sourceValues, diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs index cd550a335..0340482fe 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs @@ -66,10 +66,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, this.Configuration, - new RowIntervalAction(interest, targetPixels, source.PixelBuffer, this.KernelY, this.KernelX, this.Configuration, this.PreserveAlpha)); + new RowIntervalOperation(interest, targetPixels, source.PixelBuffer, this.KernelY, this.KernelX, this.Configuration, this.PreserveAlpha)); Buffer2D.SwapOrCopyContent(source.PixelBuffer, targetPixels); } @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly int maxY; @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly bool preserveAlpha; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Rectangle bounds, Buffer2D targetPixels, Buffer2D sourcePixels, diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs index 1be97a4f8..3cbbf8c46 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs @@ -64,22 +64,22 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); // Horizontal convolution - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, this.Configuration, - new RowIntervalAction(interest, firstPassPixels, source.PixelBuffer, this.KernelX, this.Configuration, this.PreserveAlpha)); + new RowIntervalOperation(interest, firstPassPixels, source.PixelBuffer, this.KernelX, this.Configuration, this.PreserveAlpha)); // Vertical convolution - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, this.Configuration, - new RowIntervalAction(interest, source.PixelBuffer, firstPassPixels, this.KernelY, this.Configuration, this.PreserveAlpha)); + new RowIntervalOperation(interest, source.PixelBuffer, firstPassPixels, this.KernelY, this.Configuration, this.PreserveAlpha)); } /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Buffer2D targetPixels; @@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly bool preserveAlpha; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Rectangle bounds, Buffer2D targetPixels, Buffer2D sourcePixels, diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs index b68dc56e0..2774a2f88 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs @@ -57,10 +57,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, this.Configuration, - new RowIntervalAction(interest, targetPixels, source.PixelBuffer, this.KernelXY, this.Configuration, this.PreserveAlpha)); + new RowIntervalOperation(interest, targetPixels, source.PixelBuffer, this.KernelXY, this.Configuration, this.PreserveAlpha)); Buffer2D.SwapOrCopyContent(source.PixelBuffer, targetPixels); } @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly int maxY; @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly bool preserveAlpha; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Rectangle bounds, Buffer2D targetPixels, Buffer2D sourcePixels, diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs index e2480957e..f390ee1ff 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs @@ -105,14 +105,14 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution ParallelRowIterator.IterateRows( Rectangle.FromLTRB(minX, minY, maxX, maxY), this.Configuration, - new RowIntervalAction(source.PixelBuffer, pass.PixelBuffer, minX, maxX, shiftY, shiftX)); + new RowIntervalOperation(source.PixelBuffer, pass.PixelBuffer, minX, maxX, shiftY, shiftX)); } } /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Buffer2D targetPixels; private readonly Buffer2D passPixels; @@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution private readonly int shiftX; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Buffer2D targetPixels, Buffer2D passPixels, int minX, diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index 2a181174c..88fa6bec3 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -102,13 +102,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing ParallelRowIterator.IterateRows( workingRect, configuration, - new RowIntervalAction(source, targetImage, blender, configuration, minX, width, locationY, targetX, this.Opacity)); + new RowIntervalOperation(source, targetImage, blender, configuration, minX, width, locationY, targetX, this.Opacity)); } /// /// A implementing the draw logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly ImageFrame sourceFrame; private readonly Image targetImage; @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing private readonly float opacity; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( ImageFrame sourceFrame, Image targetImage, PixelBlender blender, diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index 4abaf7ac4..1c3be4e63 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects ParallelRowIterator.IterateRows( this.SourceRectangle, this.Configuration, - new RowIntervalAction(this.SourceRectangle, targetPixels, source, this.Configuration, brushSize >> 1, this.definition.Levels)); + new RowIntervalOperation(this.SourceRectangle, targetPixels, source, this.Configuration, brushSize >> 1, this.definition.Levels)); Buffer2D.SwapOrCopyContent(source.PixelBuffer, targetPixels); } @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Buffer2D targetPixels; @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects private readonly int levels; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Rectangle bounds, Buffer2D targetPixels, ImageFrame source, diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs index fd725d3ba..3f8dcd8d9 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs @@ -51,16 +51,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects { var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, this.Configuration, - new RowIntervalAction(interest.X, source, this.Configuration, this.modifiers, this.rowDelegate)); + new RowIntervalOperation(interest.X, source, this.Configuration, this.modifiers, this.rowDelegate)); } /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly int startX; private readonly ImageFrame source; @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects private readonly TDelegate rowProcessor; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( int startX, ImageFrame source, Configuration configuration, diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs index e541b0d68..157ac7df1 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor{TPixel}.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading.Tasks; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; @@ -29,9 +28,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects /// The source area to process for the current processor instance. public PixelateProcessor(Configuration configuration, PixelateProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) - { - this.definition = definition; - } + => this.definition = definition; private int Size => this.definition.Size; @@ -51,10 +48,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects Parallel.ForEach( range, this.Configuration.GetParallelOptions(), - new RowAction(interest, size, source).Invoke); + new RowOperation(interest, size, source).Invoke); } - private readonly struct RowAction + private readonly struct RowOperation { private readonly int minX; private readonly int maxX; @@ -66,7 +63,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects private readonly ImageFrame source; [MethodImpl(InliningOptions.ShortMethod)] - public RowAction( + public RowOperation( Rectangle bounds, int size, ImageFrame source) diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs index cdb67e48b..159a1f981 100644 --- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs @@ -37,16 +37,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters { var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, this.Configuration, - new RowIntervalAction(interest.X, source, this.definition.Matrix, this.Configuration)); + new RowIntervalOperation(interest.X, source, this.definition.Matrix, this.Configuration)); } /// /// A implementing the convolution logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly int startX; private readonly ImageFrame source; @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters private readonly Configuration configuration; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( int startX, ImageFrame source, ColorMatrix matrix, diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index b5b8cfe56..64aaa884b 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -7,8 +7,7 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Threading.Tasks; - +using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -81,56 +80,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization yStart += tileHeight; } - Parallel.For( - 0, - tileYStartPositions.Count, - new ParallelOptions { MaxDegreeOfParallelism = this.Configuration.MaxDegreeOfParallelism }, - index => - { - int y = tileYStartPositions[index].y; - int cdfYY = tileYStartPositions[index].cdfY; - - // It's unfortunate that we have to do this per iteration. - ref TPixel sourceBase = ref source.GetPixelReference(0, 0); - - int cdfX = 0; - int x = halfTileWidth; - for (int tile = 0; tile < tileCount - 1; tile++) - { - int tileY = 0; - int yEnd = Math.Min(y + tileHeight, sourceHeight); - int xEnd = Math.Min(x + tileWidth, sourceWidth); - for (int dy = y; dy < yEnd; dy++) - { - int dyOffSet = dy * sourceWidth; - int tileX = 0; - for (int dx = x; dx < xEnd; dx++) - { - ref TPixel pixel = ref Unsafe.Add(ref sourceBase, dyOffSet + dx); - float luminanceEqualized = InterpolateBetweenFourTiles( - pixel, - cdfData, - tileCount, - tileCount, - tileX, - tileY, - cdfX, - cdfYY, - tileWidth, - tileHeight, - luminanceLevels); - - pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); - tileX++; - } - - tileY++; - } - - cdfX++; - x += tileWidth; - } - }); + ParallelRowIterator.IterateRows( + new Rectangle(0, 0, sourceWidth, tileYStartPositions.Count), + this.Configuration, + new RowIntervalOperation(cdfData, tileYStartPositions, tileWidth, tileHeight, tileCount, halfTileWidth, luminanceLevels, source)); ref TPixel pixelsBase = ref source.GetPixelReference(0, 0); @@ -416,6 +369,95 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization private static float LinearInterpolation(float left, float right, float t) => left + ((right - left) * t); + private readonly struct RowIntervalOperation : IRowIntervalOperation + { + private readonly CdfTileData cdfData; + private readonly List<(int y, int cdfY)> tileYStartPositions; + private readonly int tileWidth; + private readonly int tileHeight; + private readonly int tileCount; + private readonly int halfTileWidth; + private readonly int luminanceLevels; + private readonly ImageFrame source; + private readonly int sourceWidth; + private readonly int sourceHeight; + + [MethodImpl(InliningOptions.ShortMethod)] + public RowIntervalOperation( + CdfTileData cdfData, + List<(int y, int cdfY)> tileYStartPositions, + int tileWidth, + int tileHeight, + int tileCount, + int halfTileWidth, + int luminanceLevels, + ImageFrame source) + { + this.cdfData = cdfData; + this.tileYStartPositions = tileYStartPositions; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.tileCount = tileCount; + this.halfTileWidth = halfTileWidth; + this.luminanceLevels = luminanceLevels; + this.source = source; + this.sourceWidth = source.Width; + this.sourceHeight = source.Height; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void Invoke(in RowInterval rows) + { + ref TPixel sourceBase = ref this.source.GetPixelReference(0, 0); + + for (int index = rows.Min; index < rows.Max; index++) + { + (int y, int cdfY) tileYStartPosition = this.tileYStartPositions[index]; + int y = tileYStartPosition.y; + int cdfYY = tileYStartPosition.cdfY; + + int cdfX = 0; + int x = this.halfTileWidth; + for (int tile = 0; tile < this.tileCount - 1; tile++) + { + int tileY = 0; + int yEnd = Math.Min(y + this.tileHeight, this.sourceHeight); + int xEnd = Math.Min(x + this.tileWidth, this.sourceWidth); + for (int dy = y; dy < yEnd; dy++) + { + int dyOffSet = dy * this.sourceWidth; + int tileX = 0; + for (int dx = x; dx < xEnd; dx++) + { + ref TPixel pixel = ref Unsafe.Add(ref sourceBase, dyOffSet + dx); + float luminanceEqualized = InterpolateBetweenFourTiles( + pixel, + this.cdfData, + this.tileCount, + this.tileCount, + tileX, + tileY, + cdfX, + cdfYY, + this.tileWidth, + this.tileHeight, + this.luminanceLevels); + + pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + tileX++; + } + + tileY++; + } + + cdfX++; + x += this.tileWidth; + } + } + } + } + /// /// Contains the results of the cumulative distribution function for all tiles. /// @@ -470,57 +512,21 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization public void CalculateLookupTables(ImageFrame source, HistogramEqualizationProcessor processor) { - int sourceWidth = this.sourceWidth; - int sourceHeight = this.sourceHeight; - int tileWidth = this.tileWidth; - int tileHeight = this.tileHeight; - int luminanceLevels = this.luminanceLevels; - - Parallel.For( - 0, - this.tileYStartPositions.Count, - new ParallelOptions { MaxDegreeOfParallelism = this.configuration.MaxDegreeOfParallelism }, - index => - { - int cdfX = 0; - int cdfY = this.tileYStartPositions[index].cdfY; - int y = this.tileYStartPositions[index].y; - int endY = Math.Min(y + tileHeight, sourceHeight); - ref TPixel sourceBase = ref source.GetPixelReference(0, 0); - ref int cdfMinBase = ref MemoryMarshal.GetReference(this.cdfMinBuffer2D.GetRowSpan(cdfY)); - - using (IMemoryOwner histogramBuffer = this.memoryAllocator.Allocate(luminanceLevels)) - { - Span histogram = histogramBuffer.GetSpan(); - ref int histogramBase = ref MemoryMarshal.GetReference(histogram); - - for (int x = 0; x < sourceWidth; x += tileWidth) - { - histogram.Clear(); - ref int cdfBase = ref MemoryMarshal.GetReference(this.GetCdfLutSpan(cdfX, index)); - - int xlimit = Math.Min(x + tileWidth, sourceWidth); - for (int dy = y; dy < endY; dy++) - { - int dyOffset = dy * sourceWidth; - for (int dx = x; dx < xlimit; dx++) - { - int luminance = GetLuminance(Unsafe.Add(ref sourceBase, dyOffset + dx), luminanceLevels); - histogram[luminance]++; - } - } - - if (processor.ClipHistogramEnabled) - { - processor.ClipHistogram(histogram, processor.ClipLimit); - } - - Unsafe.Add(ref cdfMinBase, cdfX) = processor.CalculateCdf(ref cdfBase, ref histogramBase, histogram.Length - 1); - - cdfX++; - } - } - }); + var rowOperation = new RowIntervalOperation( + processor, + this.memoryAllocator, + this.cdfMinBuffer2D, + this.cdfLutBuffer2D, + this.tileYStartPositions, + this.tileWidth, + this.tileHeight, + this.luminanceLevels, + source); + + ParallelRowIterator.IterateRows( + new Rectangle(0, 0, this.sourceWidth, this.tileYStartPositions.Count), + this.configuration, + in rowOperation); } [MethodImpl(InliningOptions.ShortMethod)] @@ -548,6 +554,93 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization this.cdfMinBuffer2D.Dispose(); this.cdfLutBuffer2D.Dispose(); } + + private readonly struct RowIntervalOperation : IRowIntervalOperation + { + private readonly HistogramEqualizationProcessor processor; + private readonly MemoryAllocator allocator; + private readonly Buffer2D cdfMinBuffer2D; + private readonly Buffer2D cdfLutBuffer2D; + private readonly List<(int y, int cdfY)> tileYStartPositions; + private readonly int tileWidth; + private readonly int tileHeight; + private readonly int luminanceLevels; + private readonly ImageFrame source; + private readonly int sourceWidth; + private readonly int sourceHeight; + + [MethodImpl(InliningOptions.ShortMethod)] + public RowIntervalOperation( + HistogramEqualizationProcessor processor, + MemoryAllocator allocator, + Buffer2D cdfMinBuffer2D, + Buffer2D cdfLutBuffer2D, + List<(int y, int cdfY)> tileYStartPositions, + int tileWidth, + int tileHeight, + int luminanceLevels, + ImageFrame source) + { + this.processor = processor; + this.allocator = allocator; + this.cdfMinBuffer2D = cdfMinBuffer2D; + this.cdfLutBuffer2D = cdfLutBuffer2D; + this.tileYStartPositions = tileYStartPositions; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.luminanceLevels = luminanceLevels; + this.source = source; + this.sourceWidth = source.Width; + this.sourceHeight = source.Height; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void Invoke(in RowInterval rows) + { + ref TPixel sourceBase = ref this.source.GetPixelReference(0, 0); + + for (int index = rows.Min; index < rows.Max; index++) + { + int cdfX = 0; + int cdfY = this.tileYStartPositions[index].cdfY; + int y = this.tileYStartPositions[index].y; + int endY = Math.Min(y + this.tileHeight, this.sourceHeight); + ref int cdfMinBase = ref MemoryMarshal.GetReference(this.cdfMinBuffer2D.GetRowSpan(cdfY)); + + using IMemoryOwner histogramBuffer = this.allocator.Allocate(this.luminanceLevels); + Span histogram = histogramBuffer.GetSpan(); + ref int histogramBase = ref MemoryMarshal.GetReference(histogram); + + for (int x = 0; x < this.sourceWidth; x += this.tileWidth) + { + histogram.Clear(); + Span cdfLutSpan = this.cdfLutBuffer2D.GetRowSpan(index).Slice(cdfX * this.luminanceLevels, this.luminanceLevels); + ref int cdfBase = ref MemoryMarshal.GetReference(cdfLutSpan); + + int xlimit = Math.Min(x + this.tileWidth, this.sourceWidth); + for (int dy = y; dy < endY; dy++) + { + int dyOffset = dy * this.sourceWidth; + for (int dx = x; dx < xlimit; dx++) + { + int luminance = GetLuminance(Unsafe.Add(ref sourceBase, dyOffset + dx), this.luminanceLevels); + histogram[luminance]++; + } + } + + if (this.processor.ClipHistogramEnabled) + { + this.processor.ClipHistogram(histogram, this.processor.ClipLimit); + } + + Unsafe.Add(ref cdfMinBase, cdfX) = this.processor.CalculateCdf(ref cdfBase, ref histogramBase, histogram.Length - 1); + + cdfX++; + } + } + } + } } } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index 5d25bae82..38da9c8d4 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization ParallelRowIterator.IterateRows( workingRect, this.Configuration, - new GrayscaleLevelsRowIntervalAction(workingRect, histogramBuffer, source, this.LuminanceLevels)); + new GrayscaleLevelsRowIntervalOperation(workingRect, histogramBuffer, source, this.LuminanceLevels)); Span histogram = histogramBuffer.GetSpan(); if (this.ClipHistogramEnabled) @@ -77,13 +77,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization ParallelRowIterator.IterateRows( workingRect, this.Configuration, - new CdfApplicationRowIntervalAction(workingRect, cdfBuffer, source, this.LuminanceLevels, numberOfPixelsMinusCdfMin)); + new CdfApplicationRowIntervalOperation(workingRect, cdfBuffer, source, this.LuminanceLevels, numberOfPixelsMinusCdfMin)); } /// /// A implementing the grayscale levels logic for . /// - private readonly struct GrayscaleLevelsRowIntervalAction : IRowIntervalAction + private readonly struct GrayscaleLevelsRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly IMemoryOwner histogramBuffer; @@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization private readonly int luminanceLevels; [MethodImpl(InliningOptions.ShortMethod)] - public GrayscaleLevelsRowIntervalAction( + public GrayscaleLevelsRowIntervalOperation( in Rectangle bounds, IMemoryOwner histogramBuffer, ImageFrame source, @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization /// /// A implementing the cdf application levels logic for . /// - private readonly struct CdfApplicationRowIntervalAction : IRowIntervalAction + private readonly struct CdfApplicationRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly IMemoryOwner cdfBuffer; @@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization private readonly float numberOfPixelsMinusCdfMin; [MethodImpl(InliningOptions.ShortMethod)] - public CdfApplicationRowIntervalAction( + public CdfApplicationRowIntervalOperation( in Rectangle bounds, IMemoryOwner cdfBuffer, ImageFrame source, diff --git a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs index a9b91e837..f26e30e52 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs @@ -52,10 +52,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays ParallelRowIterator.IterateRows( interest, configuration, - new RowIntervalAction(configuration, interest, blender, amount, colors, source)); + new RowIntervalOperation(configuration, interest, blender, amount, colors, source)); } - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Configuration configuration; private readonly Rectangle bounds; @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays private readonly ImageFrame source; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Configuration configuration, Rectangle bounds, PixelBlender blender, diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs index 65a87fbf0..ccb2eed60 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs @@ -55,13 +55,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays using IMemoryOwner rowColors = allocator.Allocate(interest.Width); rowColors.GetSpan().Fill(glowColor); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, configuration, - new RowIntervalAction(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source)); + new RowIntervalOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source)); } - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Configuration configuration; private readonly Rectangle bounds; @@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays private readonly ImageFrame source; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Configuration configuration, Rectangle bounds, IMemoryOwner colors, diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index 11887433c..fd842766d 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -63,13 +63,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays using IMemoryOwner rowColors = allocator.Allocate(interest.Width); rowColors.GetSpan().Fill(vignetteColor); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( interest, configuration, - new RowIntervalAction(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source)); + new RowIntervalOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source)); } - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Configuration configuration; private readonly Rectangle bounds; @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays private readonly ImageFrame source; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Configuration configuration, Rectangle bounds, IMemoryOwner colors, diff --git a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs index 402a05249..85ac8dba5 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs @@ -61,23 +61,23 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( targetBounds, configuration, - new NearestNeighborRowIntervalAction(this.SourceRectangle, ref matrix, width, source, destination)); + new NearestNeighborRowIntervalOperation(this.SourceRectangle, ref matrix, width, source, destination)); return; } using var kernelMap = new TransformKernelMap(configuration, source.Size(), destination.Size(), this.resampler); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( targetBounds, configuration, - new RowIntervalAction(configuration, kernelMap, ref matrix, width, source, destination)); + new RowIntervalOperation(configuration, kernelMap, ref matrix, width, source, destination)); } /// /// A implementing the nearest neighbor resampler logic for . /// - private readonly struct NearestNeighborRowIntervalAction : IRowIntervalAction + private readonly struct NearestNeighborRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Matrix3x2 matrix; @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public NearestNeighborRowIntervalAction( + public NearestNeighborRowIntervalOperation( Rectangle bounds, ref Matrix3x2 matrix, int maxX, @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// A implementing the transformation logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Configuration configuration; private readonly TransformKernelMap kernelMap; @@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Configuration configuration, TransformKernelMap kernelMap, ref Matrix3x2 matrix, diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index 103c5d3ff..d8c77e8e7 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(this.Configuration).MultiplyMinimumPixelsPerTask(4); - var rowAction = new RowIntervalAction(ref bounds, source, destination); + var rowAction = new RowIntervalOperation(ref bounds, source, destination); ParallelRowIterator.IterateRows( bounds, @@ -62,20 +62,20 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms /// /// A implementing the processor logic for . /// - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly ImageFrame source; private readonly ImageFrame destination; /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The target processing bounds for the current instance. /// The source for the current instance. /// The destination for the current instance. [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction(ref Rectangle bounds, ImageFrame source, ImageFrame destination) + public RowIntervalOperation(ref Rectangle bounds, ImageFrame source, ImageFrame destination) { this.bounds = bounds; this.source = source; diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs index 041f602a5..58be1ef0c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs @@ -79,15 +79,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( source.Bounds(), configuration, - new RowIntervalAction(source)); + new RowIntervalOperation(source)); } - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly ImageFrame source; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction(ImageFrame source) => this.source = source; + public RowIntervalOperation(ImageFrame source) => this.source = source; [MethodImpl(InliningOptions.ShortMethod)] public void Invoke(in RowInterval rows) diff --git a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs index 5034b072f..4e5b87b84 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs @@ -63,20 +63,20 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( targetBounds, configuration, - new NearestNeighborRowIntervalAction(ref sourceBounds, ref matrix, width, source, destination)); + new NearestNeighborRowIntervalOperation(ref sourceBounds, ref matrix, width, source, destination)); return; } using var kernelMap = new TransformKernelMap(configuration, source.Size(), destination.Size(), this.resampler); - ParallelRowIterator.IterateRows( + ParallelRowIterator.IterateRows( targetBounds, configuration, - new RowIntervalAction(configuration, kernelMap, ref matrix, width, source, destination)); + new RowIntervalOperation(configuration, kernelMap, ref matrix, width, source, destination)); } - private readonly struct NearestNeighborRowIntervalAction : IRowIntervalAction + private readonly struct NearestNeighborRowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly Matrix4x4 matrix; @@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public NearestNeighborRowIntervalAction( + public NearestNeighborRowIntervalOperation( ref Rectangle bounds, ref Matrix4x4 matrix, int maxX, @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms } } - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Configuration configuration; private readonly TransformKernelMap kernelMap; @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Configuration configuration, TransformKernelMap kernelMap, ref Matrix4x4 matrix, diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index 02622622d..27a2cca51 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( interest, configuration, - new RowIntervalAction(sourceRectangle, this.targetRectangle, widthFactor, heightFactor, source, destination)); + new RowIntervalOperation(sourceRectangle, this.targetRectangle, widthFactor, heightFactor, source, destination)); return; } @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms base.Dispose(disposing); } - private readonly struct RowIntervalAction : IRowIntervalAction + private readonly struct RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle sourceBounds; private readonly Rectangle destinationBounds; @@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public RowIntervalAction( + public RowIntervalOperation( Rectangle sourceBounds, Rectangle destinationBounds, float widthFactor, diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs index bf03ce319..59cdf4f10 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs @@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( source.Bounds(), configuration, - new Rotate180RowIntervalAction(source.Width, source.Height, source, destination)); + new Rotate180RowIntervalOperation(source.Width, source.Height, source, destination)); } /// @@ -148,7 +148,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( source.Bounds(), configuration, - new Rotate270RowIntervalAction(destination.Bounds(), source.Width, source.Height, source, destination)); + new Rotate270RowIntervalOperation(destination.Bounds(), source.Width, source.Height, source, destination)); } /// @@ -162,10 +162,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms ParallelRowIterator.IterateRows( source.Bounds(), configuration, - new Rotate90RowIntervalAction(destination.Bounds(), source.Width, source.Height, source, destination)); + new Rotate90RowIntervalOperation(destination.Bounds(), source.Width, source.Height, source, destination)); } - private readonly struct Rotate180RowIntervalAction : IRowIntervalAction + private readonly struct Rotate180RowIntervalOperation : IRowIntervalOperation { private readonly int width; private readonly int height; @@ -173,7 +173,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public Rotate180RowIntervalAction( + public Rotate180RowIntervalOperation( int width, int height, ImageFrame source, @@ -201,7 +201,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms } } - private readonly struct Rotate270RowIntervalAction : IRowIntervalAction + private readonly struct Rotate270RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly int width; @@ -210,7 +210,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public Rotate270RowIntervalAction( + public Rotate270RowIntervalOperation( Rectangle bounds, int width, int height, @@ -245,7 +245,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms } } - private readonly struct Rotate90RowIntervalAction : IRowIntervalAction + private readonly struct Rotate90RowIntervalOperation : IRowIntervalOperation { private readonly Rectangle bounds; private readonly int width; @@ -254,7 +254,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms private readonly ImageFrame destination; [MethodImpl(InliningOptions.ShortMethod)] - public Rotate90RowIntervalAction( + public Rotate90RowIntervalOperation( Rectangle bounds, int width, int height,