Browse Source

Rename class and add native memory profiler

af/octree-no-pixelmap
James Jackson-South 6 years ago
parent
commit
b62434cea9
  1. 3
      src/ImageSharp/Advanced/IRowIntervalAction.cs
  2. 9
      src/ImageSharp/Advanced/IRowIntervalAction{TBuffer}.cs
  3. 8
      src/ImageSharp/Advanced/ParallelExecutionSettings.cs
  4. 4
      src/ImageSharp/Advanced/ParallelRowIterator.cs
  5. 4
      src/ImageSharp/ImageFrame{TPixel}.cs
  6. 6
      src/ImageSharp/ImageSharp.csproj
  7. 4
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
  8. 11
      src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs
  9. 5
      src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs
  10. 5
      src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs
  11. 5
      src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs
  12. 5
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
  13. 4
      src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs
  14. 4
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs
  15. 3
      src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs
  16. 3
      src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs
  17. 6
      src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs
  18. 4
      src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs
  19. 4
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs
  20. 4
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs
  21. 5
      src/ImageSharp/Processing/Processors/Transforms/AffineTransformProcessor{TPixel}.cs
  22. 3
      src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs
  23. 4
      src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs
  24. 6
      src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs
  25. 3
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs
  26. 8
      src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs
  27. 1
      tests/Directory.Build.targets
  28. 22
      tests/ImageSharp.Benchmarks/Config.cs
  29. 1
      tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
  30. 2
      tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs
  31. 24
      tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs
  32. 3
      tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

3
src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction.cs → src/ImageSharp/Advanced/IRowIntervalAction.cs

@ -5,7 +5,7 @@ using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Advanced.ParallelUtils
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Defines the contract for an action that operates on a row interval.
@ -46,6 +46,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils
private readonly WrappingRowIntervalInfo info;
private readonly T action;
[MethodImpl(InliningOptions.ShortMethod)]
public WrappingRowIntervalAction(in WrappingRowIntervalInfo info, in T action)
{
this.info = info;

9
src/ImageSharp/Advanced/ParallelUtils/IRowIntervalAction{TBuffer}.cs → src/ImageSharp/Advanced/IRowIntervalAction{TBuffer}.cs

@ -6,7 +6,7 @@ using System.Buffers;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Advanced.ParallelUtils
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Defines the contract for an action that operates on a row interval with a temporary buffer.
@ -31,6 +31,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils
private readonly MemoryAllocator allocator;
private readonly T action;
[MethodImpl(InliningOptions.ShortMethod)]
public WrappingRowIntervalAction(
in WrappingRowIntervalInfo info,
MemoryAllocator allocator,
@ -54,10 +55,8 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils
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))
{
this.action.Invoke(in rows, buffer.Memory);
}
using IMemoryOwner<TBuffer> buffer = this.allocator.Allocate<TBuffer>(this.info.MaxX);
this.action.Invoke(in rows, buffer.Memory);
}
}
}

8
src/ImageSharp/Advanced/ParallelUtils/ParallelExecutionSettings.cs → src/ImageSharp/Advanced/ParallelExecutionSettings.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -6,10 +6,10 @@ using System.Threading.Tasks;
using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Advanced.ParallelUtils
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Defines execution settings for methods in <see cref="ParallelHelper"/>.
/// Defines execution settings for methods in <see cref="ParallelRowIterator"/>.
/// </summary>
public readonly struct ParallelExecutionSettings
{
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils
}
/// <summary>
/// Get the default <see cref="SixLabors.ImageSharp.Advanced.ParallelUtils.ParallelExecutionSettings"/> for a <see cref="SixLabors.ImageSharp.Configuration"/>
/// Get the default <see cref="SixLabors.ImageSharp.Advanced.ParallelExecutionSettings"/> for a <see cref="SixLabors.ImageSharp.Configuration"/>
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/>.</param>
/// <returns>The <see cref="ParallelExecutionSettings"/>.</returns>

4
src/ImageSharp/Advanced/ParallelUtils/ParallelHelper.cs → src/ImageSharp/Advanced/ParallelRowIterator.cs

