Browse Source

Rename things

af/octree-no-pixelmap
James Jackson-South 6 years ago
parent
commit
fd9f3d6942
  1. 26
      src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs
  2. 8
      src/ImageSharp/Advanced/ParallelRowIterator.cs

26
src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs

@ -17,35 +17,35 @@ namespace SixLabors.ImageSharp.Advanced
/// </content>
public static partial class ParallelRowIterator
{
private readonly struct WrappingRowIntervalInfo
private readonly struct IterationParameters
{
public readonly int MinY;
public readonly int MaxY;
public readonly int StepY;
public readonly int MaxX;
public readonly int Width;
public WrappingRowIntervalInfo(int minY, int maxY, int stepY)
public IterationParameters(int minY, int maxY, int stepY)
: this(minY, maxY, stepY, 0)
{
}
public WrappingRowIntervalInfo(int minY, int maxY, int stepY, int maxX)
public IterationParameters(int minY, int maxY, int stepY, int width)
{
this.MinY = minY;
this.MaxY = maxY;
this.StepY = stepY;
this.MaxX = maxX;
this.Width = width;
}
}
private readonly struct WrappingRowIntervalOperation<T>
private readonly struct RowIntervalOperationWrapper<T>
where T : struct, IRowIntervalOperation
{
private readonly WrappingRowIntervalInfo info;
private readonly IterationParameters info;
private readonly T operation;
[MethodImpl(InliningOptions.ShortMethod)]
public WrappingRowIntervalOperation(in WrappingRowIntervalInfo info, in T operation)
public RowIntervalOperationWrapper(in IterationParameters info, in T operation)
{
this.info = info;
this.operation = operation;
@ -69,17 +69,17 @@ namespace SixLabors.ImageSharp.Advanced
}
}
private readonly struct WrappingRowIntervalBufferOperation<T, TBuffer>
private readonly struct RowIntervalOperationWrapper<T, TBuffer>
where T : struct, IRowIntervalOperation<TBuffer>
where TBuffer : unmanaged
{
private readonly WrappingRowIntervalInfo info;
private readonly IterationParameters info;
private readonly MemoryAllocator allocator;
private readonly T operation;
[MethodImpl(InliningOptions.ShortMethod)]
public WrappingRowIntervalBufferOperation(
in WrappingRowIntervalInfo info,
public RowIntervalOperationWrapper(
in IterationParameters info,
MemoryAllocator allocator,
in T operation)
{
@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Advanced
int yMax = Math.Min(yMin + this.info.StepY, this.info.MaxY);
var rows = new RowInterval(yMin, yMax);
using IMemoryOwner<TBuffer> buffer = this.allocator.Allocate<TBuffer>(this.info.MaxX);
using IMemoryOwner<TBuffer> buffer = this.allocator.Allocate<TBuffer>(this.info.Width);
Unsafe.AsRef(in this.operation).Invoke(in rows, buffer.Memory.Span);
}

8
src/ImageSharp/Advanced/ParallelRowIterator.cs

@ -65,8 +65,8 @@ namespace SixLabors.ImageSharp.Advanced
int verticalStep = DivideCeil(rectangle.Height, numOfSteps);
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
var info = new WrappingRowIntervalInfo(top, bottom, verticalStep);
var wrappingOperation = new WrappingRowIntervalOperation<T>(in info, in operation);
var info = new IterationParameters(top, bottom, verticalStep);
var wrappingOperation = new RowIntervalOperationWrapper<T>(in info, in operation);
Parallel.For(
0,
@ -133,8 +133,8 @@ namespace SixLabors.ImageSharp.Advanced
int verticalStep = DivideCeil(height, numOfSteps);
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps };
var info = new WrappingRowIntervalInfo(top, bottom, verticalStep, width);
var wrappingOperation = new WrappingRowIntervalBufferOperation<T, TBuffer>(in info, allocator, in operation);
var info = new IterationParameters(top, bottom, verticalStep, width);
var wrappingOperation = new RowIntervalOperationWrapper<T, TBuffer>(in info, allocator, in operation);
Parallel.For(
0,

Loading…
Cancel
Save