Skip to content

Commit

Permalink
Cleanup General Convolution (SixLabors#887)
Browse files Browse the repository at this point in the history
* Remove multiple premultiplication.

* Use in DenseMatrix everywhere.

* Make private

* Dont convert vector row on first pass

* Remove incorrectly assigned alpha.

* Remove boxing.

* Use correct min row.

* Reorder parameters

* Correctly handle alpha component.

* Update tests

* Use dedicated methods over branching.
  • Loading branch information
JimBobSquarePants authored Apr 25, 2019
1 parent 1576d3f commit a2308a6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/ImageSharp.Drawing/Processing/PatternBrush{TPixel}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public PatternBrush(TPixel foreColor, TPixel backColor, bool[,] pattern)
/// <param name="foreColor">Color of the fore.</param>
/// <param name="backColor">Color of the back.</param>
/// <param name="pattern">The pattern.</param>
internal PatternBrush(TPixel foreColor, TPixel backColor, DenseMatrix<bool> pattern)
internal PatternBrush(TPixel foreColor, TPixel backColor, in DenseMatrix<bool> pattern)
{
var foreColorVector = foreColor.ToVector4();
var backColorVector = backColor.ToVector4();
Expand Down Expand Up @@ -93,10 +93,7 @@ internal PatternBrush(PatternBrush<TPixel> brush)
}

/// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options)
{
return new PatternBrushApplicator(source, this.pattern, this.patternVector, options);
}
public BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options) => new PatternBrushApplicator(source, this.pattern, this.patternVector, options);

/// <summary>
/// The pattern brush applicator.
Expand All @@ -116,7 +113,7 @@ private class PatternBrushApplicator : BrushApplicator<TPixel>
/// <param name="pattern">The pattern.</param>
/// <param name="patternVector">The patternVector.</param>
/// <param name="options">The options</param>
public PatternBrushApplicator(ImageFrame<TPixel> source, DenseMatrix<TPixel> pattern, DenseMatrix<Vector4> patternVector, GraphicsOptions options)
public PatternBrushApplicator(ImageFrame<TPixel> source, in DenseMatrix<TPixel> pattern, DenseMatrix<Vector4> patternVector, GraphicsOptions options)
: base(source, options)
{
this.pattern = pattern;
Expand Down

0 comments on commit a2308a6

Please sign in to comment.