Browse Source

Refactored AffineTransformProcessor<TPixel>

pull/1574/head
Sergio Pedri 7 years ago
parent
commit
a71bcd2a21
  1. 19
      src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs

19
src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs

@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
if (sampler is NearestNeighborResampler) if (sampler is NearestNeighborResampler)
{ {
var nnOperation = new NNAffineOperation(source, destination, matrix); var nnOperation = new NNAffineOperation(source, destination, matrix);
ParallelRowIterator.IterateRowIntervals( ParallelRowIterator.IterateRows(
configuration, configuration,
destination.Bounds(), destination.Bounds(),
in nnOperation); in nnOperation);
@ -105,13 +105,13 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
radialExtents, radialExtents,
maxSourceExtents); maxSourceExtents);
ParallelRowIterator.IterateRowIntervals<AffineOperation<TResampler>, Vector4>( ParallelRowIterator.IterateRows<AffineOperation<TResampler>, Vector4>(
configuration, configuration,
destination.Bounds(), destination.Bounds(),
in operation); in operation);
} }
private readonly struct NNAffineOperation : IRowIntervalOperation private readonly struct NNAffineOperation : IRowOperation
{ {
private readonly ImageFrame<TPixel> source; private readonly ImageFrame<TPixel> source;
private readonly ImageFrame<TPixel> destination; private readonly ImageFrame<TPixel> destination;
@ -133,9 +133,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
} }
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void Invoke(in RowInterval rows) public void Invoke(int y)
{
for (int y = rows.Min; y < rows.Max; y++)
{ {
Span<TPixel> destRow = this.destination.GetPixelRowSpan(y); Span<TPixel> destRow = this.destination.GetPixelRowSpan(y);
@ -152,9 +150,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
} }
} }
} }
}
private readonly struct AffineOperation<TResampler> : IRowIntervalOperation<Vector4> private readonly struct AffineOperation<TResampler> : IRowOperation<Vector4>
where TResampler : struct, IResampler where TResampler : struct, IResampler
{ {
private readonly Configuration configuration; private readonly Configuration configuration;
@ -193,11 +190,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
} }
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void Invoke(in RowInterval rows, Span<Vector4> span) public void Invoke(int y, Span<Vector4> span)
{ {
Buffer2D<TPixel> sourceBuffer = this.source.PixelBuffer; Buffer2D<TPixel> sourceBuffer = this.source.PixelBuffer;
for (int y = rows.Min; y < rows.Max; y++)
{
PixelOperations<TPixel>.Instance.ToVector4( PixelOperations<TPixel>.Instance.ToVector4(
this.configuration, this.configuration,
this.destination.GetPixelRowSpan(y), this.destination.GetPixelRowSpan(y),
@ -231,4 +227,3 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
} }
} }
} }
}

Loading…
Cancel
Save