Browse Source

Minor code refactoring

pull/1058/head
Sergio Pedri 7 years ago
parent
commit
ef04d2f718
  1. 10
      src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs

10
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs

@ -275,10 +275,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
// Create a 0-filled buffer to use to store the result of the component convolutions // Create a 0-filled buffer to use to store the result of the component convolutions
using (Buffer2D<Vector4> processingBuffer = this.Configuration.MemoryAllocator.Allocate2D<Vector4>(source.Size(), AllocationOptions.Clean)) using (Buffer2D<Vector4> processingBuffer = this.Configuration.MemoryAllocator.Allocate2D<Vector4>(source.Size(), AllocationOptions.Clean))
using (Buffer2D<ComplexVector4> firstPassBuffer = this.Configuration.MemoryAllocator.Allocate2D<ComplexVector4>(source.Size()))
{ {
// Perform the 1D convolutions on all the kernel components and accumulate the results // Perform the 1D convolutions on all the kernel components and accumulate the results
this.OnFrameApplyCore(source, this.SourceRectangle, this.Configuration, processingBuffer, firstPassBuffer); this.OnFrameApplyCore(source, this.SourceRectangle, this.Configuration, processingBuffer);
// Apply the inverse gamma exposure pass, and write the final pixel data // Apply the inverse gamma exposure pass, and write the final pixel data
this.ApplyInverseGammaExposure(source.PixelBuffer, processingBuffer, this.SourceRectangle, this.Configuration); this.ApplyInverseGammaExposure(source.PixelBuffer, processingBuffer, this.SourceRectangle, this.Configuration);
@ -292,13 +291,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
/// <param name="sourceRectangle">The <see cref="Rectangle" /> structure that specifies the portion of the image object to draw.</param> /// <param name="sourceRectangle">The <see cref="Rectangle" /> structure that specifies the portion of the image object to draw.</param>
/// <param name="configuration">The configuration.</param> /// <param name="configuration">The configuration.</param>
/// <param name="processingBuffer">The buffer with the raw pixel data to use to aggregate the results of each convolution.</param> /// <param name="processingBuffer">The buffer with the raw pixel data to use to aggregate the results of each convolution.</param>
/// <param name="firstPassBuffer">The complex buffer to use for the first 1D convolution pass for each kernel.</param>
private void OnFrameApplyCore( private void OnFrameApplyCore(
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
Rectangle sourceRectangle, Rectangle sourceRectangle,
Configuration configuration, Configuration configuration,
Buffer2D<Vector4> processingBuffer, Buffer2D<Vector4> processingBuffer)
Buffer2D<ComplexVector4> firstPassBuffer) {
using (Buffer2D<ComplexVector4> firstPassBuffer = this.Configuration.MemoryAllocator.Allocate2D<ComplexVector4>(source.Size()))
{ {
// Perform two 1D convolutions for each component in the current instance // Perform two 1D convolutions for each component in the current instance
ref Complex64[] baseRef = ref MemoryMarshal.GetReference(this.kernels.AsSpan()); ref Complex64[] baseRef = ref MemoryMarshal.GetReference(this.kernels.AsSpan());
@ -315,6 +314,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
this.ApplyConvolution(processingBuffer, firstPassBuffer, interest, kernel, configuration, parameters.Z, parameters.W); this.ApplyConvolution(processingBuffer, firstPassBuffer, interest, kernel, configuration, parameters.Z, parameters.W);
} }
} }
}
/// <summary> /// <summary>
/// Applies the process to the specified portion of the specified <see cref="ImageFrame{TPixel}"/> at the specified location /// Applies the process to the specified portion of the specified <see cref="ImageFrame{TPixel}"/> at the specified location

Loading…
Cancel
Save