|
|
|
@ -43,12 +43,13 @@ namespace SixLabors.ImageSharp.Processing.Processors |
|
|
|
{ |
|
|
|
int width = source.Width; |
|
|
|
int height = source.Height; |
|
|
|
ParallelOptions parallelOptions = source.Configuration.ParallelOptions; |
|
|
|
|
|
|
|
using (var firstPassPixels = new PixelAccessor<TPixel>(width, height)) |
|
|
|
using (PixelAccessor<TPixel> sourcePixels = source.Lock()) |
|
|
|
{ |
|
|
|
this.ApplyConvolution(firstPassPixels, sourcePixels, source.Bounds(), this.KernelX); |
|
|
|
this.ApplyConvolution(sourcePixels, firstPassPixels, sourceRectangle, this.KernelY); |
|
|
|
this.ApplyConvolution(firstPassPixels, sourcePixels, source.Bounds(), this.KernelX, parallelOptions); |
|
|
|
this.ApplyConvolution(sourcePixels, firstPassPixels, sourceRectangle, this.KernelY, parallelOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -62,7 +63,13 @@ namespace SixLabors.ImageSharp.Processing.Processors |
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
|
|
|
|
/// </param>
|
|
|
|
/// <param name="kernel">The kernel operator.</param>
|
|
|
|
private void ApplyConvolution(PixelAccessor<TPixel> targetPixels, PixelAccessor<TPixel> sourcePixels, Rectangle sourceRectangle, Fast2DArray<float> kernel) |
|
|
|
/// <param name="parallelOptions">The parellel options</param>
|
|
|
|
private void ApplyConvolution( |
|
|
|
PixelAccessor<TPixel> targetPixels, |
|
|
|
PixelAccessor<TPixel> sourcePixels, |
|
|
|
Rectangle sourceRectangle, |
|
|
|
Fast2DArray<float> kernel, |
|
|
|
ParallelOptions parallelOptions) |
|
|
|
{ |
|
|
|
int kernelHeight = kernel.Height; |
|
|
|
int kernelWidth = kernel.Width; |
|
|
|
@ -79,7 +86,7 @@ namespace SixLabors.ImageSharp.Processing.Processors |
|
|
|
Parallel.For( |
|
|
|
startY, |
|
|
|
endY, |
|
|
|
this.ParallelOptions, |
|
|
|
parallelOptions, |
|
|
|
y => |
|
|
|
{ |
|
|
|
Span<TPixel> targetRow = targetPixels.GetRowSpan(y); |
|
|
|
|