@ -8,7 +8,7 @@ using System.Threading.Tasks;
using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Advanced.ParallelUtils
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Utility methods for batched processing of pixel row intervals.
@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Advanced.ParallelUtils
/// <see cref="ParallelExecutionSettings"/> or <see cref="Configuration"/>.
/// Using this class is preferred over direct usage of <see cref="Parallel"/> utility methods.
/// </summary>
public static class ParallelHelper
public static class ParallelRowIterator
{
/// <summary>
/// Iterate through the rows of a rectangle in optimized batches defined by <see cref="RowInterval"/>-s.

4
src/ImageSharp/ImageFrame{TPixel}.cs

@ -4,9 +4,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
@ -262,7 +260,7 @@ namespace SixLabors.ImageSharp
var target = new ImageFrame<TPixel2>(configuration, this.Width, this.Height, this.Metadata.DeepClone());
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
this.Bounds(),
configuration,
rows =>

6
src/ImageSharp/ImageSharp.csproj

@ -24,9 +24,9 @@
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) OR '$(TargetFramework)' == 'net472'">
<PackageReference Include="System.Numerics.Vectors"/>
<PackageReference Include="System.Buffers"/>
<PackageReference Include="System.Memory"/>
<PackageReference Include="System.Numerics.Vectors" />
<PackageReference Include="System.Buffers" />
<PackageReference Include="System.Memory" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3'">

4
src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Binarization
@ -51,7 +49,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY);
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
configuration,
rows =>

11
src/ImageSharp/Processing/Processors/Convolution/BokehBlurProcessor{TPixel}.cs

@ -7,8 +7,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Convolution.Parameters;
@ -342,7 +341,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
var workingRectangle = Rectangle.FromLTRB(startX, startY, endX, endY);
int width = workingRectangle.Width;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRectangle,
configuration,
rows =>
@ -389,7 +388,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
var workingRectangle = Rectangle.FromLTRB(startX, startY, endX, endY);
int width = workingRectangle.Width;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRectangle,
configuration,
rows =>
@ -428,7 +427,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
int width = workingRectangle.Width;
float exp = this.gamma;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
workingRectangle,
configuration,
(rows, vectorBuffer) =>
@ -479,7 +478,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
int width = workingRectangle.Width;
float expGamma = 1 / this.gamma;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRectangle,
configuration,
rows =>

5
src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor{TPixel}.cs

@ -4,8 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -79,7 +78,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
var workingRectangle = Rectangle.FromLTRB(startX, startY, endX, endY);
int width = workingRectangle.Width;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
workingRectangle,
this.Configuration,
(rows, vectorBuffer) =>

5
src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor{TPixel}.cs

@ -4,8 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -98,7 +97,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
var workingRectangle = Rectangle.FromLTRB(startX, startY, endX, endY);
int width = workingRectangle.Width;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
workingRectangle,
configuration,
(rows, vectorBuffer) =>

5
src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor{TPixel}.cs

@ -4,8 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -69,7 +68,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
var workingRectangle = Rectangle.FromLTRB(startX, startY, endX, endY);
int width = workingRectangle.Width;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
workingRectangle,
this.Configuration,
(rows, vectorBuffer) =>

5
src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs

@ -5,8 +5,7 @@ using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Filters;
@ -109,7 +108,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
Buffer2D<TPixel> passPixels = pass.PixelBuffer;
Buffer2D<TPixel> targetPixels = source.PixelBuffer;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
this.Configuration,
rows =>

4
src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Drawing
@ -99,7 +97,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
"Cannot draw image because the source image does not overlap the target image.");
}
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
configuration,
rows =>

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

@ -5,9 +5,7 @@ using System;
using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -63,7 +61,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
source.CopyTo(targetPixels);
var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY);
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
this.Configuration,
(rows) =>

3
src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessorBase{TPixel}.cs

@ -4,7 +4,6 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Effects
@ -40,7 +39,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Effects
Configuration configuration = this.Configuration;
PixelConversionModifiers modifiers = this.modifiers;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
interest,
this.Configuration,
(rows, vectorBuffer) =>

3
src/ImageSharp/Processing/Processors/Filters/FilterProcessor{TPixel}.cs

@ -4,7 +4,6 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Filters
@ -39,7 +38,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
ColorMatrix matrix = this.definition.Matrix;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
interest,
this.Configuration,
(rows, vectorBuffer) =>

6
src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs

