Browse Source

Minor code refactoring

af/merge-core
Sergio Pedri 6 years ago
parent
commit
ec2f72df4f
  1. 5
      src/ImageSharp/Processing/Extensions/PixelShaderExtensions.cs
  2. 8
      src/ImageSharp/Processing/Processors/PixelShading/PixelShaderProcessor.cs
  3. 8
      src/ImageSharp/Processing/Processors/PixelShading/PixelShaderProcessor{TPixel}.cs

5
src/ImageSharp/Processing/Extensions/PixelShaderExtensions.cs

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Processing.Delegates;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Processors.PixelShading;
using SixLabors.Primitives;
@ -20,7 +19,7 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="pixelShader">The user defined pixel shader to use to modify images.</param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader)
=> source.ApplyProcessor(new DelegatePixelShaderProcessor(pixelShader));
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader));
/// <summary>
/// Applies a user defined pixel shader to the image.
@ -32,6 +31,6 @@ namespace SixLabors.ImageSharp.Processing
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
public static IImageProcessingContext BlackWhite(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle)
=> source.ApplyProcessor(new DelegatePixelShaderProcessor(pixelShader), rectangle);
=> source.ApplyProcessor(new PixelShaderProcessor(pixelShader), rectangle);
}
}

8
src/ImageSharp/Processing/Processors/PixelShading/DelegatePixelShaderProcessor.cs → src/ImageSharp/Processing/Processors/PixelShading/PixelShaderProcessor.cs

@ -10,15 +10,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.PixelShading
/// <summary>
/// Applies a user defined pixel shader effect through a given delegate.
/// </summary>
public sealed class DelegatePixelShaderProcessor : IImageProcessor
public sealed class PixelShaderProcessor : IImageProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="DelegatePixelShaderProcessor"/> class.
/// Initializes a new instance of the <see cref="PixelShaderProcessor"/> class.
/// </summary>
/// <param name="pixelShader">
/// The user defined pixel shader to use to modify images.
/// </param>
public DelegatePixelShaderProcessor(PixelShader pixelShader)
public PixelShaderProcessor(PixelShader pixelShader)
{
this.PixelShader = pixelShader;
}
@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.PixelShading
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Image<TPixel> source, Rectangle sourceRectangle)
where TPixel : struct, IPixel<TPixel>
{
return new DelegatePixelShaderProcessor<TPixel>(this, source, sourceRectangle);
return new PixelShaderProcessor<TPixel>(this, source, sourceRectangle);
}
}
}

8
src/ImageSharp/Processing/Processors/PixelShading/DelegatePixelShaderProcessor{TPixel}.cs → src/ImageSharp/Processing/Processors/PixelShading/PixelShaderProcessor{TPixel}.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.PixelShading
/// Applies a user defined pixel shader effect through a given delegate.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class DelegatePixelShaderProcessor<TPixel> : ImageProcessor<TPixel>
internal class PixelShaderProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
@ -25,12 +25,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.PixelShading
private readonly PixelShader pixelShader;
/// <summary>
/// Initializes a new instance of the <see cref="DelegatePixelShaderProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="PixelShaderProcessor{TPixel}"/> class.
/// </summary>
/// <param name="definition">The <see cref="DelegatePixelShaderProcessor"/> defining the processor parameters.</param>
/// <param name="definition">The <see cref="PixelShaderProcessor"/> defining the processor parameters.</param>
/// <param name="source">The source <see cref="Image{TPixel}"/> for the current processor instance.</param>
/// <param name="sourceRectangle">The source area to process for the current processor instance.</param>
public DelegatePixelShaderProcessor(DelegatePixelShaderProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
public PixelShaderProcessor(PixelShaderProcessor definition, Image<TPixel> source, Rectangle sourceRectangle)
: base(source, sourceRectangle)
{
this.pixelShader = definition.PixelShader;
Loading…
Cancel
Save