From 77e524d83b875441e0186e9ef1d81a2875ed6103 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 20 Feb 2018 03:00:25 +0100 Subject: [PATCH] MemoryManager returns IBuffer now --- .../Brushes/ImageBrush{TPixel}.cs | 4 +- .../Brushes/PatternBrush{TPixel}.cs | 4 +- .../Brushes/Processors/BrushApplicator.cs | 4 +- .../Brushes/RecolorBrush{TPixel}.cs | 4 +- .../Brushes/SolidBrush{TPixel}.cs | 4 +- .../Processors/DrawImageProcessor.cs | 2 +- .../Processors/FillProcessor.cs | 2 +- src/ImageSharp/Formats/Gif/LzwDecoder.cs | 6 +-- src/ImageSharp/Formats/Gif/LzwEncoder.cs | 4 +- .../Common/Decoder/JpegImagePostProcessor.cs | 2 +- .../GolangPort/Components/Decoder/Bytes.cs | 2 +- .../PdfJsPort/Components/PdfJsComponent.cs | 2 +- .../Components/PdfJsFrameComponent.cs | 2 +- .../Components/PdfJsJpegPixelArea.cs | 2 +- .../Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs | 4 +- .../Memory/ArrayPoolMemoryManager.cs | 11 ++++- src/ImageSharp/Memory/Buffer{T}.cs | 4 +- src/ImageSharp/Memory/IGetArray.cs | 14 +++++++ src/ImageSharp/Memory/MemoryManager.cs | 2 +- .../Memory/MemoryManagerExtensions.cs | 6 +-- .../Memory/SimpleManagedMemoryManager.cs | 2 +- .../DefaultPixelBlenders.Generated.cs | 42 +++++++++---------- .../DefaultPixelBlenders.Generated.tt | 2 +- .../Effects/BackgroundColorProcessor.cs | 4 +- .../Quantizers/WuQuantizer{TPixel}.cs | 26 ++++++------ .../Color/Bulk/PackFromVector4.cs | 4 +- .../Color/Bulk/PackFromXyzw.cs | 4 +- .../Color/Bulk/ToVector4.cs | 4 +- .../ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs | 4 +- .../Color/Bulk/ToXyzw.cs | 4 +- .../PixelBlenders/PorterDuffBulkVsPixel.cs | 6 +-- tests/ImageSharp.Benchmarks/Samplers/Glow.cs | 2 +- .../Drawing/SolidBezierTests.cs | 4 +- .../PixelFormats/PixelOperationsTests.cs | 6 +-- .../ReferenceCodecs/SystemDrawingBridge.cs | 6 +-- 35 files changed, 113 insertions(+), 92 deletions(-) create mode 100644 src/ImageSharp/Memory/IGetArray.cs diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs index 5866d9feae..6b3ce36fe1 100644 --- a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs @@ -122,8 +122,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes internal override void Apply(Span scanline, int x, int y) { // Create a span for colors - using (Buffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) - using (Buffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.Span; Span overlaySpan = overlay.Span; diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs index ac8ffa7941..449a23da9f 100644 --- a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs @@ -152,8 +152,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes internal override void Apply(Span scanline, int x, int y) { int patternY = y % this.pattern.Height; - using (Buffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) - using (Buffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.Span; Span overlaySpan = overlay.Span; diff --git a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs index dadd546e93..68bc13ecb5 100644 --- a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs @@ -65,8 +65,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes.Processors /// scanlineBuffer will be > scanlineWidth but provide and offset in case we want to share a larger buffer across runs. internal virtual void Apply(Span scanline, int x, int y) { - using (Buffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) - using (Buffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.Span; Span overlaySpan = overlay.Span; diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs index d1fda7ebe6..37cba42c9e 100644 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -144,8 +144,8 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// internal override void Apply(Span scanline, int x, int y) { - using (Buffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) - using (Buffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.Span; Span overlaySpan = overlay.Span; diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs index 510299f263..90286cb6c9 100644 --- a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes /// /// Gets the colors. /// - protected Buffer Colors { get; } + protected IBuffer Colors { get; } /// /// Gets the color for a single pixel. @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes { Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length); - using (Buffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.Span; diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index eb3949b007..21e13d47af 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors maxY = Math.Min(this.Location.Y + this.Size.Height, maxY); int width = maxX - minX; - using (Buffer amount = this.Image.GetConfiguration().MemoryManager.Allocate(width)) + using (IBuffer amount = this.Image.GetConfiguration().MemoryManager.Allocate(width)) { amount.Span.Fill(this.Alpha); diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs index 75ea1f2033..3bf18a37ba 100644 --- a/src/ImageSharp.Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillProcessor.cs @@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Drawing.Processors int width = maxX - minX; - using (Buffer amount = source.MemoryManager.Allocate(width)) + using (IBuffer amount = source.MemoryManager.Allocate(width)) using (BrushApplicator applicator = this.brush.CreateApplicator( source, sourceRectangle, diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index 27ca275db1..0c73efea46 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -32,17 +32,17 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// The prefix buffer. /// - private readonly Buffer prefix; + private readonly IBuffer prefix; /// /// The suffix buffer. /// - private readonly Buffer suffix; + private readonly IBuffer suffix; /// /// The pixel stack buffer. /// - private readonly Buffer pixelStack; + private readonly IBuffer pixelStack; /// /// A value indicating whether this instance of the given entity has been disposed. diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs index 115ecf6fbe..35c4148964 100644 --- a/src/ImageSharp/Formats/Gif/LzwEncoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwEncoder.cs @@ -71,12 +71,12 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// The hash table. /// - private readonly Buffer hashTable; + private readonly IBuffer hashTable; /// /// The code table. /// - private readonly Buffer codeTable; + private readonly IBuffer codeTable; /// /// Define the storage for the packet accumulator. diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs index 3258fd32cc..aa1c216a75 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder /// /// Temporal buffer to store a row of colors. /// - private readonly Buffer rgbaBuffer; + private readonly IBuffer rgbaBuffer; /// /// The corresponding to the current determined by . diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs index 7a22b043b8..c10771b462 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Values of converted to -s /// - public Buffer BufferAsInt; + public IBuffer BufferAsInt; /// /// Start of bytes read diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs index 3c35e311f1..0742293c78 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsComponent.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components /// /// Gets or sets the output /// - public Buffer Output; + public IBuffer Output; /// /// Gets or sets the scaling factors diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs index 18e1773909..2442c39981 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs @@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components /// /// Gets the block data /// - public Buffer BlockData { get; private set; } + public IBuffer BlockData { get; private set; } /// public int Index { get; } diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs index a6f8780177..f16fb9a2c2 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsJpegPixelArea.cs @@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components private readonly int imageHeight; - private Buffer componentData; + private IBuffer componentData; private int rowStride; diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs index 6bcde2f487..4fa0bc281d 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs @@ -786,8 +786,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort { int blocksPerLine = component.BlocksPerLine; int blocksPerColumn = component.BlocksPerColumn; - using (Buffer computationBuffer = this.configuration.MemoryManager.Allocate(64, true)) - using (Buffer multiplicationBuffer = this.configuration.MemoryManager.Allocate(64, true)) + using (IBuffer computationBuffer = this.configuration.MemoryManager.Allocate(64, true)) + using (IBuffer multiplicationBuffer = this.configuration.MemoryManager.Allocate(64, true)) { Span quantizationTable = this.quantizationTables.Tables.GetRowSpan(frameComponent.QuantizationTableIndex); Span computationBufferSpan = computationBuffer.Span; diff --git a/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs b/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs index e14ba443f9..de26b0ba5e 100644 --- a/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs +++ b/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Memory } /// - internal override Buffer Allocate(int length, bool clear) + internal override IBuffer Allocate(int length, bool clear) { int itemSizeBytes = Unsafe.SizeOf(); int bufferSizeInBytes = length * itemSizeBytes; @@ -68,7 +68,14 @@ namespace SixLabors.ImageSharp.Memory /// internal override void Release(Buffer buffer) { - byte[] byteBuffer = Unsafe.As(buffer.GetArray()); + T[] array = (buffer as IGetArray)?.GetArray(); + if (array == null) + { + return; + } + + // TODO: OMG Do not do this! + byte[] byteBuffer = Unsafe.As(array); this.pool.Return(byteBuffer); } } diff --git a/src/ImageSharp/Memory/Buffer{T}.cs b/src/ImageSharp/Memory/Buffer{T}.cs index 309cca1f41..b1449f9b61 100644 --- a/src/ImageSharp/Memory/Buffer{T}.cs +++ b/src/ImageSharp/Memory/Buffer{T}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Memory /// The backing array is either pooled or comes from the outside. /// /// The value type. - internal class Buffer : IBuffer + internal class Buffer : IBuffer, IGetArray where T : struct { private MemoryManager memoryManager; @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Memory /// /// TODO: Refactor this /// - internal T[] GetArray() + T[] IGetArray.GetArray() { return this.array; } diff --git a/src/ImageSharp/Memory/IGetArray.cs b/src/ImageSharp/Memory/IGetArray.cs new file mode 100644 index 0000000000..9b46058d19 --- /dev/null +++ b/src/ImageSharp/Memory/IGetArray.cs @@ -0,0 +1,14 @@ +namespace SixLabors.ImageSharp.Memory +{ + /// + /// Absolutely temporal. + /// + internal interface IGetArray + where T : struct + { + /// + /// Absolutely temporal. + /// + T[] GetArray(); + } +} \ No newline at end of file diff --git a/src/ImageSharp/Memory/MemoryManager.cs b/src/ImageSharp/Memory/MemoryManager.cs index 540c045de3..fe6bb7823f 100644 --- a/src/ImageSharp/Memory/MemoryManager.cs +++ b/src/ImageSharp/Memory/MemoryManager.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Memory /// Size of the buffer to allocate /// True to clear the backing memory of the buffer /// A buffer of values of type . - internal abstract Buffer Allocate(int length, bool clear) + internal abstract IBuffer Allocate(int length, bool clear) where T : struct; internal abstract IManagedByteBuffer AllocateManagedByteBuffer(int length, bool clear); diff --git a/src/ImageSharp/Memory/MemoryManagerExtensions.cs b/src/ImageSharp/Memory/MemoryManagerExtensions.cs index f157767217..21c8f71248 100644 --- a/src/ImageSharp/Memory/MemoryManagerExtensions.cs +++ b/src/ImageSharp/Memory/MemoryManagerExtensions.cs @@ -14,13 +14,13 @@ /// The /// Size of the buffer to allocate /// A buffer of values of type . - public static Buffer Allocate(this MemoryManager memoryManager, int length) + public static IBuffer Allocate(this MemoryManager memoryManager, int length) where T : struct { return memoryManager.Allocate(length, false); } - public static Buffer AllocateClean(this MemoryManager memoryManager, int length) + public static IBuffer AllocateClean(this MemoryManager memoryManager, int length) where T : struct { return memoryManager.Allocate(length, true); @@ -39,7 +39,7 @@ public static Buffer2D Allocate2D(this MemoryManager memoryManager, int width, int height, bool clear) where T : struct { - Buffer buffer = memoryManager.Allocate(width * height, clear); + IBuffer buffer = memoryManager.Allocate(width * height, clear); return new Buffer2D(buffer, width, height); } diff --git a/src/ImageSharp/Memory/SimpleManagedMemoryManager.cs b/src/ImageSharp/Memory/SimpleManagedMemoryManager.cs index ac4098c71d..804a468fd6 100644 --- a/src/ImageSharp/Memory/SimpleManagedMemoryManager.cs +++ b/src/ImageSharp/Memory/SimpleManagedMemoryManager.cs @@ -6,7 +6,7 @@ public class SimpleManagedMemoryManager : MemoryManager { /// - internal override Buffer Allocate(int length, bool clear) + internal override IBuffer Allocate(int length, bool clear) { return new Buffer(new T[length], length, this); } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 4ca53244ad..17f75898db 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -201,7 +201,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -240,7 +240,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -318,7 +318,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -357,7 +357,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -396,7 +396,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -435,7 +435,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -474,7 +474,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -513,7 +513,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -552,7 +552,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -591,7 +591,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -630,7 +630,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -669,7 +669,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -708,7 +708,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -747,7 +747,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -786,7 +786,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -825,7 +825,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index 5e9268dff1..75c6b2d81c 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3, false)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); diff --git a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs index a42a2056c4..e97495a3db 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs @@ -71,8 +71,8 @@ namespace SixLabors.ImageSharp.Processing.Processors int width = maxX - minX; - using (Buffer colors = this.memoryManager.Allocate(width)) - using (Buffer amount = this.memoryManager.Allocate(width)) + using (IBuffer colors = this.memoryManager.Allocate(width)) + using (IBuffer amount = this.memoryManager.Allocate(width)) { // Be careful! Do not capture colorSpan & amountSpan in the lambda below! Span colorSpan = colors.Span; diff --git a/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs b/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs index d9f188bf30..0aadf49732 100644 --- a/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs @@ -473,19 +473,19 @@ namespace SixLabors.ImageSharp.Quantizers Span vmaSpan = this.vma.Span; Span m2Span = this.m2.Span; - using (Buffer volume = memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeR = memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeG = memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeB = memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeA = memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volume2 = memoryManager.Allocate(IndexCount * IndexAlphaCount)) - - using (Buffer area = memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaR = memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaG = memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaB = memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaA = memoryManager.Allocate(IndexAlphaCount)) - using (Buffer area2 = memoryManager.Allocate(IndexAlphaCount)) + using (IBuffer volume = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeR = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeG = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeB = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeA = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volume2 = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + + using (IBuffer area = memoryManager.Allocate(IndexAlphaCount)) + using (IBuffer areaR = memoryManager.Allocate(IndexAlphaCount)) + using (IBuffer areaG = memoryManager.Allocate(IndexAlphaCount)) + using (IBuffer areaB = memoryManager.Allocate(IndexAlphaCount)) + using (IBuffer areaA = memoryManager.Allocate(IndexAlphaCount)) + using (IBuffer area2 = memoryManager.Allocate(IndexAlphaCount)) { Span volumeSpan = volume.Span; Span volumeRSpan = volumeR.Span; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs index 1b49c48ec5..7d8519875b 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs @@ -13,9 +13,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Color.Bulk public abstract class PackFromVector4 where TPixel : struct, IPixel { - private Buffer source; + private IBuffer source; - private Buffer destination; + private IBuffer destination; [Params(16, 128, 512)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs index 33dbcd24ca..882d77dd12 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs @@ -11,9 +11,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Color.Bulk public abstract class PackFromXyzw where TPixel : struct, IPixel { - private Buffer destination; + private IBuffer destination; - private Buffer source; + private IBuffer source; [Params(16, 128, 1024)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs index 8a7fc52afd..6537141501 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Color.Bulk public abstract class ToVector4 where TPixel : struct, IPixel { - private Buffer source; + private IBuffer source; - private Buffer destination; + private IBuffer destination; [Params(64, 300, 1024)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs index 45ccaa8299..b2def64ace 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Color.Bulk public abstract class ToXyz where TPixel : struct, IPixel { - private Buffer source; + private IBuffer source; - private Buffer destination; + private IBuffer destination; [Params(16, 128, 1024)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs index 9912e987cf..dd9a628c25 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs @@ -14,9 +14,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Color.Bulk public abstract class ToXyzw where TPixel : struct, IPixel { - private Buffer source; + private IBuffer source; - private Buffer destination; + private IBuffer destination; [Params(16, 128, 1024)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index 07734c6f55..c088e8eed4 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Benchmarks Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length)); - using (Buffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) { Span destinationSpan = buffer.Slice(0, destination.Length); Span backgroundSpan = buffer.Slice(destination.Length, destination.Length); @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Benchmarks { using (Image image = new Image(800, 800)) { - using (Buffer amounts = Configuration.Default.MemoryManager.Allocate(image.Width)) + using (IBuffer amounts = Configuration.Default.MemoryManager.Allocate(image.Width)) { amounts.Span.Fill(1); @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Benchmarks { using (Image image = new Image(800, 800)) { - using (Buffer amounts = Configuration.Default.MemoryManager.Allocate(image.Width)) + using (IBuffer amounts = Configuration.Default.MemoryManager.Allocate(image.Width)) { amounts.Span.Fill(1); using (PixelAccessor pixels = image.Lock()) diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index b36b4841f2..5f4e2d75b4 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Benchmarks } int width = maxX - minX; - using (Buffer rowColors = Configuration.Default.MemoryManager.Allocate(width)) + using (IBuffer rowColors = Configuration.Default.MemoryManager.Allocate(width)) using (PixelAccessor sourcePixels = source.Lock()) { rowColors.Span.Fill(glowColor); diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 8bc4645ff2..70badd34c5 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -43,13 +43,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void OverlayByFilledPolygonOpacity(TestImageProvider provider) where TPixel : struct, IPixel { - string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledBezier"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + Primitives.PointF[] simplePath = { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), new Vector2(300, 400) }; + Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); using (var image = provider.GetImage() as Image) diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs index 6e01bf182d..c0039bb37c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs @@ -50,8 +50,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats int times = 200000; int count = 1024; - using (Buffer source = Configuration.Default.MemoryManager.Allocate(count)) - using (Buffer dest = Configuration.Default.MemoryManager.Allocate(count)) + using (IBuffer source = Configuration.Default.MemoryManager.Allocate(count)) + using (IBuffer dest = Configuration.Default.MemoryManager.Allocate(count)) { this.Measure( times, @@ -334,7 +334,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats where TDest : struct { public TSource[] SourceBuffer { get; } - public Buffer ActualDestBuffer { get; } + public IBuffer ActualDestBuffer { get; } public TDest[] ExpectedDestBuffer { get; } public TestBuffers(TSource[] source, TDest[] expectedDest) diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 9dbfeaca91..d1270dcfd7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs int length = source.Length; Guard.MustBeSizedAtLeast(dest, length, nameof(dest)); - using (Buffer rgbaBuffer = Configuration.Default.MemoryManager.Allocate(length)) + using (IBuffer rgbaBuffer = Configuration.Default.MemoryManager.Allocate(length)) { Span rgbaSpan = rgbaBuffer.Span; PixelOperations.Instance.ToRgba32(source, rgbaSpan, length); @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs int length = source.Length; Guard.MustBeSizedAtLeast(dest, length, nameof(dest)); - using (Buffer rgbaBuffer = Configuration.Default.MemoryManager.Allocate(length)) + using (IBuffer rgbaBuffer = Configuration.Default.MemoryManager.Allocate(length)) { Span rgbaSpan = rgbaBuffer.Span; PixelOperations.Instance.ToRgba32(source, rgbaSpan, length); @@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs int length = source.Length; Guard.MustBeSizedAtLeast(dest, length, nameof(dest)); - using (Buffer rgbBuffer = Configuration.Default.MemoryManager.Allocate(length)) + using (IBuffer rgbBuffer = Configuration.Default.MemoryManager.Allocate(length)) { Span rgbSpan = rgbBuffer.Span; PixelOperations.Instance.ToRgb24(source, rgbSpan, length);