Browse Source
Merge branch 'master' into af/pin-ByteToNormalizedFloat
pull/1770/head
James Jackson-South
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
21 additions and
9 deletions
-
tests/ImageSharp.Tests/Image/ImageFrameTests.cs
-
tests/ImageSharp.Tests/Image/ImageTests.cs
-
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
-
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs
-
tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
|
|
@ -16,7 +16,8 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
|
|
|
|
|
private void LimitBufferCapacity(int bufferCapacityInBytes) |
|
|
private void LimitBufferCapacity(int bufferCapacityInBytes) |
|
|
{ |
|
|
{ |
|
|
var allocator = (ArrayPoolMemoryAllocator)this.configuration.MemoryAllocator; |
|
|
var allocator = ArrayPoolMemoryAllocator.CreateDefault(); |
|
|
|
|
|
this.configuration.MemoryAllocator = allocator; |
|
|
allocator.BufferCapacityInBytes = bufferCapacityInBytes; |
|
|
allocator.BufferCapacityInBytes = bufferCapacityInBytes; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -99,7 +99,8 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
|
|
|
|
|
private void LimitBufferCapacity(int bufferCapacityInBytes) |
|
|
private void LimitBufferCapacity(int bufferCapacityInBytes) |
|
|
{ |
|
|
{ |
|
|
var allocator = (ArrayPoolMemoryAllocator)this.configuration.MemoryAllocator; |
|
|
var allocator = ArrayPoolMemoryAllocator.CreateDefault(); |
|
|
|
|
|
this.configuration.MemoryAllocator = allocator; |
|
|
allocator.BufferCapacityInBytes = bufferCapacityInBytes; |
|
|
allocator.BufferCapacityInBytes = bufferCapacityInBytes; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -21,11 +21,20 @@ namespace SixLabors.ImageSharp.Tests |
|
|
public abstract partial class TestImageProvider<TPixel> : ITestImageProvider, IXunitSerializable |
|
|
public abstract partial class TestImageProvider<TPixel> : ITestImageProvider, IXunitSerializable |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
|
|
|
// Create a Configuration with Configuration.CreateDefaultInstance(),
|
|
|
|
|
|
// but use the shared MemoryAllocator from Configuration.Default.MemoryAllocator
|
|
|
|
|
|
private static Configuration CreateDefaultConfiguration() |
|
|
|
|
|
{ |
|
|
|
|
|
var configuration = Configuration.CreateDefaultInstance(); |
|
|
|
|
|
configuration.MemoryAllocator = ImageSharp.Configuration.Default.MemoryAllocator; |
|
|
|
|
|
return configuration; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public PixelTypes PixelType { get; private set; } = typeof(TPixel).GetPixelType(); |
|
|
public PixelTypes PixelType { get; private set; } = typeof(TPixel).GetPixelType(); |
|
|
|
|
|
|
|
|
public virtual string SourceFileOrDescription => string.Empty; |
|
|
public virtual string SourceFileOrDescription => string.Empty; |
|
|
|
|
|
|
|
|
public Configuration Configuration { get; set; } = Configuration.CreateDefaultInstance(); |
|
|
public Configuration Configuration { get; set; } = CreateDefaultConfiguration(); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the utility instance to provide information about the test image & manage input/output.
|
|
|
/// Gets the utility instance to provide information about the test image & manage input/output.
|
|
|
|
|
|
@ -32,15 +32,15 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs |
|
|
private static void FromRgba32Bytes<TPixel>(Configuration configuration, Span<byte> rgbaBytes, IMemoryGroup<TPixel> destinationGroup) |
|
|
private static void FromRgba32Bytes<TPixel>(Configuration configuration, Span<byte> rgbaBytes, IMemoryGroup<TPixel> destinationGroup) |
|
|
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel> |
|
|
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
|
|
|
Span<Rgba32> sourcePixels = MemoryMarshal.Cast<byte, Rgba32>(rgbaBytes); |
|
|
foreach (Memory<TPixel> m in destinationGroup) |
|
|
foreach (Memory<TPixel> m in destinationGroup) |
|
|
{ |
|
|
{ |
|
|
Span<TPixel> destBuffer = m.Span; |
|
|
Span<TPixel> destBuffer = m.Span; |
|
|
PixelOperations<TPixel>.Instance.FromRgba32Bytes( |
|
|
PixelOperations<TPixel>.Instance.FromRgba32( |
|
|
configuration, |
|
|
configuration, |
|
|
rgbaBytes, |
|
|
sourcePixels.Slice(0, destBuffer.Length), |
|
|
destBuffer, |
|
|
destBuffer); |
|
|
destBuffer.Length); |
|
|
sourcePixels = sourcePixels.Slice(destBuffer.Length); |
|
|
rgbaBytes = rgbaBytes.Slice(destBuffer.Length * 4); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -663,7 +663,8 @@ namespace SixLabors.ImageSharp.Tests |
|
|
this TestImageProvider<TPixel> provider) |
|
|
this TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
{ |
|
|
{ |
|
|
var allocator = (ArrayPoolMemoryAllocator)provider.Configuration.MemoryAllocator; |
|
|
var allocator = ArrayPoolMemoryAllocator.CreateDefault(); |
|
|
|
|
|
provider.Configuration.MemoryAllocator = allocator; |
|
|
return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf<TPixel>()); |
|
|
return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf<TPixel>()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|