- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 888
Rename Pixel Shader Extensions and Delegates #1096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            102 changes: 102 additions & 0 deletions
          
          102 
        
  src/ImageSharp/Processing/Extensions/Effects/PixelRowDelegateExtensions.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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 | ||
| { | ||
| /// <summary> | ||
| /// Defines extension methods that allow the application of user defined processing delegate to an <see cref="Image"/>. | ||
| /// </summary> | ||
| public static class PixelRowDelegateExtensions | ||
| { | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation) | ||
| => ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, PixelConversionModifiers modifiers) | ||
| => source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers)); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <param name="rectangle"> | ||
| /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. | ||
| /// </param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle) | ||
| => ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <param name="rectangle"> | ||
| /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. | ||
| /// </param> | ||
| /// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers) | ||
| => source.ApplyProcessor(new PixelRowDelegateProcessor(rowOperation, modifiers), rectangle); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation) | ||
| => ProcessPixelRowsAsVector4(source, rowOperation, PixelConversionModifiers.None); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation, PixelConversionModifiers modifiers) | ||
| => source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers)); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <param name="rectangle"> | ||
| /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. | ||
| /// </param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation, Rectangle rectangle) | ||
| => ProcessPixelRowsAsVector4(source, rowOperation, rectangle, PixelConversionModifiers.None); | ||
|  | ||
| /// <summary> | ||
| /// Applies a user defined processing delegate to the image. | ||
| /// </summary> | ||
| /// <param name="source">The image this method extends.</param> | ||
| /// <param name="rowOperation">The user defined processing delegate to use to modify image rows.</param> | ||
| /// <param name="rectangle"> | ||
| /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. | ||
| /// </param> | ||
| /// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param> | ||
| /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> | ||
| public static IImageProcessingContext ProcessPixelRowsAsVector4(this IImageProcessingContext source, PixelRowOperation<Point> rowOperation, Rectangle rectangle, PixelConversionModifiers modifiers) | ||
| => source.ApplyProcessor(new PositionAwarePixelRowDelegateProcessor(rowOperation, modifiers), rectangle); | ||
| } | ||
| } | 
        
          
          
            102 changes: 0 additions & 102 deletions
          
          102 
        
  src/ImageSharp/Processing/Extensions/Effects/PixelShaderExtensions.cs
  
  
      
      
   
        
      
      
    This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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 | ||
| { | ||
| /// <summary> | ||
| /// A <see langword="delegate"/> representing a user defined processing delegate to use to modify image rows. | ||
| /// </summary> | ||
| /// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param> | ||
| /// <remarks>The <see cref="Vector4.X"/>, <see cref="Vector4.Y"/>, <see cref="Vector4.Z"/>, and <see cref="Vector4.W"/> fields map the RGBA channels respectively.</remarks> | ||
| public delegate void PixelRowOperation(Span<Vector4> span); | ||
|  | ||
| /// <summary> | ||
| /// A <see langword="delegate"/> representing a user defined processing delegate to use to modify image rows. | ||
| /// </summary> | ||
| /// <typeparam name="T"> | ||
| /// 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. | ||
| /// </typeparam> | ||
| /// <param name="span">The target row of <see cref="Vector4"/> pixels to process.</param> | ||
| /// <param name="value">The parameter of the method that this delegate encapsulates.</param> | ||
| /// <remarks>The <see cref="Vector4.X"/>, <see cref="Vector4.Y"/>, <see cref="Vector4.Z"/>, and <see cref="Vector4.W"/> fields map the RGBA channels respectively.</remarks> | ||
| public delegate void PixelRowOperation<in T>(Span<Vector4> span, T value); | ||
| } | ||
This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  
        
          
          
            39 changes: 39 additions & 0 deletions
          
          39 
        
  src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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 | ||
| { | ||
| /// <summary> | ||
| /// Applies a user defined row processing delegate to the image. | ||
| /// </summary> | ||
| internal sealed class PixelRowDelegateProcessor : IImageProcessor | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="PixelRowDelegateProcessor"/> class. | ||
| /// </summary> | ||
| /// <param name="pixelRowOperation">The user defined, row processing delegate.</param> | ||
| /// <param name="modifiers">The <see cref="PixelConversionModifiers"/> to apply during the pixel conversions.</param> | ||
| public PixelRowDelegateProcessor(PixelRowOperation pixelRowOperation, PixelConversionModifiers modifiers) | ||
| { | ||
| this.PixelRowOperation = pixelRowOperation; | ||
| this.Modifiers = modifiers; | ||
| } | ||
|  | ||
| /// <summary> | ||
| /// Gets the user defined row processing delegate to the image. | ||
| /// </summary> | ||
| public PixelRowOperation PixelRowOperation { get; } | ||
|  | ||
| /// <summary> | ||
| /// Gets the <see cref="PixelConversionModifiers"/> to apply during the pixel conversions. | ||
| /// </summary> | ||
| public PixelConversionModifiers Modifiers { get; } | ||
|  | ||
| /// <inheritdoc /> | ||
| public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle) | ||
| where TPixel : struct, IPixel<TPixel> | ||
| => new PixelRowDelegateProcessor<TPixel>(configuration, this, source, sourceRectangle); | ||
| } | ||
| } | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.