Skip to content

Commit 6f5269f

Browse files
Merge branch 'master' into af/pin-ByteToNormalizedFloat
2 parents 185d8e3 + 4ce2d0c commit 6f5269f

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

tests/ImageSharp.Tests/Image/ImageFrameTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class Indexer
1616

1717
private void LimitBufferCapacity(int bufferCapacityInBytes)
1818
{
19-
var allocator = (ArrayPoolMemoryAllocator)this.configuration.MemoryAllocator;
19+
var allocator = ArrayPoolMemoryAllocator.CreateDefault();
20+
this.configuration.MemoryAllocator = allocator;
2021
allocator.BufferCapacityInBytes = bufferCapacityInBytes;
2122
}
2223

tests/ImageSharp.Tests/Image/ImageTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public class Indexer
9999

100100
private void LimitBufferCapacity(int bufferCapacityInBytes)
101101
{
102-
var allocator = (ArrayPoolMemoryAllocator)this.configuration.MemoryAllocator;
102+
var allocator = ArrayPoolMemoryAllocator.CreateDefault();
103+
this.configuration.MemoryAllocator = allocator;
103104
allocator.BufferCapacityInBytes = bufferCapacityInBytes;
104105
}
105106

tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@ namespace SixLabors.ImageSharp.Tests
2121
public abstract partial class TestImageProvider<TPixel> : ITestImageProvider, IXunitSerializable
2222
where TPixel : unmanaged, IPixel<TPixel>
2323
{
24+
// Create a Configuration with Configuration.CreateDefaultInstance(),
25+
// but use the shared MemoryAllocator from Configuration.Default.MemoryAllocator
26+
private static Configuration CreateDefaultConfiguration()
27+
{
28+
var configuration = Configuration.CreateDefaultInstance();
29+
configuration.MemoryAllocator = ImageSharp.Configuration.Default.MemoryAllocator;
30+
return configuration;
31+
}
32+
2433
public PixelTypes PixelType { get; private set; } = typeof(TPixel).GetPixelType();
2534

2635
public virtual string SourceFileOrDescription => string.Empty;
2736

28-
public Configuration Configuration { get; set; } = Configuration.CreateDefaultInstance();
37+
public Configuration Configuration { get; set; } = CreateDefaultConfiguration();
2938

3039
/// <summary>
3140
/// Gets the utility instance to provide information about the test image & manage input/output.

tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public MagickReferenceDecoder()
3232
private static void FromRgba32Bytes<TPixel>(Configuration configuration, Span<byte> rgbaBytes, IMemoryGroup<TPixel> destinationGroup)
3333
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
3434
{
35+
Span<Rgba32> sourcePixels = MemoryMarshal.Cast<byte, Rgba32>(rgbaBytes);
3536
foreach (Memory<TPixel> m in destinationGroup)
3637
{
3738
Span<TPixel> destBuffer = m.Span;
38-
PixelOperations<TPixel>.Instance.FromRgba32Bytes(
39+
PixelOperations<TPixel>.Instance.FromRgba32(
3940
configuration,
40-
rgbaBytes,
41-
destBuffer,
42-
destBuffer.Length);
43-
rgbaBytes = rgbaBytes.Slice(destBuffer.Length * 4);
41+
sourcePixels.Slice(0, destBuffer.Length),
42+
destBuffer);
43+
sourcePixels = sourcePixels.Slice(destBuffer.Length);
4444
}
4545
}
4646

tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ internal static AllocatorBufferCapacityConfigurator LimitAllocatorBufferCapacity
663663
this TestImageProvider<TPixel> provider)
664664
where TPixel : unmanaged, IPixel<TPixel>
665665
{
666-
var allocator = (ArrayPoolMemoryAllocator)provider.Configuration.MemoryAllocator;
666+
var allocator = ArrayPoolMemoryAllocator.CreateDefault();
667+
provider.Configuration.MemoryAllocator = allocator;
667668
return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf<TPixel>());
668669
}
669670

0 commit comments

Comments
 (0)