Browse Source

Revert changes from 692c35b166ca7a18680b5efa6cd863ee48e01e11: "Switched to vectorized pixel conversions"

af/octree-no-pixelmap
Brian Popow 6 years ago
parent
commit
c542dffd08
  1. 18
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs

18
src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs

@ -63,16 +63,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
source.CopyTo(targetPixels); source.CopyTo(targetPixels);
var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY); var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY);
ParallelHelper.IterateRowsWithTempBuffer<Vector4>( ParallelHelper.IterateRows(
workingRect, workingRect,
this.Configuration, this.Configuration,
(rows, vectorBuffer) => (rows) =>
{ {
Span<Vector4> vectorSpan = vectorBuffer.Span; // Rent the shared buffer only once per parallel item.
int length = vectorSpan.Length;
ref Vector4 vectorSpanRef = ref MemoryMarshal.GetReference(vectorSpan);
// Rent the shared buffer only once per parallel item
using (IMemoryOwner<float> bins = configuration.MemoryAllocator.Allocate<float>(levels * 4)) using (IMemoryOwner<float> bins = configuration.MemoryAllocator.Allocate<float>(levels * 4))
{ {
ref float binsRef = ref bins.GetReference(); ref float binsRef = ref bins.GetReference();
@ -84,8 +80,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
for (int y = rows.Min; y < rows.Max; y++) for (int y = rows.Min; y < rows.Max; y++)
{ {
Span<TPixel> sourceRow = source.GetPixelRowSpan(y); Span<TPixel> sourceRow = source.GetPixelRowSpan(y);
Span<TPixel> targetRowSpan = targetPixels.GetRowSpan(y).Slice(startX, length); Span<TPixel> targetRow = targetPixels.GetRowSpan(y);
PixelOperations<TPixel>.Instance.ToVector4(configuration, targetRowSpan, vectorSpan);
for (int x = startX; x < endX; x++) for (int x = startX; x < endX; x++)
{ {
@ -135,11 +130,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
float green = MathF.Abs(Unsafe.Add(ref greenBinRef, maxIndex) / maxIntensity); float green = MathF.Abs(Unsafe.Add(ref greenBinRef, maxIndex) / maxIntensity);
float alpha = sourceRow[x].ToVector4().W; float alpha = sourceRow[x].ToVector4().W;
Unsafe.Add(ref vectorSpanRef, x) = new Vector4(red, green, blue, alpha); ref TPixel pixel = ref targetRow[x];
pixel.FromVector4(new Vector4(red, green, blue, sourceRow[x].ToVector4().W));
} }
} }
PixelOperations<TPixel>.Instance.FromVector4Destructive(configuration, vectorSpan, targetRowSpan);
} }
} }
}); });

Loading…
Cancel
Save