Browse Source

Refactored VignetteProcessor<TPixel>

pull/1574/head
Sergio Pedri 7 years ago
parent
commit
851f491aa1
  1. 13
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs

13
src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs

@ -63,14 +63,14 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
using IMemoryOwner<TPixel> rowColors = allocator.Allocate<TPixel>(interest.Width); using IMemoryOwner<TPixel> rowColors = allocator.Allocate<TPixel>(interest.Width);
rowColors.GetSpan().Fill(vignetteColor); rowColors.GetSpan().Fill(vignetteColor);
var operation = new RowIntervalOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source); var operation = new RowOperation(configuration, interest, rowColors, this.blender, center, maxDistance, blendPercent, source);
ParallelRowIterator.IterateRowIntervals<RowIntervalOperation, float>( ParallelRowIterator.IterateRows<RowOperation, float>(
configuration, configuration,
interest, interest,
in operation); in operation);
} }
private readonly struct RowIntervalOperation : IRowIntervalOperation<float> private readonly struct RowOperation : IRowOperation<float>
{ {
private readonly Configuration configuration; private readonly Configuration configuration;
private readonly Rectangle bounds; private readonly Rectangle bounds;
@ -82,7 +82,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
private readonly ImageFrame<TPixel> source; private readonly ImageFrame<TPixel> source;
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public RowIntervalOperation( public RowOperation(
Configuration configuration, Configuration configuration,
Rectangle bounds, Rectangle bounds,
IMemoryOwner<TPixel> colors, IMemoryOwner<TPixel> colors,
@ -103,12 +103,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
} }
[MethodImpl(InliningOptions.ShortMethod)] [MethodImpl(InliningOptions.ShortMethod)]
public void Invoke(in RowInterval rows, Span<float> span) public void Invoke(int y, Span<float> span)
{ {
Span<TPixel> colorSpan = this.colors.GetSpan(); Span<TPixel> colorSpan = this.colors.GetSpan();
for (int y = rows.Min; y < rows.Max; y++)
{
for (int i = 0; i < this.bounds.Width; i++) for (int i = 0; i < this.bounds.Width; i++)
{ {
float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y));
@ -127,4 +125,3 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
} }
} }
} }
}

Loading…
Cancel
Save