diff --git a/src/ImageSharp/Processing/Extensions/Effects/PixelRowDelegateExtensions.cs b/src/ImageSharp/Processing/Extensions/Effects/PixelRowDelegateExtensions.cs new file mode 100644 index 0000000000..b622141b73 --- /dev/null +++ b/src/ImageSharp/Processing/Extensions/Effects/PixelRowDelegateExtensions.cs @@ -0,0 +1,102 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Processors.Effects; + +namespace SixLabors.ImageSharp.Processing +{ + /// + /// Defines extension methods that allow the application of user defined processing delegate to an . + /// + public static class PixelRowDelegateExtensions + { + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation) + => ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers)); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle) + => ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers), rectangle); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation) + => ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers)); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle) + => ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None); + + /// + /// Applies a user defined processing delegate to the image. + /// + /// The image this method extends. + /// The user defined processing delegate to use to modify image rows. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The to apply during the pixel conversions. + /// The to allow chaining of operations. + public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers) + => source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers), rectangle); + } +} diff --git a/src/ImageSharp/Processing/Extensions/Effects/PixelShaderExtensions.cs b/src/ImageSharp/Processing/Extensions/Effects/PixelShaderExtensions.cs deleted file mode 100644 index 00fd542672..0000000000 --- a/src/ImageSharp/Processing/Extensions/Effects/PixelShaderExtensions.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors.Effects; - -namespace SixLabors.ImageSharp.Processing -{ - /// - /// Defines extension methods that allow the application of user defined pixel shaders to an . - /// - public static class PixelShaderExtensions - { - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader) - => source.ApplyProcessor(new PixelShaderProcessor(pixelShader)); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// The to apply during the pixel conversions. - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, PixelConversionModifiers modifiers) - => source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers)); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle) - => source.ApplyProcessor(new PixelShaderProcessor(pixelShader), rectangle); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The to apply during the pixel conversions. - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers) - => source.ApplyProcessor(new PixelShaderProcessor(pixelShader, modifiers), rectangle); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader) - => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader)); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// The to apply during the pixel conversions. - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers) - => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers)); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle) - => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader), rectangle); - - /// - /// Applies a user defined pixel shader to the image. - /// - /// The image this method extends. - /// The user defined pixel shader to use to modify images. - /// - /// The structure that specifies the portion of the image object to alter. - /// - /// The to apply during the pixel conversions. - /// The to allow chaining of operations. - public static IImageProcessingContext ApplyPixelShaderProcessor(this IImageProcessingContext source, PositionAwarePixelShader pixelShader, Rectangle rectangle, PixelConversionModifiers modifiers) - => source.ApplyProcessor(new PositionAwarePixelShaderProcessor(pixelShader, modifiers), rectangle); - } -} diff --git a/src/ImageSharp/Processing/PixelRowOperation.cs b/src/ImageSharp/Processing/PixelRowOperation.cs new file mode 100644 index 0000000000..6857b24f19 --- /dev/null +++ b/src/ImageSharp/Processing/PixelRowOperation.cs @@ -0,0 +1,27 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Numerics; + +namespace SixLabors.ImageSharp.Processing +{ + /// + /// A representing a user defined processing delegate to use to modify image rows. + /// + /// The target row of pixels to process. + /// The , , , and fields map the RGBA channels respectively. + public delegate void PixelRowOperation(Span span); + + /// + /// A representing a user defined processing delegate to use to modify image rows. + /// + /// + /// The type of the parameter of the method that this delegate encapsulates. + /// This type parameter is contravariant.That is, you can use either the type you specified or any type that is less derived. + /// + /// The target row of pixels to process. + /// The parameter of the method that this delegate encapsulates. + /// The , , , and fields map the RGBA channels respectively. + public delegate void PixelRowOperation(Span span, T value); +} diff --git a/src/ImageSharp/Processing/PixelShader.cs b/src/ImageSharp/Processing/PixelShader.cs deleted file mode 100644 index 0245931fb5..0000000000 --- a/src/ImageSharp/Processing/PixelShader.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Numerics; - -namespace SixLabors.ImageSharp.Processing -{ - /// - /// A representing a user defined pixel shader. - /// - /// The target row of pixels to process. - /// The , , , and fields map the RGBA channels respectively. - public delegate void PixelShader(Span span); -} diff --git a/src/ImageSharp/Processing/PositionAwarePixelShader.cs b/src/ImageSharp/Processing/PositionAwarePixelShader.cs deleted file mode 100644 index c87d3ada6b..0000000000 --- a/src/ImageSharp/Processing/PositionAwarePixelShader.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using System; -using System.Numerics; - -namespace SixLabors.ImageSharp.Processing -{ - /// - /// A representing a user defined pixel shader. - /// - /// The target row of pixels to process. - /// The initial horizontal and vertical offset for the input pixels to process. - /// The , , , and fields map the RGBA channels respectively. - public delegate void PositionAwarePixelShader(Span span, Point offset); -} diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs new file mode 100644 index 0000000000..5bdc0bc80b --- /dev/null +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs @@ -0,0 +1,39 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Processors.Effects +{ + /// + /// Applies a user defined row processing delegate to the image. + /// + internal sealed class PixelRowDelegateProcessor : IImageProcessor + { + /// + /// Initializes a new instance of the class. + /// + /// The user defined, row processing delegate. + /// The to apply during the pixel conversions. + public PixelRowDelegateProcessor(PixelRowOperation pixelRowOperation, PixelConversionModifiers modifiers) + { + this.PixelRowOperation = pixelRowOperation; + this.Modifiers = modifiers; + } + + /// + /// Gets the user defined row processing delegate to the image. + /// + public PixelRowOperation PixelRowOperation { get; } + + /// + /// Gets the to apply during the pixel conversions. + /// + public PixelConversionModifiers Modifiers { get; } + + /// + public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) + where TPixel : struct, IPixel + => new PixelRowDelegateProcessor(configuration, this, source, sourceRectangle); + } +} diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs similarity index 76% rename from src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs rename to src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs index 681f44651f..019509dc23 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessorBase.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs @@ -3,7 +3,6 @@ using System; using System.Numerics; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced.ParallelUtils; using SixLabors.ImageSharp.PixelFormats; @@ -11,10 +10,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects { /// - /// Applies a user defined pixel shader effect through a given delegate. + /// The base class for all processors that accept a user defined row processing delegate. /// /// The pixel format. - internal abstract class PixelShaderProcessorBase : ImageProcessor + internal abstract class PixelRowDelegateProcessorBase : ImageProcessor where TPixel : struct, IPixel { /// @@ -23,17 +22,15 @@ internal abstract class PixelShaderProcessorBase : ImageProcessor - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The configuration which allows altering default behaviour or extending the library. /// The to apply during the pixel conversions. /// The source for the current processor instance. /// The source area to process for the current processor instance. - protected PixelShaderProcessorBase(Configuration configuration, PixelConversionModifiers modifiers, Image source, Rectangle sourceRectangle) + protected PixelRowDelegateProcessorBase(Configuration configuration, PixelConversionModifiers modifiers, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) - { - this.modifiers = modifiers; - } + => this.modifiers = modifiers; /// protected override void OnFrameApply(ImageFrame source) @@ -55,8 +52,8 @@ protected override void OnFrameApply(ImageFrame source) Span rowSpan = source.GetPixelRowSpan(y).Slice(startX, length); PixelOperations.Instance.ToVector4(configuration, rowSpan, vectorSpan, modifiers); - // Run the user defined pixel shader on the current row of pixels - this.ApplyPixelShader(vectorSpan, new Point(startX, y)); + // Run the user defined pixel shader to the current row of pixels + this.ApplyPixelRowDelegate(vectorSpan, new Point(startX, y)); PixelOperations.Instance.FromVector4Destructive(configuration, vectorSpan, rowSpan, modifiers); } @@ -64,10 +61,10 @@ protected override void OnFrameApply(ImageFrame source) } /// - /// Applies the current pixel shader effect on a target row of preprocessed pixels. + /// Applies the current pixel row delegate to a target row of preprocessed pixels. /// /// The target row of pixels to process. /// The initial horizontal and vertical offset for the input pixels to process. - protected abstract void ApplyPixelShader(Span span, Point offset); + protected abstract void ApplyPixelRowDelegate(Span span, Point offset); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel}.cs similarity index 53% rename from src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs rename to src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel}.cs index 244cfe3a70..da917eaf39 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel}.cs @@ -9,31 +9,31 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects { /// - /// Applies a user defined pixel shader effect through a given delegate. + /// Applies a user defined row processing delegate to the image. /// /// The pixel format. - internal sealed class PixelShaderProcessor : PixelShaderProcessorBase + internal sealed class PixelRowDelegateProcessor : PixelRowDelegateProcessorBase where TPixel : struct, IPixel { /// - /// The user defined pixel shader. + /// The user defined pixel row processing delegate. /// - private readonly PixelShader pixelShader; + private readonly PixelRowOperation pixelRowOperation; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The configuration which allows altering default behaviour or extending the library. - /// The defining the processor parameters. + /// The defining the processor parameters. /// The source for the current processor instance. /// The source area to process for the current processor instance. - public PixelShaderProcessor(Configuration configuration, PixelShaderProcessor definition, Image source, Rectangle sourceRectangle) + public PixelRowDelegateProcessor(Configuration configuration, PixelRowDelegateProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, definition.Modifiers, source, sourceRectangle) { - this.pixelShader = definition.PixelShader; + this.pixelRowOperation = definition.PixelRowOperation; } /// - protected override void ApplyPixelShader(Span span, Point offset) => this.pixelShader(span); + protected override void ApplyPixelRowDelegate(Span span, Point offset) => this.pixelRowOperation(span); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs deleted file mode 100644 index fef80dfc46..0000000000 --- a/src/ImageSharp/Processing/Processors/Effects/PixelShaderProcessor.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors.Effects -{ - /// - /// Applies a user defined pixel shader effect through a given delegate. - /// - public sealed class PixelShaderProcessor : IImageProcessor - { - /// - /// The default to apply during the pixel conversions. - /// - public const PixelConversionModifiers DefaultModifiers = PixelConversionModifiers.None; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The user defined pixel shader to use to modify images. - /// - public PixelShaderProcessor(PixelShader pixelShader) - { - this.PixelShader = pixelShader; - this.Modifiers = DefaultModifiers; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The user defined pixel shader to use to modify images. - /// - /// The to apply during the pixel conversions. - public PixelShaderProcessor(PixelShader pixelShader, PixelConversionModifiers modifiers) - { - this.PixelShader = pixelShader; - this.Modifiers = modifiers; - } - - /// - /// Gets the user defined pixel shader. - /// - public PixelShader PixelShader { get; } - - /// - /// Gets the to apply during the pixel conversions. - /// - public PixelConversionModifiers Modifiers { get; } - - /// - public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel - => new PixelShaderProcessor(configuration, this, source, sourceRectangle); - } -} diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs new file mode 100644 index 0000000000..bf21f5b9b1 --- /dev/null +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs @@ -0,0 +1,39 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Processing.Processors.Effects +{ + /// + /// Applies a user defined, position aware, row processing delegate to the image. + /// + internal sealed class PositionAwarePixelRowDelegateProcessor : IImageProcessor + { + /// + /// Initializes a new instance of the class. + /// + /// The user defined, position aware, row processing delegate. + /// The to apply during the pixel conversions. + public PositionAwarePixelRowDelegateProcessor(PixelRowOperation pixelRowOperation, PixelConversionModifiers modifiers) + { + this.PixelRowOperation = pixelRowOperation; + this.Modifiers = modifiers; + } + + /// + /// Gets the user defined, position aware, row processing delegate. + /// + public PixelRowOperation PixelRowOperation { get; } + + /// + /// Gets the to apply during the pixel conversions. + /// + public PixelConversionModifiers Modifiers { get; } + + /// + public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) + where TPixel : struct, IPixel + => new PositionAwarePixelRowDelegateProcessor(configuration, this, source, sourceRectangle); + } +} diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor{TPixel}.cs similarity index 57% rename from src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs rename to src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor{TPixel}.cs index a539b5105f..901a3a9856 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor{TPixel}.cs @@ -9,31 +9,28 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects { /// - /// Applies a user defined pixel shader effect through a given delegate. + /// Applies a user defined, position aware, row processing delegate to the image. /// /// The pixel format. - internal sealed class PositionAwarePixelShaderProcessor : PixelShaderProcessorBase + internal sealed class PositionAwarePixelRowDelegateProcessor : PixelRowDelegateProcessorBase where TPixel : struct, IPixel { - /// - /// The user defined pixel shader. - /// - private readonly PositionAwarePixelShader pixelShader; + private readonly PixelRowOperation pixelRowOperation; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The configuration which allows altering default behaviour or extending the library. - /// The defining the processor parameters. + /// The defining the processor parameters. /// The source for the current processor instance. /// The source area to process for the current processor instance. - public PositionAwarePixelShaderProcessor(Configuration configuration, PositionAwarePixelShaderProcessor definition, Image source, Rectangle sourceRectangle) + public PositionAwarePixelRowDelegateProcessor(Configuration configuration, PositionAwarePixelRowDelegateProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, definition.Modifiers, source, sourceRectangle) { - this.pixelShader = definition.PixelShader; + this.pixelRowOperation = definition.PixelRowOperation; } /// - protected override void ApplyPixelShader(Span span, Point offset) => this.pixelShader(span, offset); + protected override void ApplyPixelRowDelegate(Span span, Point offset) => this.pixelRowOperation(span, offset); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs deleted file mode 100644 index 7494f6ffc0..0000000000 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelShaderProcessor.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.PixelFormats; - -namespace SixLabors.ImageSharp.Processing.Processors.Effects -{ - /// - /// Applies a user defined pixel shader effect through a given delegate. - /// - public sealed class PositionAwarePixelShaderProcessor : IImageProcessor - { - /// - /// The default to apply during the pixel conversions. - /// - public const PixelConversionModifiers DefaultModifiers = PixelConversionModifiers.None; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The user defined pixel shader to use to modify images. - /// - public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader) - { - this.PixelShader = pixelShader; - this.Modifiers = DefaultModifiers; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The user defined pixel shader to use to modify images. - /// - /// The to apply during the pixel conversions. - public PositionAwarePixelShaderProcessor(PositionAwarePixelShader pixelShader, PixelConversionModifiers modifiers) - { - this.PixelShader = pixelShader; - this.Modifiers = modifiers; - } - - /// - /// Gets the user defined pixel shader. - /// - public PositionAwarePixelShader PixelShader { get; } - - /// - /// Gets the to apply during the pixel conversions. - /// - public PixelConversionModifiers Modifiers { get; } - - /// - public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) - where TPixel : struct, IPixel - => new PositionAwarePixelShaderProcessor(configuration, this, source, sourceRectangle); - } -} diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index c18f043852..00a45a94e1 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -20,7 +20,7 @@ public void FullImage(TestImageProvider provider) where TPixel : struct, IPixel { provider.RunValidatingProcessorTest( - x => x.ApplyPixelShaderProcessor( + x => x.ProcessPixelRowsAsVector4( span => { for (int i = 0; i < span.Length; i++) @@ -39,7 +39,7 @@ public void InBox(TestImageProvider provider) where TPixel : struct, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest( - (x, rect) => x.ApplyPixelShaderProcessor( + (x, rect) => x.ProcessPixelRowsAsVector4( span => { for (int i = 0; i < span.Length; i++) @@ -57,7 +57,7 @@ public void PositionAwareFullImage(TestImageProvider provider) where TPixel : struct, IPixel { provider.RunValidatingProcessorTest( - c => c.ApplyPixelShaderProcessor( + c => c.ProcessPixelRowsAsVector4( (span, offset) => { int y = offset.Y; @@ -87,7 +87,7 @@ public void PositionAwareInBox(TestImageProvider provider) where TPixel : struct, IPixel { provider.RunRectangleConstrainedValidatingProcessorTest( - (c, rect) => c.ApplyPixelShaderProcessor( + (c, rect) => c.ProcessPixelRowsAsVector4( (span, offset) => { int y = offset.Y;