@ -6,9 +6,7 @@ using System.Buffers;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -55,7 +53,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
using (IMemoryOwner<int> cdfBuffer = memoryAllocator.Allocate<int>(this.LuminanceLevels, AllocationOptions.Clean))
{
// Build the histogram of the grayscale levels.
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
this.Configuration,
rows =>
@ -88,7 +86,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
float numberOfPixelsMinusCdfMin = numberOfPixels - cdfMin;
// Apply the cdf to each pixel of the image
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
this.Configuration,
rows =>

4
src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor{TPixel}.cs

@ -3,9 +3,7 @@
using System;
using System.Buffers;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -79,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
PixelBlender<TPixel> blender = PixelOperations<TPixel>.Instance.GetPixelBlender(graphicsOptions);
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
workingRect,
configuration,
rows =>

4
src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs

@ -4,9 +4,7 @@
using System;
using System.Buffers;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -83,7 +81,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
{
rowColors.GetSpan().Fill(glowColor);
ParallelHelper.IterateRowsWithTempBuffer<float>(
ParallelRowIterator.IterateRowsWithTempBuffer<float>(
workingRect,
configuration,
(rows, amounts) =>

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

@ -4,9 +4,7 @@
using System;
using System.Buffers;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -87,7 +85,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
{
rowColors.GetSpan().Fill(vignetteColor);
ParallelHelper.IterateRowsWithTempBuffer<float>(
ParallelRowIterator.IterateRowsWithTempBuffer<float>(
workingRect,
configuration,
(rows, amounts) =>

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

@ -4,7 +4,6 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Transforms
@ -58,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
if (this.resampler is NearestNeighborResampler)
{
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
targetBounds,
configuration,
rows =>
@ -85,7 +84,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
try
{
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
targetBounds,
configuration,
(rows, vectorBuffer) =>

3
src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs

@ -4,7 +4,6 @@
using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -54,7 +53,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
var rowAction = new RowAction(ref bounds, source, destination);
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
bounds,
in parallelSettings,
in rowAction);

4
src/ImageSharp/Processing/Processors/Transforms/FlipProcessor{TPixel}.cs

@ -3,9 +3,7 @@
using System;
using System.Buffers;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Transforms
@ -79,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
/// <param name="configuration">The configuration.</param>
private void FlipY(ImageFrame<TPixel> source, Configuration configuration)
{
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
source.Bounds(),
configuration,
rows =>

6
src/ImageSharp/Processing/Processors/Transforms/ProjectiveTransformProcessor{TPixel}.cs

@ -3,9 +3,7 @@
using System;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors.Transforms
@ -59,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
if (this.resampler is NearestNeighborResampler)
{
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
targetBounds,
configuration,
rows =>
@ -89,7 +87,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
try
{
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
targetBounds,
configuration,
(rows, vectorBuffer) =>

3
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs

@ -4,7 +4,6 @@
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -101,7 +100,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
float widthFactor = sourceRectangle.Width / (float)this.targetRectangle.Width;
float heightFactor = sourceRectangle.Height / (float)this.targetRectangle.Height;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
targetWorkingRect,
configuration,
rows =>

8
src/ImageSharp/Processing/Processors/Transforms/RotateProcessor{TPixel}.cs

@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats;
@ -136,7 +134,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
int width = source.Width;
int height = source.Height;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
source.Bounds(),
configuration,
rows =>
@ -166,7 +164,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
int height = source.Height;
Rectangle destinationBounds = destination.Bounds();
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
source.Bounds(),
configuration,
rows =>
@ -201,7 +199,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
int height = source.Height;
Rectangle destinationBounds = destination.Bounds();
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
source.Bounds(),
configuration,
rows =>

1
tests/Directory.Build.targets

@ -26,6 +26,7 @@
<ItemGroup>
<!--Test Dependencies-->
<PackageReference Update="BenchmarkDotNet" Version="0.12.0" />
<PackageReference Update="BenchmarkDotNet.Diagnostics.Windows" Version="0.12.0" Condition="'$(OS)' == 'Windows_NT'" />
<PackageReference Update="Colourful" Version="2.0.3" />
<PackageReference Update="coverlet.collector" Version="1.2.0" PrivateAssets="All"/>
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="7.14.4" />

22
tests/ImageSharp.Benchmarks/Config.cs

@ -1,8 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
#if Windows_NT
using System.Security.Principal;
#endif
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Diagnostics.Windows;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
@ -13,6 +17,14 @@ namespace SixLabors.ImageSharp.Benchmarks
public Config()
{
this.Add(MemoryDiagnoser.Default);
#if Windows_NT
if (this.IsElevated)
{
this.Add(new NativeMemoryProfiler());
}
#endif
}
public class ShortClr : Config
@ -25,5 +37,15 @@ namespace SixLabors.ImageSharp.Benchmarks
Job.Default.With(CoreRuntime.Core21).WithLaunchCount(1).WithWarmupCount(3).WithIterationCount(3));
}
}
#if Windows_NT
private bool IsElevated
{
get
{
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
}
}
#endif
}
}

1
tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj

@ -19,6 +19,7 @@
<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" />
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Condition="'$(OS)' == 'Windows_NT'" />
<PackageReference Include="Colourful" />
<PackageReference Include="Pfim" />
<PackageReference Include="System.Drawing.Common" />

2
tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Helpers

24
tests/ImageSharp.Tests/Helpers/ParallelHelperTests.cs → tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs

@ -7,7 +7,7 @@ using System.Linq;
using System.Numerics;
using System.Threading;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -16,11 +16,11 @@ using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Helpers
{
public class ParallelHelperTests
public class ParallelRowIteratorTests
{
private readonly ITestOutputHelper output;
public ParallelHelperTests(ITestOutputHelper output)
public ParallelRowIteratorTests(ITestOutputHelper output)
{
this.output = output;
}
@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
int actualNumberOfSteps = 0;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
rectangle,
parallelSettings,
rows =>
@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray();
var actualData = new int[maxY];
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
rectangle,
parallelSettings,
rows =>
@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var bufferHashes = new ConcurrentBag<int>();
int actualNumberOfSteps = 0;
ParallelHelper.IterateRowsWithTempBuffer(
ParallelRowIterator.IterateRowsWithTempBuffer(
rectangle,
parallelSettings,
(RowInterval rows, Memory<Vector4> buffer) =>
@ -179,7 +179,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray();
var actualData = new int[maxY];
ParallelHelper.IterateRowsWithTempBuffer(
ParallelRowIterator.IterateRowsWithTempBuffer(
rectangle,
parallelSettings,
(RowInterval rows, Memory<Vector4> buffer) =>
@ -225,7 +225,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
int actualNumberOfSteps = 0;
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
rectangle,
parallelSettings,
rows =>
@ -262,7 +262,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rectangle = new Rectangle(0, 0, width, height);
int actualNumberOfSteps = 0;
ParallelHelper.IterateRowsWithTempBuffer(
ParallelRowIterator.IterateRowsWithTempBuffer(
rectangle,
parallelSettings,
(RowInterval rows, Memory<Vector4> buffer) =>
@ -325,7 +325,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
// Fill actual data using IterateRows:
var settings = new ParallelExecutionSettings(maxDegreeOfParallelism, memoryAllocator);
ParallelHelper.IterateRows(
ParallelRowIterator.IterateRows(
rect,
settings,
rows =>
@ -354,7 +354,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rect = new Rectangle(0, 0, width, height);
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(
() => ParallelHelper.IterateRows(rect, parallelSettings, rows => { }));
() => ParallelRowIterator.IterateRows(rect, parallelSettings, rows => { }));
Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message);
}
@ -371,7 +371,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
var rect = new Rectangle(0, 0, width, height);
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(
() => ParallelHelper.IterateRowsWithTempBuffer<Rgba32>(rect, parallelSettings, (rows, memory) => { }));
() => ParallelRowIterator.IterateRowsWithTempBuffer<Rgba32>(rect, parallelSettings, (rows, memory) => { }));
Assert.Contains(width <= 0 ? "Width" : "Height", ex.Message);
}

3
tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

@ -7,7 +7,6 @@ using System.IO;
using System.Numerics;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Advanced.ParallelUtils;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -703,7 +702,7 @@ namespace SixLabors.ImageSharp.Tests
{
Rectangle sourceRectangle = this.SourceRectangle;
Configuration configuration = this.Configuration;
ParallelHelper.IterateRowsWithTempBuffer<Vector4>(
ParallelRowIterator.IterateRowsWithTempBuffer<Vector4>(
sourceRectangle,
configuration,
(rows, temp) =>

Loading…
Cancel
Save