diff --git a/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs index 4c446189e..cb4305248 100644 --- a/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Primitives var start = new PointF(this.Bounds.Left - 1, y); var end = new PointF(this.Bounds.Right + 1, y); - using (IBuffer tempBuffer = configuration.MemoryManager.Allocate(buffer.Length)) + using (IBuffer tempBuffer = configuration.MemoryAllocator.Allocate(buffer.Length)) { Span innerBuffer = tempBuffer.GetSpan(); int count = this.Shape.FindIntersections(start, end, innerBuffer); diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs index 83bff9c47..bd22759fc 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs @@ -65,10 +65,10 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes /// 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) { - MemoryManager memoryManager = this.Target.MemoryManager; + MemoryAllocator memoryAllocator = this.Target.MemoryAllocator; - using (IBuffer amountBuffer = memoryManager.Allocate(scanline.Length)) - using (IBuffer overlay = memoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = memoryAllocator.Allocate(scanline.Length)) + using (IBuffer overlay = memoryAllocator.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.GetSpan(); Span overlaySpan = overlay.GetSpan(); @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes } Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length); - this.Blender.Blend(memoryManager, destinationRow, destinationRow, overlaySpan, amountSpan); + this.Blender.Blend(memoryAllocator, destinationRow, destinationRow, overlaySpan, amountSpan); } } } diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs index dfdc1721d..30e48b54c 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/ImageBrush{TPixel}.cs @@ -118,8 +118,8 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes internal override void Apply(Span scanline, int x, int y) { // Create a span for colors - using (IBuffer amountBuffer = this.Target.MemoryManager.Allocate(scanline.Length)) - using (IBuffer overlay = this.Target.MemoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = this.Target.MemoryAllocator.Allocate(scanline.Length)) + using (IBuffer overlay = this.Target.MemoryAllocator.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.GetSpan(); Span overlaySpan = overlay.GetSpan(); @@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes } Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length); - this.Blender.Blend(this.source.MemoryManager, destinationRow, destinationRow, overlaySpan, amountSpan); + this.Blender.Blend(this.source.MemoryAllocator, destinationRow, destinationRow, overlaySpan, amountSpan); } } } diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs index b5bc5a7ef..dccb05f87 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/PatternBrush{TPixel}.cs @@ -151,10 +151,10 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes internal override void Apply(Span scanline, int x, int y) { int patternY = y % this.pattern.Rows; - MemoryManager memoryManager = this.Target.MemoryManager; + MemoryAllocator memoryAllocator = this.Target.MemoryAllocator; - using (IBuffer amountBuffer = memoryManager.Allocate(scanline.Length)) - using (IBuffer overlay = memoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = memoryAllocator.Allocate(scanline.Length)) + using (IBuffer overlay = memoryAllocator.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.GetSpan(); Span overlaySpan = overlay.GetSpan(); @@ -168,7 +168,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes } Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length); - this.Blender.Blend(memoryManager, destinationRow, destinationRow, overlaySpan, amountSpan); + this.Blender.Blend(memoryAllocator, destinationRow, destinationRow, overlaySpan, amountSpan); } } } diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs index 05607472e..a2d5c296d 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -136,10 +136,10 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes /// internal override void Apply(Span scanline, int x, int y) { - MemoryManager memoryManager = this.Target.MemoryManager; + MemoryAllocator memoryAllocator = this.Target.MemoryAllocator; - using (IBuffer amountBuffer = memoryManager.Allocate(scanline.Length)) - using (IBuffer overlay = memoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = memoryAllocator.Allocate(scanline.Length)) + using (IBuffer overlay = memoryAllocator.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.GetSpan(); Span overlaySpan = overlay.GetSpan(); @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes } Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length); - this.Blender.Blend(memoryManager, destinationRow, destinationRow, overlaySpan, amountSpan); + this.Blender.Blend(memoryAllocator, destinationRow, destinationRow, overlaySpan, amountSpan); } } } diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs index a32152ba0..c5ea5792f 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/SolidBrush{TPixel}.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes public SolidBrushApplicator(ImageFrame source, TPixel color, GraphicsOptions options) : base(source, options) { - this.Colors = source.MemoryManager.Allocate(source.Width); + this.Colors = source.MemoryAllocator.Allocate(source.Width); this.Colors.GetSpan().Fill(color); } @@ -88,15 +88,15 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length); - MemoryManager memoryManager = this.Target.MemoryManager; + MemoryAllocator memoryAllocator = this.Target.MemoryAllocator; if (this.Options.BlendPercentage == 1f) { - this.Blender.Blend(memoryManager, destinationRow, destinationRow, this.Colors.GetSpan(), scanline); + this.Blender.Blend(memoryAllocator, destinationRow, destinationRow, this.Colors.GetSpan(), scanline); } else { - using (IBuffer amountBuffer = memoryManager.Allocate(scanline.Length)) + using (IBuffer amountBuffer = memoryAllocator.Allocate(scanline.Length)) { Span amountSpan = amountBuffer.GetSpan(); @@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes amountSpan[i] = scanline[i] * this.Options.BlendPercentage; } - this.Blender.Blend(memoryManager, destinationRow, destinationRow, this.Colors.GetSpan(), amountSpan); + this.Blender.Blend(memoryAllocator, destinationRow, destinationRow, this.Colors.GetSpan(), amountSpan); } } } diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs index c5691aa64..38805c517 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/DrawImageProcessor.cs @@ -133,9 +133,9 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors int width = maxX - minX; - MemoryManager memoryManager = this.Image.GetConfiguration().MemoryManager; + MemoryAllocator memoryAllocator = this.Image.GetConfiguration().MemoryAllocator; - using (IBuffer amount = memoryManager.Allocate(width)) + using (IBuffer amount = memoryAllocator.Allocate(width)) { amount.GetSpan().Fill(this.Opacity); @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors { Span background = source.GetPixelRowSpan(y).Slice(minX, width); Span foreground = targetImage.GetPixelRowSpan(y - locationY).Slice(targetX, width); - blender.Blend(memoryManager, background, background, foreground, amount.GetSpan()); + blender.Blend(memoryAllocator, background, background, foreground, amount.GetSpan()); }); } } diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs index 3cf2f7d63..7a0b7a05d 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillProcessor.cs @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors startY = 0; } - using (IBuffer amount = source.MemoryManager.Allocate(width)) + using (IBuffer amount = source.MemoryAllocator.Allocate(width)) using (BrushApplicator applicator = this.brush.CreateApplicator( source, sourceRectangle, diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs index 4072f88a8..916da360b 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Processors/FillRegionProcessor.cs @@ -96,8 +96,8 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Processors using (BrushApplicator applicator = this.Brush.CreateApplicator(source, rect, this.Options)) { int scanlineWidth = maxX - minX; - using (IBuffer bBuffer = source.MemoryManager.Allocate(maxIntersections)) - using (IBuffer bScanline = source.MemoryManager.Allocate(scanlineWidth)) + using (IBuffer bBuffer = source.MemoryAllocator.Allocate(maxIntersections)) + using (IBuffer bScanline = source.MemoryAllocator.Allocate(scanlineWidth)) { bool scanlineDirty = true; float subpixelFraction = 1f / subpixelCount; diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs index 1d7f33a9a..337f82e03 100644 --- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs +++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs @@ -144,12 +144,12 @@ namespace SixLabors.ImageSharp.Advanced => ref source.Frames.RootFrame.DangerousGetPinnableReferenceToPixelBuffer(); /// - /// Gets the assigned to 'source'. + /// Gets the assigned to 'source'. /// /// The source image /// Returns the configuration. - internal static MemoryManager GetMemoryManager(this IConfigurable source) - => GetConfiguration(source).MemoryManager; + internal static MemoryAllocator GetMemoryAllocator(this IConfigurable source) + => GetConfiguration(source).MemoryAllocator; /// /// Gets the span to the backing buffer. diff --git a/src/ImageSharp/Common/Helpers/ParallelFor.cs b/src/ImageSharp/Common/Helpers/ParallelFor.cs index da9125905..fc22b42be 100644 --- a/src/ImageSharp/Common/Helpers/ParallelFor.cs +++ b/src/ImageSharp/Common/Helpers/ParallelFor.cs @@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp /// The value type of the buffer /// The start index, inclusive. /// The end index, exclusive. - /// The used for getting the and + /// The used for getting the and /// The length of the requested parallel buffer /// The delegate that is invoked once per iteration. public static void WithTemporaryBuffer( @@ -35,12 +35,12 @@ namespace SixLabors.ImageSharp Action> body) where T : struct { - MemoryManager memoryManager = configuration.MemoryManager; + MemoryAllocator memoryAllocator = configuration.MemoryAllocator; ParallelOptions parallelOptions = configuration.ParallelOptions; IBuffer InitBuffer() { - return memoryManager.Allocate(bufferLength); + return memoryAllocator.Allocate(bufferLength); } void CleanUpBuffer(IBuffer buffer) diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index eb08bc579..f30b5469f 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -75,9 +75,9 @@ namespace SixLabors.ImageSharp public ImageFormatManager ImageFormatsManager { get; set; } = new ImageFormatManager(); /// - /// Gets or sets the that is currently in use. + /// Gets or sets the that is currently in use. /// - public MemoryManager MemoryManager { get; set; } = ArrayPoolMemoryManager.CreateDefault(); + public MemoryAllocator MemoryAllocator { get; set; } = ArrayPoolMemoryAllocator.CreateDefault(); /// /// Gets the maximum header size of all the formats. @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp { ParallelOptions = this.ParallelOptions, ImageFormatsManager = this.ImageFormatsManager, - MemoryManager = this.MemoryManager, + MemoryAllocator = this.MemoryAllocator, ImageOperationsProvider = this.ImageOperationsProvider, ReadOrigin = this.ReadOrigin, diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 43be0004e..b6905a62f 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp private readonly Configuration configuration; - private readonly MemoryManager memoryManager; + private readonly MemoryAllocator memoryAllocator; /// /// Initializes a new instance of the class. @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp public BmpDecoderCore(Configuration configuration, IBmpDecoderOptions options) { this.configuration = configuration; - this.memoryManager = configuration.MemoryManager; + this.memoryAllocator = configuration.MemoryAllocator; } /// @@ -213,7 +213,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp var color = default(TPixel); var rgba = new Rgba32(0, 0, 0, 255); - using (Buffer2D buffer = this.memoryManager.AllocateClean2D(width, height)) + using (Buffer2D buffer = this.memoryAllocator.AllocateClean2D(width, height)) { this.UncompressRle8(width, buffer.GetSpan()); @@ -337,7 +337,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp padding = 4 - padding; } - using (IManagedByteBuffer row = this.memoryManager.AllocateCleanManagedByteBuffer(arrayWidth + padding)) + using (IManagedByteBuffer row = this.memoryAllocator.AllocateCleanManagedByteBuffer(arrayWidth + padding)) { TPixel color = default; var rgba = new Rgba32(0, 0, 0, 255); @@ -389,7 +389,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp var color = default(TPixel); var rgba = new Rgba32(0, 0, 0, 255); - using (IManagedByteBuffer buffer = this.memoryManager.AllocateManagedByteBuffer(stride)) + using (IManagedByteBuffer buffer = this.memoryAllocator.AllocateManagedByteBuffer(stride)) { for (int y = 0; y < height; y++) { @@ -427,7 +427,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp { int padding = CalculatePadding(width, 3); - using (IManagedByteBuffer row = this.memoryManager.AllocatePaddedPixelRowBuffer(width, 3, padding)) + using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 3, padding)) { for (int y = 0; y < height; y++) { @@ -452,7 +452,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp { int padding = CalculatePadding(width, 4); - using (IManagedByteBuffer row = this.memoryManager.AllocatePaddedPixelRowBuffer(width, 4, padding)) + using (IManagedByteBuffer row = this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, 4, padding)) { for (int y = 0; y < height; y++) { diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs index 9edd0fcd4..23b01ae9e 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp public void Encode(Image image, Stream stream) where TPixel : struct, IPixel { - var encoder = new BmpEncoderCore(this, image.GetMemoryManager()); + var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator()); encoder.Encode(image, stream); } } diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index aefcda402..aff0c024d 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -20,16 +20,16 @@ namespace SixLabors.ImageSharp.Formats.Bmp private readonly BmpBitsPerPixel bitsPerPixel; - private readonly MemoryManager memoryManager; + private readonly MemoryAllocator memoryAllocator; /// /// Initializes a new instance of the class. /// /// The encoder options - /// The memory manager - public BmpEncoderCore(IBmpEncoderOptions options, MemoryManager memoryManager) + /// The memory manager + public BmpEncoderCore(IBmpEncoderOptions options, MemoryAllocator memoryAllocator) { - this.memoryManager = memoryManager; + this.memoryAllocator = memoryAllocator; this.bitsPerPixel = options.BitsPerPixel; } @@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp private IManagedByteBuffer AllocateRow(int width, int bytesPerPixel) { - return this.memoryManager.AllocatePaddedPixelRowBuffer(width, bytesPerPixel, this.padding); + return this.memoryAllocator.AllocatePaddedPixelRowBuffer(width, bytesPerPixel, this.padding); } /// diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index d37682a3d..bba983af8 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// public FrameDecodingMode DecodingMode { get; } - private MemoryManager MemoryManager => this.configuration.MemoryManager; + private MemoryAllocator MemoryAllocator => this.configuration.MemoryAllocator; /// /// Decodes the stream to the image. @@ -293,7 +293,7 @@ namespace SixLabors.ImageSharp.Formats.Gif continue; } - using (IManagedByteBuffer commentsBuffer = this.MemoryManager.AllocateManagedByteBuffer(length)) + using (IManagedByteBuffer commentsBuffer = this.MemoryAllocator.AllocateManagedByteBuffer(length)) { this.stream.Read(commentsBuffer.Array, 0, length); string comments = this.TextEncoding.GetString(commentsBuffer.Array, 0, length); @@ -321,11 +321,11 @@ namespace SixLabors.ImageSharp.Formats.Gif if (imageDescriptor.LocalColorTableFlag) { int length = imageDescriptor.LocalColorTableSize * 3; - localColorTable = this.configuration.MemoryManager.AllocateManagedByteBuffer(length, true); + localColorTable = this.configuration.MemoryAllocator.AllocateManagedByteBuffer(length, true); this.stream.Read(localColorTable.Array, 0, length); } - indices = this.configuration.MemoryManager.AllocateManagedByteBuffer(imageDescriptor.Width * imageDescriptor.Height, true); + indices = this.configuration.MemoryAllocator.AllocateManagedByteBuffer(imageDescriptor.Width * imageDescriptor.Height, true); this.ReadFrameIndices(imageDescriptor, indices.GetSpan()); ReadOnlySpan colorTable = MemoryMarshal.Cast((localColorTable ?? this.globalColorTable).GetSpan()); @@ -350,7 +350,7 @@ namespace SixLabors.ImageSharp.Formats.Gif private void ReadFrameIndices(in GifImageDescriptor imageDescriptor, Span indices) { int dataSize = this.stream.ReadByte(); - using (var lzwDecoder = new LzwDecoder(this.configuration.MemoryManager, this.stream)) + using (var lzwDecoder = new LzwDecoder(this.configuration.MemoryAllocator, this.stream)) { lzwDecoder.DecodePixels(imageDescriptor.Width, imageDescriptor.Height, dataSize, indices); } @@ -528,7 +528,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { int globalColorTableLength = this.logicalScreenDescriptor.GlobalColorTableSize * 3; - this.globalColorTable = this.MemoryManager.AllocateManagedByteBuffer(globalColorTableLength, true); + this.globalColorTable = this.MemoryAllocator.AllocateManagedByteBuffer(globalColorTableLength, true); // Read the global color table data from the stream stream.Read(this.globalColorTable.Array, 0, globalColorTableLength); diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs index fb072bcb7..a07928b04 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoder.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Gif public void Encode(Image image, Stream stream) where TPixel : struct, IPixel { - var encoder = new GifEncoderCore(image.GetConfiguration().MemoryManager, this); + var encoder = new GifEncoderCore(image.GetConfiguration().MemoryAllocator, this); encoder.Encode(image, stream); } } diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 6f134c4bd..8de347086 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Gif /// internal sealed class GifEncoderCore { - private readonly MemoryManager memoryManager; + private readonly MemoryAllocator memoryAllocator; /// /// A reusable buffer used to reduce allocations. @@ -49,11 +49,11 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The options for the encoder. - public GifEncoderCore(MemoryManager memoryManager, IGifEncoderOptions options) + public GifEncoderCore(MemoryAllocator memoryAllocator, IGifEncoderOptions options) { - this.memoryManager = memoryManager; + this.memoryAllocator = memoryAllocator; this.textEncoding = options.TextEncoding ?? GifConstants.DefaultEncoding; this.quantizer = options.Quantizer; this.ignoreMetadata = options.IgnoreMetadata; @@ -317,7 +317,7 @@ namespace SixLabors.ImageSharp.Formats.Gif int colorTableLength = (int)Math.Pow(2, this.bitDepth) * 3; // The maximium number of colors for the bit depth Rgb24 rgb = default; - using (IManagedByteBuffer colorTable = this.memoryManager.AllocateManagedByteBuffer(colorTableLength)) + using (IManagedByteBuffer colorTable = this.memoryAllocator.AllocateManagedByteBuffer(colorTableLength)) { ref TPixel paletteRef = ref MemoryMarshal.GetReference(image.Palette.AsSpan()); ref Rgb24 rgb24Ref = ref Unsafe.As(ref MemoryMarshal.GetReference(colorTable.GetSpan())); @@ -342,7 +342,7 @@ namespace SixLabors.ImageSharp.Formats.Gif private void WriteImageData(QuantizedFrame image, Stream stream) where TPixel : struct, IPixel { - using (var encoder = new LzwEncoder(this.memoryManager, image.Pixels, (byte)this.bitDepth)) + using (var encoder = new LzwEncoder(this.memoryAllocator, image.Pixels, (byte)this.bitDepth)) { encoder.Encode(stream); } diff --git a/src/ImageSharp/Formats/Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs index f52a8b240..aaf0547b9 100644 --- a/src/ImageSharp/Formats/Gif/LzwDecoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwDecoder.cs @@ -48,18 +48,18 @@ namespace SixLabors.ImageSharp.Formats.Gif /// Initializes a new instance of the class /// and sets the stream, where the compressed data should be read from. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The stream to read from. /// is null. - public LzwDecoder(MemoryManager memoryManager, Stream stream) + public LzwDecoder(MemoryAllocator memoryAllocator, Stream stream) { Guard.NotNull(stream, nameof(stream)); this.stream = stream; - this.prefix = memoryManager.Allocate(MaxStackSize, true); - this.suffix = memoryManager.Allocate(MaxStackSize, true); - this.pixelStack = memoryManager.Allocate(MaxStackSize + 1, true); + this.prefix = memoryAllocator.Allocate(MaxStackSize, true); + this.suffix = memoryAllocator.Allocate(MaxStackSize, true); + this.pixelStack = memoryAllocator.Allocate(MaxStackSize + 1, true); } /// diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs index a23d2f4e2..f3e75b6f6 100644 --- a/src/ImageSharp/Formats/Gif/LzwEncoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwEncoder.cs @@ -168,16 +168,16 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The array of indexed pixels. /// The color depth in bits. - public LzwEncoder(MemoryManager memoryManager, byte[] indexedPixels, int colorDepth) + public LzwEncoder(MemoryAllocator memoryAllocator, byte[] indexedPixels, int colorDepth) { this.pixelArray = indexedPixels; this.initialCodeSize = Math.Max(2, colorDepth); - this.hashTable = memoryManager.Allocate(HashSize, true); - this.codeTable = memoryManager.Allocate(HashSize, true); + this.hashTable = memoryAllocator.Allocate(HashSize, true); + this.codeTable = memoryAllocator.Allocate(HashSize, true); } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs index fe18f8438..edb34bc03 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponentPostProcessor.cs @@ -26,11 +26,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// /// Initializes a new instance of the class. /// - public JpegComponentPostProcessor(MemoryManager memoryManager, JpegImagePostProcessor imagePostProcessor, IJpegComponent component) + public JpegComponentPostProcessor(MemoryAllocator memoryAllocator, JpegImagePostProcessor imagePostProcessor, IJpegComponent component) { this.Component = component; this.ImagePostProcessor = imagePostProcessor; - this.ColorBuffer = memoryManager.Allocate2D( + this.ColorBuffer = memoryAllocator.Allocate2D( imagePostProcessor.PostProcessorBufferSize.Width, imagePostProcessor.PostProcessorBufferSize.Height); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs index a8def1e19..1a7f8bebb 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs @@ -49,17 +49,17 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The representing the uncompressed spectral Jpeg data - public JpegImagePostProcessor(MemoryManager memoryManager, IRawJpegData rawJpeg) + public JpegImagePostProcessor(MemoryAllocator memoryAllocator, IRawJpegData rawJpeg) { this.RawJpeg = rawJpeg; IJpegComponent c0 = rawJpeg.Components.First(); this.NumberOfPostProcessorSteps = c0.SizeInBlocks.Height / BlockRowsPerStep; this.PostProcessorBufferSize = new Size(c0.SizeInBlocks.Width * 8, PixelRowsPerStep); - this.ComponentProcessors = rawJpeg.Components.Select(c => new JpegComponentPostProcessor(memoryManager, this, c)).ToArray(); - this.rgbaBuffer = memoryManager.Allocate(rawJpeg.ImageSizeInPixels.Width); + this.ComponentProcessors = rawJpeg.Components.Select(c => new JpegComponentPostProcessor(memoryAllocator, this, c)).ToArray(); + this.rgbaBuffer = memoryAllocator.Allocate(rawJpeg.ImageSizeInPixels.Width); this.colorConverter = JpegColorConverter.GetConverter(rawJpeg.ColorSpace); } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs index bb3bd01aa..2335800c2 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/GolangComponent.cs @@ -56,9 +56,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder /// /// Initializes /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The instance - public void InitializeDerivedData(MemoryManager memoryManager, GolangJpegDecoderCore decoder) + public void InitializeDerivedData(MemoryAllocator memoryAllocator, GolangJpegDecoderCore decoder) { // For 4-component images (either CMYK or YCbCrK), we only support two // hv vectors: [0x11 0x11 0x11 0x11] and [0x22 0x11 0x11 0x22]. @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.SubSamplingDivisors = c0.SamplingFactors.DivideBy(this.SamplingFactors); } - this.SpectralBlocks = memoryManager.Allocate2D(this.SizeInBlocks.Width, this.SizeInBlocks.Height, true); + this.SpectralBlocks = memoryAllocator.Allocate2D(this.SizeInBlocks.Width, this.SizeInBlocks.Height, true); } /// diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs index 86f97d224..34a6e2f0f 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs @@ -705,7 +705,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort foreach (GolangComponent component in this.Components) { - component.InitializeDerivedData(this.configuration.MemoryManager, this); + component.InitializeDerivedData(this.configuration.MemoryAllocator, this); } } } @@ -812,7 +812,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort private Image PostProcessIntoImage() where TPixel : struct, IPixel { - using (var postProcessor = new JpegImagePostProcessor(this.configuration.MemoryManager, this)) + using (var postProcessor = new JpegImagePostProcessor(this.configuration.MemoryAllocator, this)) { var image = new Image(this.configuration, this.ImageWidth, this.ImageHeight, this.MetaData); postProcessor.PostProcess(image.Frames.RootFrame); diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/DoubleBufferedStreamReader.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/DoubleBufferedStreamReader.cs index eb91590e8..ae1dbf75e 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/DoubleBufferedStreamReader.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/DoubleBufferedStreamReader.cs @@ -38,13 +38,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The input stream. - public DoubleBufferedStreamReader(MemoryManager memoryManager, Stream stream) + public DoubleBufferedStreamReader(MemoryAllocator memoryAllocator, Stream stream) { this.stream = stream; this.length = (int)stream.Length; - this.managedBuffer = memoryManager.AllocateCleanManagedByteBuffer(ChunkLength); + this.managedBuffer = memoryAllocator.AllocateCleanManagedByteBuffer(ChunkLength); this.bufferChunk = this.managedBuffer.Array; } diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs index 70ac760e6..9a17b2dfa 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs @@ -17,11 +17,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components /// internal class PdfJsFrameComponent : IDisposable, IJpegComponent { - private readonly MemoryManager memoryManager; + private readonly MemoryAllocator memoryAllocator; - public PdfJsFrameComponent(MemoryManager memoryManager, PdfJsFrame frame, byte id, int horizontalFactor, int verticalFactor, byte quantizationTableIndex, int index) + public PdfJsFrameComponent(MemoryAllocator memoryAllocator, PdfJsFrame frame, byte id, int horizontalFactor, int verticalFactor, byte quantizationTableIndex, int index) { - this.memoryManager = memoryManager; + this.memoryAllocator = memoryAllocator; this.Frame = frame; this.Id = id; this.HorizontalSamplingFactor = horizontalFactor; @@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components this.SubSamplingDivisors = c0.SamplingFactors.DivideBy(this.SamplingFactors); } - this.SpectralBlocks = this.memoryManager.Allocate2D(blocksPerColumnForMcu, blocksPerLineForMcu + 1, true); + this.SpectralBlocks = this.memoryAllocator.Allocate2D(blocksPerColumnForMcu, blocksPerLineForMcu + 1, true); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs index e8e0054f2..4a8f9debe 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs @@ -37,14 +37,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components /// /// Initializes a new instance of the struct. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The code lengths /// The huffman values - public PdfJsHuffmanTable(MemoryManager memoryManager, ReadOnlySpan lengths, ReadOnlySpan values) + public PdfJsHuffmanTable(MemoryAllocator memoryAllocator, ReadOnlySpan lengths, ReadOnlySpan values) { const int length = 257; - using (IBuffer huffsize = memoryManager.Allocate(length)) - using (IBuffer huffcode = memoryManager.Allocate(length)) + using (IBuffer huffsize = memoryAllocator.Allocate(length)) + using (IBuffer huffcode = memoryAllocator.Allocate(length)) { ref short huffsizeRef = ref MemoryMarshal.GetReference(huffsize.GetSpan()); ref short huffcodeRef = ref MemoryMarshal.GetReference(huffcode.GetSpan()); diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs index 69994ee59..625c8f691 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs @@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort public void ParseStream(Stream stream, bool metadataOnly = false) { this.MetaData = new ImageMetaData(); - this.InputStream = new DoubleBufferedStreamReader(this.configuration.MemoryManager, stream); + this.InputStream = new DoubleBufferedStreamReader(this.configuration.MemoryAllocator, stream); // Check for the Start Of Image marker. this.InputStream.Read(this.markerBuffer, 0, 2); @@ -675,7 +675,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort maxV = v; } - var component = new PdfJsFrameComponent(this.configuration.MemoryManager, this.Frame, this.temp[index], h, v, this.temp[index + 2], i); + var component = new PdfJsFrameComponent(this.configuration.MemoryAllocator, this.Frame, this.temp[index], h, v, this.temp[index + 2], i); this.Frame.Components[i] = component; this.Frame.ComponentIds[i] = component.Id; @@ -703,7 +703,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort throw new ImageFormatException($"DHT has wrong length: {remaining}"); } - using (IManagedByteBuffer huffmanData = this.configuration.MemoryManager.AllocateCleanManagedByteBuffer(256)) + using (IManagedByteBuffer huffmanData = this.configuration.MemoryAllocator.AllocateCleanManagedByteBuffer(256)) { ref byte huffmanDataRef = ref MemoryMarshal.GetReference(huffmanData.GetSpan()); for (int i = 2; i < remaining;) @@ -711,7 +711,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort byte huffmanTableSpec = (byte)this.InputStream.ReadByte(); this.InputStream.Read(huffmanData.Array, 0, 16); - using (IManagedByteBuffer codeLengths = this.configuration.MemoryManager.AllocateCleanManagedByteBuffer(17)) + using (IManagedByteBuffer codeLengths = this.configuration.MemoryAllocator.AllocateCleanManagedByteBuffer(17)) { ref byte codeLengthsRef = ref MemoryMarshal.GetReference(codeLengths.GetSpan()); int codeLengthSum = 0; @@ -721,7 +721,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort codeLengthSum += Unsafe.Add(ref codeLengthsRef, j) = Unsafe.Add(ref huffmanDataRef, j - 1); } - using (IManagedByteBuffer huffmanValues = this.configuration.MemoryManager.AllocateCleanManagedByteBuffer(256)) + using (IManagedByteBuffer huffmanValues = this.configuration.MemoryAllocator.AllocateCleanManagedByteBuffer(256)) { this.InputStream.Read(huffmanValues.Array, 0, codeLengthSum); @@ -817,7 +817,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort [MethodImpl(MethodImplOptions.AggressiveInlining)] private void BuildHuffmanTable(PdfJsHuffmanTables tables, int index, ReadOnlySpan codeLengths, ReadOnlySpan values) { - tables[index] = new PdfJsHuffmanTable(this.configuration.MemoryManager, codeLengths, values); + tables[index] = new PdfJsHuffmanTable(this.configuration.MemoryAllocator, codeLengths, values); } /// @@ -834,7 +834,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort private Image PostProcessIntoImage() where TPixel : struct, IPixel { - using (var postProcessor = new JpegImagePostProcessor(this.configuration.MemoryManager, this)) + using (var postProcessor = new JpegImagePostProcessor(this.configuration.MemoryAllocator, this)) { var image = new Image(this.configuration, this.ImageWidth, this.ImageHeight, this.MetaData); postProcessor.PostProcess(image.Frames.RootFrame); diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 15edf2ad3..f481dc508 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -188,7 +188,7 @@ namespace SixLabors.ImageSharp.Formats.Png this.ignoreMetadata = options.IgnoreMetadata; } - private MemoryManager MemoryManager => this.configuration.MemoryManager; + private MemoryAllocator MemoryAllocator => this.configuration.MemoryAllocator; /// /// Decodes the stream to the image. @@ -410,8 +410,8 @@ namespace SixLabors.ImageSharp.Formats.Png this.bytesPerSample = this.header.BitDepth / 8; } - this.previousScanline = this.MemoryManager.AllocateCleanManagedByteBuffer(this.bytesPerScanline); - this.scanline = this.configuration.MemoryManager.AllocateCleanManagedByteBuffer(this.bytesPerScanline); + this.previousScanline = this.MemoryAllocator.AllocateCleanManagedByteBuffer(this.bytesPerScanline); + this.scanline = this.configuration.MemoryAllocator.AllocateCleanManagedByteBuffer(this.bytesPerScanline); } /// @@ -727,7 +727,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (this.header.BitDepth == 16) { int length = this.header.Width * 3; - using (IBuffer compressed = this.configuration.MemoryManager.Allocate(length)) + using (IBuffer compressed = this.configuration.MemoryAllocator.Allocate(length)) { // TODO: Should we use pack from vector here instead? this.From16BitTo8Bit(scanlineBuffer, compressed.GetSpan(), length); @@ -744,7 +744,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (this.header.BitDepth == 16) { int length = this.header.Width * 3; - using (IBuffer compressed = this.configuration.MemoryManager.Allocate(length)) + using (IBuffer compressed = this.configuration.MemoryAllocator.Allocate(length)) { // TODO: Should we use pack from vector here instead? this.From16BitTo8Bit(scanlineBuffer, compressed.GetSpan(), length); @@ -785,7 +785,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (this.header.BitDepth == 16) { int length = this.header.Width * 4; - using (IBuffer compressed = this.configuration.MemoryManager.Allocate(length)) + using (IBuffer compressed = this.configuration.MemoryAllocator.Allocate(length)) { // TODO: Should we use pack from vector here instead? this.From16BitTo8Bit(scanlineBuffer, compressed.GetSpan(), length); @@ -984,7 +984,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (this.header.BitDepth == 16) { int length = this.header.Width * 3; - using (IBuffer compressed = this.configuration.MemoryManager.Allocate(length)) + using (IBuffer compressed = this.configuration.MemoryAllocator.Allocate(length)) { Span compressedSpan = compressed.GetSpan(); @@ -1054,7 +1054,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (this.header.BitDepth == 16) { int length = this.header.Width * 4; - using (IBuffer compressed = this.configuration.MemoryManager.Allocate(length)) + using (IBuffer compressed = this.configuration.MemoryAllocator.Allocate(length)) { Span compressedSpan = compressed.GetSpan(); @@ -1273,7 +1273,7 @@ namespace SixLabors.ImageSharp.Formats.Png private IManagedByteBuffer ReadChunkData(int length) { // We rent the buffer here to return it afterwards in Decode() - IManagedByteBuffer buffer = this.configuration.MemoryManager.AllocateCleanManagedByteBuffer(length); + IManagedByteBuffer buffer = this.configuration.MemoryAllocator.AllocateCleanManagedByteBuffer(length); this.currentStream.Read(buffer.Array, 0, length); diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index b39a6353e..fab1b5185 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Formats.Png public void Encode(Image image, Stream stream) where TPixel : struct, IPixel { - using (var encoder = new PngEncoderCore(image.GetMemoryManager(), this)) + using (var encoder = new PngEncoderCore(image.GetMemoryAllocator(), this)) { encoder.Encode(image, stream); } diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index b9e09070e..1e6c186ec 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// internal sealed class PngEncoderCore : IDisposable { - private readonly MemoryManager memoryManager; + private readonly MemoryAllocator memoryAllocator; /// /// The maximum block size, defaults at 64k for uncompressed blocks. @@ -144,11 +144,11 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. + /// The to use for buffer allocations. /// The options for influencing the encoder - public PngEncoderCore(MemoryManager memoryManager, IPngEncoderOptions options) + public PngEncoderCore(MemoryAllocator memoryAllocator, IPngEncoderOptions options) { - this.memoryManager = memoryManager; + this.memoryAllocator = memoryAllocator; this.pngColorType = options.PngColorType; this.pngFilterMethod = options.PngFilterMethod; this.compressionLevel = options.CompressionLevel; @@ -460,8 +460,8 @@ namespace SixLabors.ImageSharp.Formats.Png Rgba32 rgba = default; bool anyAlpha = false; - using (IManagedByteBuffer colorTable = this.memoryManager.AllocateManagedByteBuffer(colorTableLength)) - using (IManagedByteBuffer alphaTable = this.memoryManager.AllocateManagedByteBuffer(pixelCount)) + using (IManagedByteBuffer colorTable = this.memoryAllocator.AllocateManagedByteBuffer(colorTableLength)) + using (IManagedByteBuffer alphaTable = this.memoryAllocator.AllocateManagedByteBuffer(pixelCount)) { Span colorTableSpan = colorTable.GetSpan(); Span alphaTableSpan = alphaTable.GetSpan(); @@ -552,16 +552,16 @@ namespace SixLabors.ImageSharp.Formats.Png this.bytesPerScanline = this.width * this.bytesPerPixel; int resultLength = this.bytesPerScanline + 1; - this.previousScanline = this.memoryManager.AllocateCleanManagedByteBuffer(this.bytesPerScanline); - this.rawScanline = this.memoryManager.AllocateCleanManagedByteBuffer(this.bytesPerScanline); - this.result = this.memoryManager.AllocateCleanManagedByteBuffer(resultLength); + this.previousScanline = this.memoryAllocator.AllocateCleanManagedByteBuffer(this.bytesPerScanline); + this.rawScanline = this.memoryAllocator.AllocateCleanManagedByteBuffer(this.bytesPerScanline); + this.result = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); if (this.pngColorType != PngColorType.Palette) { - this.sub = this.memoryManager.AllocateCleanManagedByteBuffer(resultLength); - this.up = this.memoryManager.AllocateCleanManagedByteBuffer(resultLength); - this.average = this.memoryManager.AllocateCleanManagedByteBuffer(resultLength); - this.paeth = this.memoryManager.AllocateCleanManagedByteBuffer(resultLength); + this.sub = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); + this.up = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); + this.average = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); + this.paeth = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); } byte[] buffer; diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 3f3dbb7e2..bd602875a 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp return null; } - using (IManagedByteBuffer buffer = config.MemoryManager.AllocateManagedByteBuffer(maxHeaderSize)) + using (IManagedByteBuffer buffer = config.MemoryAllocator.AllocateManagedByteBuffer(maxHeaderSize)) { long startPosition = stream.Position; stream.Read(buffer.Array, 0, maxHeaderSize); diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index a41a2bf3b..c6471df14 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -85,8 +85,8 @@ namespace SixLabors.ImageSharp Guard.NotNull(metaData, nameof(metaData)); this.configuration = configuration; - this.MemoryManager = configuration.MemoryManager; - this.PixelBuffer = this.MemoryManager.Allocate2D(width, height, false); + this.MemoryAllocator = configuration.MemoryAllocator; + this.PixelBuffer = this.MemoryAllocator.Allocate2D(width, height, false); this.MetaData = metaData; this.Clear(configuration.ParallelOptions, backgroundColor); } @@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp Guard.NotNull(metaData, nameof(metaData)); this.configuration = configuration; - this.MemoryManager = configuration.MemoryManager; + this.MemoryAllocator = configuration.MemoryAllocator; this.PixelBuffer = new Buffer2D(consumedBuffer, width, height); this.MetaData = metaData; } @@ -131,16 +131,16 @@ namespace SixLabors.ImageSharp Guard.NotNull(source, nameof(source)); this.configuration = configuration; - this.MemoryManager = configuration.MemoryManager; - this.PixelBuffer = this.MemoryManager.Allocate2D(source.PixelBuffer.Width, source.PixelBuffer.Height); + this.MemoryAllocator = configuration.MemoryAllocator; + this.PixelBuffer = this.MemoryAllocator.Allocate2D(source.PixelBuffer.Width, source.PixelBuffer.Height); source.PixelBuffer.GetSpan().CopyTo(this.PixelBuffer.GetSpan()); this.MetaData = source.MetaData.Clone(); } /// - /// Gets the to use for buffer allocations. + /// Gets the to use for buffer allocations. /// - public MemoryManager MemoryManager { get; } + public MemoryAllocator MemoryAllocator { get; } /// /// Gets the image pixels. Not private as Buffer2D requires an array in its constructor. diff --git a/src/ImageSharp/Memory/ArrayPoolMemoryManager.Buffer{T}.cs b/src/ImageSharp/Memory/ArrayPoolMemoryAllocator.Buffer{T}.cs similarity index 91% rename from src/ImageSharp/Memory/ArrayPoolMemoryManager.Buffer{T}.cs rename to src/ImageSharp/Memory/ArrayPoolMemoryAllocator.Buffer{T}.cs index afa5fdbb4..2216003e5 100644 --- a/src/ImageSharp/Memory/ArrayPoolMemoryManager.Buffer{T}.cs +++ b/src/ImageSharp/Memory/ArrayPoolMemoryAllocator.Buffer{T}.cs @@ -10,10 +10,10 @@ namespace SixLabors.ImageSharp.Memory /// /// Contains and /// - public partial class ArrayPoolMemoryManager + public partial class ArrayPoolMemoryAllocator { /// - /// The buffer implementation of . + /// The buffer implementation of . /// In this implementation is owned. /// private class Buffer : ManagedBufferBase, IBuffer @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Memory /// /// /// By using a weak reference here, we are making sure that array pools and their retained arrays are always GC-ed - /// after a call to , regardless of having buffer instances still being in use. + /// after a call to , regardless of having buffer instances still being in use. /// private WeakReference> sourcePoolReference; @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Memory } /// - /// The implementation of . + /// The implementation of . /// private class ManagedByteBuffer : Buffer, IManagedByteBuffer { diff --git a/src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs b/src/ImageSharp/Memory/ArrayPoolMemoryAllocator.CommonFactoryMethods.cs similarity index 77% rename from src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs rename to src/ImageSharp/Memory/ArrayPoolMemoryAllocator.CommonFactoryMethods.cs index 53d7fc021..0f115764b 100644 --- a/src/ImageSharp/Memory/ArrayPoolMemoryManager.CommonFactoryMethods.cs +++ b/src/ImageSharp/Memory/ArrayPoolMemoryAllocator.CommonFactoryMethods.cs @@ -5,7 +5,7 @@ namespace SixLabors.ImageSharp.Memory /// /// Contains common factory methods and configuration constants. /// - public partial class ArrayPoolMemoryManager + public partial class ArrayPoolMemoryAllocator { /// /// The default value for: maximum size of pooled arrays in bytes. @@ -32,9 +32,9 @@ namespace SixLabors.ImageSharp.Memory /// This is the default. Should be good for most use cases. /// /// The memory manager - public static ArrayPoolMemoryManager CreateDefault() + public static ArrayPoolMemoryAllocator CreateDefault() { - return new ArrayPoolMemoryManager( + return new ArrayPoolMemoryAllocator( DefaultMaxPooledBufferSizeInBytes, DefaultBufferSelectorThresholdInBytes, DefaultLargePoolBucketCount, @@ -45,27 +45,27 @@ namespace SixLabors.ImageSharp.Memory /// For environments with limited memory capabilities. Only small images are pooled, which can result in reduced througput. /// /// The memory manager - public static ArrayPoolMemoryManager CreateWithModeratePooling() + public static ArrayPoolMemoryAllocator CreateWithModeratePooling() { - return new ArrayPoolMemoryManager(1024 * 1024, 32 * 1024, 16, 24); + return new ArrayPoolMemoryAllocator(1024 * 1024, 32 * 1024, 16, 24); } /// /// Only pool small buffers like image rows. /// /// The memory manager - public static ArrayPoolMemoryManager CreateWithMinimalPooling() + public static ArrayPoolMemoryAllocator CreateWithMinimalPooling() { - return new ArrayPoolMemoryManager(64 * 1024, 32 * 1024, 8, 24); + return new ArrayPoolMemoryAllocator(64 * 1024, 32 * 1024, 8, 24); } /// /// RAM is not an issue for me, gimme maximum througput! /// /// The memory manager - public static ArrayPoolMemoryManager CreateWithAggressivePooling() + public static ArrayPoolMemoryAllocator CreateWithAggressivePooling() { - return new ArrayPoolMemoryManager(128 * 1024 * 1024, 32 * 1024 * 1024, 16, 32); + return new ArrayPoolMemoryAllocator(128 * 1024 * 1024, 32 * 1024 * 1024, 16, 32); } } } \ No newline at end of file diff --git a/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs b/src/ImageSharp/Memory/ArrayPoolMemoryAllocator.cs similarity index 88% rename from src/ImageSharp/Memory/ArrayPoolMemoryManager.cs rename to src/ImageSharp/Memory/ArrayPoolMemoryAllocator.cs index 7b8c7ab32..8bc88a5cf 100644 --- a/src/ImageSharp/Memory/ArrayPoolMemoryManager.cs +++ b/src/ImageSharp/Memory/ArrayPoolMemoryAllocator.cs @@ -7,9 +7,9 @@ using System.Runtime.CompilerServices; namespace SixLabors.ImageSharp.Memory { /// - /// Implements by allocating memory from . + /// Implements by allocating memory from . /// - public partial class ArrayPoolMemoryManager : MemoryManager + public partial class ArrayPoolMemoryAllocator : MemoryAllocator { /// /// The for small-to-medium buffers which is not kept clean. @@ -26,40 +26,40 @@ namespace SixLabors.ImageSharp.Memory private readonly int maxArraysPerBucketLargePool; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public ArrayPoolMemoryManager() + public ArrayPoolMemoryAllocator() : this(DefaultMaxPooledBufferSizeInBytes, DefaultBufferSelectorThresholdInBytes) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The maximum size of pooled arrays. Arrays over the thershold are gonna be always allocated. - public ArrayPoolMemoryManager(int maxPoolSizeInBytes) + public ArrayPoolMemoryAllocator(int maxPoolSizeInBytes) : this(maxPoolSizeInBytes, GetLargeBufferThresholdInBytes(maxPoolSizeInBytes)) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The maximum size of pooled arrays. Arrays over the thershold are gonna be always allocated. /// Arrays over this threshold will be pooled in which has less buckets for memory safety. - public ArrayPoolMemoryManager(int maxPoolSizeInBytes, int poolSelectorThresholdInBytes) + public ArrayPoolMemoryAllocator(int maxPoolSizeInBytes, int poolSelectorThresholdInBytes) : this(maxPoolSizeInBytes, poolSelectorThresholdInBytes, DefaultLargePoolBucketCount, DefaultNormalPoolBucketCount) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The maximum size of pooled arrays. Arrays over the thershold are gonna be always allocated. /// The threshold to pool arrays in which has less buckets for memory safety. /// Max arrays per bucket for the large array pool /// Max arrays per bucket for the normal array pool - public ArrayPoolMemoryManager(int maxPoolSizeInBytes, int poolSelectorThresholdInBytes, int maxArraysPerBucketLargePool, int maxArraysPerBucketNormalPool) + public ArrayPoolMemoryAllocator(int maxPoolSizeInBytes, int poolSelectorThresholdInBytes, int maxArraysPerBucketLargePool, int maxArraysPerBucketNormalPool) { Guard.MustBeGreaterThan(maxPoolSizeInBytes, 0, nameof(maxPoolSizeInBytes)); Guard.MustBeLessThanOrEqualTo(poolSelectorThresholdInBytes, maxPoolSizeInBytes, nameof(poolSelectorThresholdInBytes)); diff --git a/src/ImageSharp/Memory/MemoryManager.cs b/src/ImageSharp/Memory/MemoryAllocator.cs similarity index 97% rename from src/ImageSharp/Memory/MemoryManager.cs rename to src/ImageSharp/Memory/MemoryAllocator.cs index 32b1c2001..c62128fd2 100644 --- a/src/ImageSharp/Memory/MemoryManager.cs +++ b/src/ImageSharp/Memory/MemoryAllocator.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Memory /// /// Memory managers are used to allocate memory for image processing operations. /// - public abstract class MemoryManager + public abstract class MemoryAllocator { /// /// Allocates an of size , optionally diff --git a/src/ImageSharp/Memory/MemoryManagerExtensions.cs b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs similarity index 52% rename from src/ImageSharp/Memory/MemoryManagerExtensions.cs rename to src/ImageSharp/Memory/MemoryAllocatorExtensions.cs index 206000245..1a92b7567 100644 --- a/src/ImageSharp/Memory/MemoryManagerExtensions.cs +++ b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs @@ -3,9 +3,9 @@ namespace SixLabors.ImageSharp.Memory { /// - /// Extension methods for . + /// Extension methods for . /// - internal static class MemoryManagerExtensions + internal static class MemoryAllocatorExtensions { /// /// Allocates a of size . @@ -13,67 +13,67 @@ namespace SixLabors.ImageSharp.Memory /// returning, so it may contain data from an earlier use. /// /// Type of the data stored in the buffer - /// The + /// The /// Size of the buffer to allocate /// A buffer of values of type . - public static IBuffer Allocate(this MemoryManager memoryManager, int length) + public static IBuffer Allocate(this MemoryAllocator memoryAllocator, int length) where T : struct { - return memoryManager.Allocate(length, false); + return memoryAllocator.Allocate(length, false); } - public static IBuffer AllocateClean(this MemoryManager memoryManager, int length) + public static IBuffer AllocateClean(this MemoryAllocator memoryAllocator, int length) where T : struct { - return memoryManager.Allocate(length, true); + return memoryAllocator.Allocate(length, true); } - public static IManagedByteBuffer AllocateManagedByteBuffer(this MemoryManager memoryManager, int length) + public static IManagedByteBuffer AllocateManagedByteBuffer(this MemoryAllocator memoryAllocator, int length) { - return memoryManager.AllocateManagedByteBuffer(length, false); + return memoryAllocator.AllocateManagedByteBuffer(length, false); } - public static IManagedByteBuffer AllocateCleanManagedByteBuffer(this MemoryManager memoryManager, int length) + public static IManagedByteBuffer AllocateCleanManagedByteBuffer(this MemoryAllocator memoryAllocator, int length) { - return memoryManager.AllocateManagedByteBuffer(length, true); + return memoryAllocator.AllocateManagedByteBuffer(length, true); } - public static Buffer2D Allocate2D(this MemoryManager memoryManager, int width, int height, bool clear) + public static Buffer2D Allocate2D(this MemoryAllocator memoryAllocator, int width, int height, bool clear) where T : struct { - IBuffer buffer = memoryManager.Allocate(width * height, clear); + IBuffer buffer = memoryAllocator.Allocate(width * height, clear); return new Buffer2D(buffer, width, height); } - public static Buffer2D Allocate2D(this MemoryManager memoryManager, Size size) + public static Buffer2D Allocate2D(this MemoryAllocator memoryAllocator, Size size) where T : struct => - Allocate2D(memoryManager, size.Width, size.Height, false); + Allocate2D(memoryAllocator, size.Width, size.Height, false); - public static Buffer2D Allocate2D(this MemoryManager memoryManager, int width, int height) + public static Buffer2D Allocate2D(this MemoryAllocator memoryAllocator, int width, int height) where T : struct => - Allocate2D(memoryManager, width, height, false); + Allocate2D(memoryAllocator, width, height, false); - public static Buffer2D AllocateClean2D(this MemoryManager memoryManager, int width, int height) + public static Buffer2D AllocateClean2D(this MemoryAllocator memoryAllocator, int width, int height) where T : struct => - Allocate2D(memoryManager, width, height, true); + Allocate2D(memoryAllocator, width, height, true); /// /// Allocates padded buffers for BMP encoder/decoder. (Replacing old PixelRow/PixelArea) /// - /// The + /// The /// Pixel count in the row /// The pixel size in bytes, eg. 3 for RGB /// The padding /// A public static IManagedByteBuffer AllocatePaddedPixelRowBuffer( - this MemoryManager memoryManager, + this MemoryAllocator memoryAllocator, int width, int pixelSizeInBytes, int paddingInBytes) { int length = (width * pixelSizeInBytes) + paddingInBytes; - return memoryManager.AllocateManagedByteBuffer(length); + return memoryAllocator.AllocateManagedByteBuffer(length); } } } \ No newline at end of file diff --git a/src/ImageSharp/Memory/SimpleGcMemoryManager.cs b/src/ImageSharp/Memory/SimpleGcMemoryAllocator.cs similarity index 72% rename from src/ImageSharp/Memory/SimpleGcMemoryManager.cs rename to src/ImageSharp/Memory/SimpleGcMemoryAllocator.cs index f4518bbb9..9ac82e3b5 100644 --- a/src/ImageSharp/Memory/SimpleGcMemoryManager.cs +++ b/src/ImageSharp/Memory/SimpleGcMemoryAllocator.cs @@ -1,9 +1,9 @@ namespace SixLabors.ImageSharp.Memory { /// - /// Implements by newing up arrays by the GC on every allocation requests. + /// Implements by newing up arrays by the GC on every allocation requests. /// - public class SimpleGcMemoryManager : MemoryManager + public class SimpleGcMemoryAllocator : MemoryAllocator { /// internal override IBuffer Allocate(int length, bool clear) diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs index 6635a5a2a..2dd97991d 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.cs @@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -194,7 +194,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -233,7 +233,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -272,7 +272,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -311,7 +311,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -350,7 +350,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -389,7 +389,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -428,7 +428,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -467,7 +467,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -506,7 +506,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -545,7 +545,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -584,7 +584,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -623,7 +623,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -662,7 +662,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -701,7 +701,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -740,7 +740,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -779,7 +779,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); @@ -818,7 +818,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt index 485bc31ad..07888a756 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultPixelBlenders.Generated.tt @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders } /// - public override void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount) + public override void Blend(MemoryAllocator memoryManager, Span destination, Span background, Span source, Span amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs index 666fb3891..75ec11084 100644 --- a/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs @@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// Blend 2 pixels together. /// - /// The + /// The /// The destination span. /// The background span. /// The source span. @@ -36,6 +36,6 @@ namespace SixLabors.ImageSharp.PixelFormats /// A value between 0 and 1 indicating the weight of the second source vector. /// At amount = 0, "from" is returned, at amount = 1, "to" is returned. /// - public abstract void Blend(MemoryManager memoryManager, Span destination, Span background, Span source, Span amount); + public abstract void Blend(MemoryAllocator memoryAllocator, Span destination, Span background, Span source, Span amount); } } diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs index ebadd2850..badc9d886 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2DProcessor.cs @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors int maxY = endY - 1; int maxX = endX - 1; - using (Buffer2D targetPixels = configuration.MemoryManager.Allocate2D(source.Width, source.Height)) + using (Buffer2D targetPixels = configuration.MemoryAllocator.Allocate2D(source.Width, source.Height)) { source.CopyTo(targetPixels); diff --git a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs index 8f96546ae..957f4c364 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/Convolution2PassProcessor.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors { ParallelOptions parallelOptions = configuration.ParallelOptions; - using (Buffer2D firstPassPixels = configuration.MemoryManager.Allocate2D(source.Size())) + using (Buffer2D firstPassPixels = configuration.MemoryAllocator.Allocate2D(source.Size())) { this.ApplyConvolution(firstPassPixels, source.PixelBuffer, source.Bounds(), this.KernelX, parallelOptions); this.ApplyConvolution(source.PixelBuffer, firstPassPixels, sourceRectangle, this.KernelY, parallelOptions); diff --git a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs index 8f7a1caab..3a4b0cad5 100644 --- a/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Convolution/Processors/ConvolutionProcessor.cs @@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors int maxY = endY - 1; int maxX = endX - 1; - using (Buffer2D targetPixels = configuration.MemoryManager.Allocate2D(source.Size())) + using (Buffer2D targetPixels = configuration.MemoryAllocator.Allocate2D(source.Size())) { source.CopyTo(targetPixels); diff --git a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs index b71430e13..d25d63c19 100644 --- a/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs +++ b/src/ImageSharp/Processing/DefaultInternalImageProcessorContext.cs @@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing } /// - public MemoryManager MemoryManager => this.source.GetConfiguration().MemoryManager; + public MemoryAllocator MemoryAllocator => this.source.GetConfiguration().MemoryAllocator; /// public Image Apply() diff --git a/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs index 9a6d93d1a..a930e9c76 100644 --- a/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Effects/Processors/OilPaintingProcessor.cs @@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Processing.Effects.Processors int radius = this.BrushSize >> 1; int levels = this.Levels; - using (Buffer2D targetPixels = configuration.MemoryManager.Allocate2D(source.Size())) + using (Buffer2D targetPixels = configuration.MemoryAllocator.Allocate2D(source.Size())) { source.CopyTo(targetPixels); diff --git a/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs b/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs index f56777bed..e12668831 100644 --- a/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs +++ b/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs @@ -16,10 +16,10 @@ namespace SixLabors.ImageSharp.Processing where TPixel : struct, IPixel { /// - /// Gets a reference to the used to allocate buffers + /// Gets a reference to the used to allocate buffers /// for this context. /// - MemoryManager MemoryManager { get; } + MemoryAllocator MemoryAllocator { get; } /// /// Gets the image dimensions at the current point in the processing pipeline. diff --git a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs index 5b8772790..93074944a 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs @@ -66,8 +66,8 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors int width = maxX - minX; - using (IBuffer colors = source.MemoryManager.Allocate(width)) - using (IBuffer amount = source.MemoryManager.Allocate(width)) + using (IBuffer colors = source.MemoryAllocator.Allocate(width)) + using (IBuffer amount = source.MemoryAllocator.Allocate(width)) { // Be careful! Do not capture colorSpan & amountSpan in the lambda below! Span colorSpan = colors.GetSpan(); @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors Span destination = source.GetPixelRowSpan(y - startY).Slice(minX - startX, width); // This switched color & destination in the 2nd and 3rd places because we are applying the target color under the current one - blender.Blend(source.MemoryManager, destination, colors.GetSpan(), destination, amount.GetSpan()); + blender.Blend(source.MemoryAllocator, destination, colors.GetSpan(), destination, amount.GetSpan()); }); } } diff --git a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs index b5571ffd0..e2dc43653 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs @@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors } int width = maxX - minX; - using (IBuffer rowColors = source.MemoryManager.Allocate(width)) + using (IBuffer rowColors = source.MemoryAllocator.Allocate(width)) { // Be careful! Do not capture rowColorsSpan in the lambda below! Span rowColorsSpan = rowColors.GetSpan(); @@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors configuration.ParallelOptions, y => { - using (IBuffer amounts = source.MemoryManager.Allocate(width)) + using (IBuffer amounts = source.MemoryAllocator.Allocate(width)) { Span amountsSpan = amounts.GetSpan(); int offsetY = y - startY; @@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors Span destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width); - this.blender.Blend(source.MemoryManager, destination, destination, rowColors.GetSpan(), amountsSpan); + this.blender.Blend(source.MemoryAllocator, destination, destination, rowColors.GetSpan(), amountsSpan); } }); } diff --git a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs index 06bf668d4..613398840 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs @@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors } int width = maxX - minX; - using (IBuffer rowColors = source.MemoryManager.Allocate(width)) + using (IBuffer rowColors = source.MemoryAllocator.Allocate(width)) { // Be careful! Do not capture rowColorsSpan in the lambda below! Span rowColorsSpan = rowColors.GetSpan(); @@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors configuration.ParallelOptions, y => { - using (IBuffer amounts = source.MemoryManager.Allocate(width)) + using (IBuffer amounts = source.MemoryAllocator.Allocate(width)) { Span amountsSpan = amounts.GetSpan(); int offsetY = y - startY; @@ -143,7 +143,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors Span destination = source.GetPixelRowSpan(offsetY).Slice(offsetX, width); - this.blender.Blend(source.MemoryManager, destination, destination, rowColors.GetSpan(), amountsSpan); + this.blender.Blend(source.MemoryAllocator, destination, destination, rowColors.GetSpan(), amountsSpan); } }); } diff --git a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs index 7887b1b2e..a377f922d 100644 --- a/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs @@ -141,17 +141,17 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers public override QuantizedFrame QuantizeFrame(ImageFrame image) { Guard.NotNull(image, nameof(image)); - MemoryManager memoryManager = image.MemoryManager; + MemoryAllocator memoryAllocator = image.MemoryAllocator; try { - this.vwt = memoryManager.AllocateClean(TableLength); - this.vmr = memoryManager.AllocateClean(TableLength); - this.vmg = memoryManager.AllocateClean(TableLength); - this.vmb = memoryManager.AllocateClean(TableLength); - this.vma = memoryManager.AllocateClean(TableLength); - this.m2 = memoryManager.AllocateClean(TableLength); - this.tag = memoryManager.AllocateClean(TableLength); + this.vwt = memoryAllocator.AllocateClean(TableLength); + this.vmr = memoryAllocator.AllocateClean(TableLength); + this.vmg = memoryAllocator.AllocateClean(TableLength); + this.vmb = memoryAllocator.AllocateClean(TableLength); + this.vma = memoryAllocator.AllocateClean(TableLength); + this.m2 = memoryAllocator.AllocateClean(TableLength); + this.tag = memoryAllocator.AllocateClean(TableLength); return base.QuantizeFrame(image); } @@ -246,7 +246,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers } } - this.Get3DMoments(source.MemoryManager); + this.Get3DMoments(source.MemoryAllocator); this.BuildCube(); } @@ -464,7 +464,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers /// /// Converts the histogram into moments so that we can rapidly calculate the sums of the above quantities over any desired box. /// - private void Get3DMoments(MemoryManager memoryManager) + private void Get3DMoments(MemoryAllocator memoryAllocator) { Span vwtSpan = this.vwt.GetSpan(); Span vmrSpan = this.vmr.GetSpan(); @@ -473,19 +473,19 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers Span vmaSpan = this.vma.GetSpan(); Span m2Span = this.m2.GetSpan(); - 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)) + using (IBuffer volume = memoryAllocator.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeR = memoryAllocator.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeG = memoryAllocator.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeB = memoryAllocator.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volumeA = memoryAllocator.Allocate(IndexCount * IndexAlphaCount)) + using (IBuffer volume2 = memoryAllocator.Allocate(IndexCount * IndexAlphaCount)) + + using (IBuffer area = memoryAllocator.Allocate(IndexAlphaCount)) + using (IBuffer areaR = memoryAllocator.Allocate(IndexAlphaCount)) + using (IBuffer areaG = memoryAllocator.Allocate(IndexAlphaCount)) + using (IBuffer areaB = memoryAllocator.Allocate(IndexAlphaCount)) + using (IBuffer areaA = memoryAllocator.Allocate(IndexAlphaCount)) + using (IBuffer area2 = memoryAllocator.Allocate(IndexAlphaCount)) { Span volumeSpan = volume.GetSpan(); Span volumeRSpan = volumeR.GetSpan(); diff --git a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs index 7c1a581b0..fe82417ce 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs @@ -111,10 +111,10 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors int xLength = (int)MathF.Ceiling((radius.X * 2) + 2); int yLength = (int)MathF.Ceiling((radius.Y * 2) + 2); - MemoryManager memoryManager = configuration.MemoryManager; + MemoryAllocator memoryAllocator = configuration.MemoryAllocator; - using (Buffer2D yBuffer = memoryManager.Allocate2D(yLength, height)) - using (Buffer2D xBuffer = memoryManager.Allocate2D(xLength, height)) + using (Buffer2D yBuffer = memoryAllocator.Allocate2D(yLength, height)) + using (Buffer2D xBuffer = memoryAllocator.Allocate2D(xLength, height)) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs index cf5ebf418..54b07cb48 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors int height = source.Height; int halfHeight = (int)Math.Ceiling(source.Height * .5F); - using (Buffer2D targetPixels = configuration.MemoryManager.Allocate2D(source.Size())) + using (Buffer2D targetPixels = configuration.MemoryAllocator.Allocate2D(source.Size())) { Parallel.For( 0, @@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors int height = source.Height; int halfWidth = (int)Math.Ceiling(width * .5F); - using (Buffer2D targetPixels = configuration.MemoryManager.Allocate2D(source.Size())) + using (Buffer2D targetPixels = configuration.MemoryAllocator.Allocate2D(source.Size())) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs index a55613dec..36bc4b1fa 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs @@ -117,10 +117,10 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors int xLength = (int)MathF.Ceiling((radius.X * 2) + 2); int yLength = (int)MathF.Ceiling((radius.Y * 2) + 2); - MemoryManager memoryManager = configuration.MemoryManager; + MemoryAllocator memoryAllocator = configuration.MemoryAllocator; - using (Buffer2D yBuffer = memoryManager.Allocate2D(yLength, height)) - using (Buffer2D xBuffer = memoryManager.Allocate2D(xLength, height)) + using (Buffer2D yBuffer = memoryAllocator.Allocate2D(yLength, height)) + using (Buffer2D xBuffer = memoryAllocator.Allocate2D(xLength, height)) { Parallel.For( 0, diff --git a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs index fc8d94362..3f11127ca 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs @@ -143,12 +143,12 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// /// Computes the weights to apply at each pixel when resizing. /// - /// The to use for buffer allocations + /// The to use for buffer allocations /// The destination size /// The source size /// The // TODO: Made internal to simplify experimenting with weights data. Make it private when finished figuring out how to optimize all the stuff! - internal WeightsBuffer PrecomputeWeights(MemoryManager memoryManager, int destinationSize, int sourceSize) + internal WeightsBuffer PrecomputeWeights(MemoryAllocator memoryAllocator, int destinationSize, int sourceSize) { float ratio = (float)sourceSize / destinationSize; float scale = ratio; @@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors IResampler sampler = this.Sampler; float radius = MathF.Ceiling(scale * sampler.Radius); - var result = new WeightsBuffer(memoryManager, sourceSize, destinationSize); + var result = new WeightsBuffer(memoryAllocator, sourceSize, destinationSize); for (int i = 0; i < destinationSize; i++) { @@ -226,14 +226,14 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors if (!(this.Sampler is NearestNeighborResampler)) { // Since all image frame dimensions have to be the same we can calculate this for all frames. - MemoryManager memoryManager = source.GetMemoryManager(); + MemoryAllocator memoryAllocator = source.GetMemoryAllocator(); this.horizontalWeights = this.PrecomputeWeights( - memoryManager, + memoryAllocator, this.ResizeRectangle.Width, sourceRectangle.Width); this.verticalWeights = this.PrecomputeWeights( - memoryManager, + memoryAllocator, this.ResizeRectangle.Height, sourceRectangle.Height); } @@ -295,7 +295,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors // First process the columns. Since we are not using multiple threads startY and endY // are the upper and lower bounds of the source rectangle. // TODO: Using a transposed variant of 'firstPassPixels' could eliminate the need for the WeightsWindow.ComputeWeightedColumnSum() method, and improve speed! - using (Buffer2D firstPassPixels = source.MemoryManager.Allocate2D(width, source.Height)) + using (Buffer2D firstPassPixels = source.MemoryAllocator.Allocate2D(width, source.Height)) { firstPassPixels.Buffer.Clear(); diff --git a/src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs b/src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs index 42c95cd33..d025644f5 100644 --- a/src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs +++ b/src/ImageSharp/Processing/Transforms/Processors/WeightsBuffer.cs @@ -16,12 +16,12 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors /// /// Initializes a new instance of the class. /// - /// The MemoryManager to use for allocations. + /// The to use for allocations. /// The size of the source window /// The size of the destination window - public WeightsBuffer(MemoryManager memoryManager, int sourceSize, int destinationSize) + public WeightsBuffer(MemoryAllocator memoryAllocator, int sourceSize, int destinationSize) { - this.dataBuffer = memoryManager.Allocate2D(sourceSize, destinationSize, true); + this.dataBuffer = memoryAllocator.Allocate2D(sourceSize, destinationSize, true); this.Weights = new WeightsWindow[destinationSize]; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs index 1d76d58a5..f91595df8 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DoubleBufferedStreams.cs @@ -29,8 +29,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg this.stream2 = new MemoryStream(this.buffer); this.stream3 = new MemoryStream(this.buffer); this.stream4 = new MemoryStream(this.buffer); - this.reader1 = new DoubleBufferedStreamReader(Configuration.Default.MemoryManager, this.stream2); - this.reader2 = new DoubleBufferedStreamReader(Configuration.Default.MemoryManager, this.stream2); + this.reader1 = new DoubleBufferedStreamReader(Configuration.Default.MemoryAllocator, this.stream2); + this.reader2 = new DoubleBufferedStreamReader(Configuration.Default.MemoryAllocator, this.stream2); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs index ef0d55765..087c033dd 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/YCbCrColorConversion.cs @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg } // no need to dispose when buffer is not array owner - buffers[i] = Configuration.Default.MemoryManager.Allocate2D(values.Length, 1); + buffers[i] = Configuration.Default.MemoryAllocator.Allocate2D(values.Length, 1); } return buffers; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs index 329fcbe67..6874ff54a 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromVector4.cs @@ -23,8 +23,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk [GlobalSetup] public void Setup() { - this.destination = Configuration.Default.MemoryManager.Allocate(this.Count); - this.source = Configuration.Default.MemoryManager.Allocate(this.Count); + this.destination = Configuration.Default.MemoryAllocator.Allocate(this.Count); + this.source = Configuration.Default.MemoryAllocator.Allocate(this.Count); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs index 31583bfe2..ca61983ce 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs @@ -21,8 +21,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk [GlobalSetup] public void Setup() { - this.destination = Configuration.Default.MemoryManager.Allocate(this.Count); - this.source = Configuration.Default.MemoryManager.Allocate(this.Count * 4); + this.destination = Configuration.Default.MemoryAllocator.Allocate(this.Count); + this.source = Configuration.Default.MemoryAllocator.Allocate(this.Count * 4); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs index e44847274..007306c6e 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs @@ -22,8 +22,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk [GlobalSetup] public void Setup() { - this.source = Configuration.Default.MemoryManager.Allocate(this.Count); - this.destination = Configuration.Default.MemoryManager.Allocate(this.Count); + this.source = Configuration.Default.MemoryAllocator.Allocate(this.Count); + this.destination = Configuration.Default.MemoryAllocator.Allocate(this.Count); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs index 030d7ad76..6e17d0276 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs @@ -22,8 +22,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk [GlobalSetup] public void Setup() { - this.source = Configuration.Default.MemoryManager.Allocate(this.Count); - this.destination = Configuration.Default.MemoryManager.Allocate(this.Count * 3); + this.source = Configuration.Default.MemoryAllocator.Allocate(this.Count); + this.destination = Configuration.Default.MemoryAllocator.Allocate(this.Count * 3); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs index 4f58d1503..a0d7df72f 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs @@ -24,8 +24,8 @@ namespace SixLabors.ImageSharp.Benchmarks.ColorSpaces.Bulk [GlobalSetup] public void Setup() { - this.source = Configuration.Default.MemoryManager.Allocate(this.Count); - this.destination = Configuration.Default.MemoryManager.Allocate(this.Count * 4); + this.source = Configuration.Default.MemoryAllocator.Allocate(this.Count); + this.destination = Configuration.Default.MemoryAllocator.Allocate(this.Count * 4); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index c088e8eed..b194e9a6a 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 (IBuffer buffer = Configuration.Default.MemoryManager.Allocate(destination.Length * 3)) + using (IBuffer buffer = Configuration.Default.MemoryAllocator.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 (IBuffer amounts = Configuration.Default.MemoryManager.Allocate(image.Width)) + using (IBuffer amounts = Configuration.Default.MemoryAllocator.Allocate(image.Width)) { amounts.Span.Fill(1); @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Benchmarks { using (Image image = new Image(800, 800)) { - using (IBuffer amounts = Configuration.Default.MemoryManager.Allocate(image.Width)) + using (IBuffer amounts = Configuration.Default.MemoryAllocator.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 51b136649..5069336c4 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Benchmarks } int width = maxX - minX; - using (IBuffer rowColors = Configuration.Default.MemoryManager.Allocate(width)) + using (IBuffer rowColors = Configuration.Default.MemoryAllocator.Allocate(width)) using (PixelAccessor sourcePixels = source.Lock()) { rowColors.Span.Fill(glowColor); diff --git a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs index 3fe1380e4..6de84641c 100644 --- a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs @@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced } } - class TestMemoryManager : System.Buffers.MemoryManager + class TestMemoryManager : MemoryManager { public TestMemoryManager(TPixel[] pixelArray) { diff --git a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs index cc2143afe..a553d4fc2 100644 --- a/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/FakeImageOperationsProvider.cs @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests public List Applied { get; } = new List(); - public MemoryManager MemoryManager => this.Source.GetConfiguration().MemoryManager; + public MemoryAllocator MemoryAllocator => this.Source.GetConfiguration().MemoryAllocator; public Image Apply() { diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 0187b7e29..77807b66f 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests public void QuantizeImageShouldPreserveMaximumColorPrecision(TestImageProvider provider, string quantizerName) where TPixel : struct, IPixel { - provider.Configuration.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); + provider.Configuration.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling(); IQuantizer quantizer = GetQuantizer(quantizerName); @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests image.DebugSave(provider, new PngEncoder() { PngColorType = PngColorType.Palette }, testOutputDetails: quantizerName); } - provider.Configuration.MemoryManager.ReleaseRetainedResources(); + provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); //string path = TestEnvironment.CreateOutputDirectory("Quantize"); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs index aa7d101c0..c720fdd4a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { Block8x8F block = CreateRandomFloatBlock(0, 100); - using (var buffer = Configuration.Default.MemoryManager.Allocate2D(20, 20)) + using (var buffer = Configuration.Default.MemoryAllocator.Allocate2D(20, 20)) { BufferArea area = buffer.GetArea(5, 10, 8, 8); block.CopyTo(area); @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg var start = new Point(50, 50); - using (var buffer = Configuration.Default.MemoryManager.Allocate2D(100, 100)) + using (var buffer = Configuration.Default.MemoryAllocator.Allocate2D(100, 100)) { BufferArea area = buffer.GetArea(start.X, start.Y, 8 * horizontalFactor, 8 * verticalFactor); block.CopyTo(area, horizontalFactor, verticalFactor); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DoubleBufferedStreamReaderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DoubleBufferedStreamReaderTests.cs index be71e554f..7fe1dd577 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DoubleBufferedStreamReaderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DoubleBufferedStreamReaderTests.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { public class DoubleBufferedStreamReaderTests { - private readonly MemoryManager manager = Configuration.Default.MemoryManager; + private readonly MemoryAllocator allocator = Configuration.Default.MemoryAllocator; [Fact] public void DoubleBufferedStreamReaderCanReadSingleByteFromOrigin() @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg using (MemoryStream stream = this.CreateTestStream()) { byte[] expected = stream.ToArray(); - var reader = new DoubleBufferedStreamReader(this.manager, stream); + var reader = new DoubleBufferedStreamReader(this.allocator, stream); Assert.Equal(expected[0], reader.ReadByte()); @@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg using (MemoryStream stream = this.CreateTestStream()) { byte[] expected = stream.ToArray(); - var reader = new DoubleBufferedStreamReader(this.manager, stream); + var reader = new DoubleBufferedStreamReader(this.allocator, stream); for (int i = 0; i < expected.Length; i++) { @@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { byte[] buffer = new byte[2]; byte[] expected = stream.ToArray(); - var reader = new DoubleBufferedStreamReader(this.manager, stream); + var reader = new DoubleBufferedStreamReader(this.allocator, stream); Assert.Equal(2, reader.Read(buffer, 0, 2)); Assert.Equal(expected[0], buffer[0]); @@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { byte[] buffer = new byte[2]; byte[] expected = stream.ToArray(); - var reader = new DoubleBufferedStreamReader(this.manager, stream); + var reader = new DoubleBufferedStreamReader(this.allocator, stream); for (int i = 0, o = 0; i < expected.Length / 2; i++, o += 2) { @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg using (MemoryStream stream = this.CreateTestStream()) { byte[] expected = stream.ToArray(); - var reader = new DoubleBufferedStreamReader(this.manager, stream); + var reader = new DoubleBufferedStreamReader(this.allocator, stream); int skip = 50; int plusOne = 1; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs index f178c29c0..374b53ab2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } // For 32 bit test enviroments: - provider.Configuration.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); + provider.Configuration.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling(); using (Image image = provider.GetImage(GolangJpegDecoder)) { @@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg appendPixelTypeToFileName: false); } - provider.Configuration.MemoryManager.ReleaseRetainedResources(); + provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs index c988f8f05..0ffe577fa 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } // For 32 bit test enviroments: - provider.Configuration.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); + provider.Configuration.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling(); using (Image image = provider.GetImage(GolangJpegDecoder)) { @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg appendPixelTypeToFileName: false); } - provider.Configuration.MemoryManager.ReleaseRetainedResources(); + provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 3667790a2..3421a06c7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg } // For 32 bit test enviroments: - provider.Configuration.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); + provider.Configuration.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling(); IImageDecoder decoder = useOldDecoder ? (IImageDecoder)GolangJpegDecoder : PdfJsJpegDecoder; using (Image image = provider.GetImage(decoder)) @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg image.CompareToReferenceOutput(ImageComparer.Tolerant(BaselineTolerance), provider, appendPixelTypeToFileName: false); } - provider.Configuration.MemoryManager.ReleaseRetainedResources(); + provider.Configuration.MemoryAllocator.ReleaseRetainedResources(); } private string GetDifferenceInPercentageString(Image image, TestImageProvider provider) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs index 45ee64cb4..843843f79 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { string imageFile = provider.SourceFileOrDescription; using (PdfJsJpegDecoderCore decoder = JpegFixture.ParsePdfJsStream(imageFile)) - using (var pp = new JpegImagePostProcessor(Configuration.Default.MemoryManager, decoder)) + using (var pp = new JpegImagePostProcessor(Configuration.Default.MemoryAllocator, decoder)) using (var imageFrame = new ImageFrame(Configuration.Default, decoder.ImageWidth, decoder.ImageHeight)) { pp.DoPostProcessorStep(imageFrame); @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { string imageFile = provider.SourceFileOrDescription; using (PdfJsJpegDecoderCore decoder = JpegFixture.ParsePdfJsStream(imageFile)) - using (var pp = new JpegImagePostProcessor(Configuration.Default.MemoryManager, decoder)) + using (var pp = new JpegImagePostProcessor(Configuration.Default.MemoryAllocator, decoder)) using (var image = new Image(decoder.ImageWidth, decoder.ImageHeight)) { pp.PostProcess(image.Frames.RootFrame); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs index 90cc45e4a..2d56a89c6 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils this.HeightInBlocks = heightInBlocks; this.WidthInBlocks = widthInBlocks; this.Index = index; - this.SpectralBlocks = Configuration.Default.MemoryManager.Allocate2D(this.WidthInBlocks, this.HeightInBlocks); + this.SpectralBlocks = Configuration.Default.MemoryAllocator.Allocate2D(this.WidthInBlocks, this.HeightInBlocks); } public Size Size => new Size(this.WidthInBlocks, this.HeightInBlocks); diff --git a/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs b/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs index b84a78a55..e13101be4 100644 --- a/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs +++ b/tests/ImageSharp.Tests/Memory/ArrayPoolMemoryManagerTests.cs @@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Memory private const int PoolSelectorThresholdInBytes = MaxPooledBufferSizeInBytes / 2; - private MemoryManager MemoryManager { get; set; } = new ArrayPoolMemoryManager(MaxPooledBufferSizeInBytes, PoolSelectorThresholdInBytes); + private MemoryAllocator MemoryAllocator { get; set; } = new ArrayPoolMemoryAllocator(MaxPooledBufferSizeInBytes, PoolSelectorThresholdInBytes); /// /// Rent a buffer -> return it -> re-rent -> verify if it's span points to the previous location @@ -30,11 +30,11 @@ namespace SixLabors.ImageSharp.Tests.Memory private bool CheckIsRentingPooledBuffer(int length) where T : struct { - IBuffer buffer = this.MemoryManager.Allocate(length); + IBuffer buffer = this.MemoryAllocator.Allocate(length); ref T ptrToPrevPosition0 = ref buffer.GetReference(); buffer.Dispose(); - buffer = this.MemoryManager.Allocate(length); + buffer = this.MemoryAllocator.Allocate(length); bool sameBuffers = Unsafe.AreSame(ref ptrToPrevPosition0, ref buffer.GetReference()); buffer.Dispose(); @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Memory public class BufferTests : BufferTestSuite { public BufferTests() - : base(new ArrayPoolMemoryManager(MaxPooledBufferSizeInBytes, PoolSelectorThresholdInBytes)) + : base(new ArrayPoolMemoryAllocator(MaxPooledBufferSizeInBytes, PoolSelectorThresholdInBytes)) { } } @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void WhenBothParametersPassedByUser() { - var mgr = new ArrayPoolMemoryManager(1111, 666); + var mgr = new ArrayPoolMemoryAllocator(1111, 666); Assert.Equal(1111, mgr.MaxPoolSizeInBytes); Assert.Equal(666, mgr.PoolSelectorThresholdInBytes); } @@ -62,7 +62,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void WhenPassedOnly_MaxPooledBufferSizeInBytes_SmallerThresholdValueIsAutoCalculated() { - var mgr = new ArrayPoolMemoryManager(5000); + var mgr = new ArrayPoolMemoryAllocator(5000); Assert.Equal(5000, mgr.MaxPoolSizeInBytes); Assert.True(mgr.PoolSelectorThresholdInBytes < mgr.MaxPoolSizeInBytes); } @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void When_PoolSelectorThresholdInBytes_IsGreaterThan_MaxPooledBufferSizeInBytes_ExceptionIsThrown() { - Assert.ThrowsAny(() => { new ArrayPoolMemoryManager(100, 200); }); + Assert.ThrowsAny(() => { new ArrayPoolMemoryAllocator(100, 200); }); } } @@ -130,12 +130,12 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(true)] public void CleaningRequests_AreControlledByAllocationParameter_Clean(bool clean) { - using (IBuffer firstAlloc = this.MemoryManager.Allocate(42)) + using (IBuffer firstAlloc = this.MemoryAllocator.Allocate(42)) { firstAlloc.GetSpan().Fill(666); } - using (IBuffer secondAlloc = this.MemoryManager.Allocate(42, clean)) + using (IBuffer secondAlloc = this.MemoryAllocator.Allocate(42, clean)) { int expected = clean ? 0 : 666; Assert.Equal(expected, secondAlloc.GetSpan()[0]); @@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(true)] public void ReleaseRetainedResources_ReplacesInnerArrayPool(bool keepBufferAlive) { - IBuffer buffer = this.MemoryManager.Allocate(32); + IBuffer buffer = this.MemoryAllocator.Allocate(32); ref int ptrToPrev0 = ref MemoryMarshal.GetReference(buffer.GetSpan()); if (!keepBufferAlive) @@ -155,9 +155,9 @@ namespace SixLabors.ImageSharp.Tests.Memory buffer.Dispose(); } - this.MemoryManager.ReleaseRetainedResources(); + this.MemoryAllocator.ReleaseRetainedResources(); - buffer = this.MemoryManager.Allocate(32); + buffer = this.MemoryAllocator.Allocate(32); Assert.False(Unsafe.AreSame(ref ptrToPrev0, ref buffer.GetReference())); } @@ -165,8 +165,8 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void ReleaseRetainedResources_DisposingPreviouslyAllocatedBuffer_IsAllowed() { - IBuffer buffer = this.MemoryManager.Allocate(32); - this.MemoryManager.ReleaseRetainedResources(); + IBuffer buffer = this.MemoryAllocator.Allocate(32); + this.MemoryAllocator.ReleaseRetainedResources(); buffer.Dispose(); } @@ -181,11 +181,11 @@ namespace SixLabors.ImageSharp.Tests.Memory int arrayLengthThreshold = PoolSelectorThresholdInBytes / sizeof(int); - IBuffer small = this.MemoryManager.Allocate(arrayLengthThreshold - 1); + IBuffer small = this.MemoryAllocator.Allocate(arrayLengthThreshold - 1); ref int ptr2Small = ref small.GetReference(); small.Dispose(); - IBuffer large = this.MemoryManager.Allocate(arrayLengthThreshold + 1); + IBuffer large = this.MemoryAllocator.Allocate(arrayLengthThreshold + 1); Assert.False(Unsafe.AreSame(ref ptr2Small, ref large.GetReference())); } @@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp.Tests.Memory return; } - this.MemoryManager = ArrayPoolMemoryManager.CreateWithAggressivePooling(); + this.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithAggressivePooling(); Assert.True(this.CheckIsRentingPooledBuffer(4096 * 4096)); } @@ -213,7 +213,7 @@ namespace SixLabors.ImageSharp.Tests.Memory return; } - this.MemoryManager = ArrayPoolMemoryManager.CreateDefault(); + this.MemoryAllocator = ArrayPoolMemoryAllocator.CreateDefault(); Assert.False(this.CheckIsRentingPooledBuffer(2 * 4096 * 4096)); Assert.True(this.CheckIsRentingPooledBuffer(2048 * 2048)); @@ -228,7 +228,7 @@ namespace SixLabors.ImageSharp.Tests.Memory return; } - this.MemoryManager = ArrayPoolMemoryManager.CreateWithModeratePooling(); + this.MemoryAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling(); Assert.False(this.CheckIsRentingPooledBuffer(2048 * 2048)); Assert.True(this.CheckIsRentingPooledBuffer(1024 * 16)); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index ca3837ad2..1495bbe44 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -27,9 +27,9 @@ namespace SixLabors.ImageSharp.Tests.Memory } } - private MemoryManager MemoryManager { get; } = new MockMemoryManager(); + private MemoryAllocator MemoryAllocator { get; } = new MockMemoryAllocator(); - private class MockMemoryManager : MemoryManager + private class MockMemoryAllocator : MemoryAllocator { internal override IBuffer Allocate(int length, bool clear) { @@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(1025, 17)] public void Construct(int width, int height) { - using (Buffer2D buffer = this.MemoryManager.Allocate2D(width, height)) + using (Buffer2D buffer = this.MemoryAllocator.Allocate2D(width, height)) { Assert.Equal(width, buffer.Width); Assert.Equal(height, buffer.Height); @@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void CreateClean() { - using (Buffer2D buffer = this.MemoryManager.Allocate2D(42, 42, true)) + using (Buffer2D buffer = this.MemoryAllocator.Allocate2D(42, 42, true)) { Span span = buffer.GetSpan(); for (int j = 0; j < span.Length; j++) @@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(17, 42, 41)] public void GetRowSpanY(int width, int height, int y) { - using (Buffer2D buffer = this.MemoryManager.Allocate2D(width, height)) + using (Buffer2D buffer = this.MemoryAllocator.Allocate2D(width, height)) { Span span = buffer.GetRowSpan(y); @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(17, 42, 0, 41)] public void GetRowSpanXY(int width, int height, int x, int y) { - using (Buffer2D buffer = this.MemoryManager.Allocate2D(width, height)) + using (Buffer2D buffer = this.MemoryAllocator.Allocate2D(width, height)) { Span span = buffer.GetRowSpan(x, y); @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(99, 88, 98, 87)] public void Indexer(int width, int height, int x, int y) { - using (Buffer2D buffer = this.MemoryManager.Allocate2D(width, height)) + using (Buffer2D buffer = this.MemoryAllocator.Allocate2D(width, height)) { Span span = buffer.Buffer.GetSpan(); @@ -132,8 +132,8 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void SwapContents() { - using (Buffer2D a = this.MemoryManager.Allocate2D(10, 5)) - using (Buffer2D b = this.MemoryManager.Allocate2D(3, 7)) + using (Buffer2D a = this.MemoryAllocator.Allocate2D(10, 5)) + using (Buffer2D b = this.MemoryAllocator.Allocate2D(3, 7)) { IBuffer aa = a.Buffer; IBuffer bb = b.Buffer; diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index bae3b4b61..2a87ed83b 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void Construct() { - using (var buffer = Configuration.Default.MemoryManager.Allocate2D(10, 20)) + using (var buffer = Configuration.Default.MemoryAllocator.Allocate2D(10, 20)) { var rectangle = new Rectangle(3,2, 5, 6); var area = new BufferArea(buffer, rectangle); @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Tests.Memory private static Buffer2D CreateTestBuffer(int w, int h) { - var buffer = Configuration.Default.MemoryManager.Allocate2D(w, h); + var buffer = Configuration.Default.MemoryAllocator.Allocate2D(w, h); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) diff --git a/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs index b19b1b03b..040e69c52 100644 --- a/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs +++ b/tests/ImageSharp.Tests/Memory/BufferTestSuite.cs @@ -13,16 +13,16 @@ namespace SixLabors.ImageSharp.Tests.Memory using System.Buffers; /// - /// Inherit this class to test an implementation (provided by ). + /// Inherit this class to test an implementation (provided by ). /// public abstract class BufferTestSuite { - protected BufferTestSuite(MemoryManager memoryManager) + protected BufferTestSuite(MemoryAllocator memoryAllocator) { - this.MemoryManager = memoryManager; + this.MemoryAllocator = memoryAllocator; } - protected MemoryManager MemoryManager { get; } + protected MemoryAllocator MemoryAllocator { get; } public struct CustomStruct : IEquatable { @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests.Memory private void TestHasCorrectLength(int desiredLength) where T : struct { - using (IBuffer buffer = this.MemoryManager.Allocate(desiredLength)) + using (IBuffer buffer = this.MemoryAllocator.Allocate(desiredLength)) { Assert.Equal(desiredLength, buffer.GetSpan().Length); } @@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.Tests.Memory { if (managedByteBuffer) { - if (!(this.MemoryManager.AllocateManagedByteBuffer(desiredLength, clean) is IBuffer buffer)) + if (!(this.MemoryAllocator.AllocateManagedByteBuffer(desiredLength, clean) is IBuffer buffer)) { throw new InvalidOperationException("typeof(T) != typeof(byte)"); } @@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Tests.Memory return buffer; } - return this.MemoryManager.Allocate(desiredLength, clean); + return this.MemoryAllocator.Allocate(desiredLength, clean); } private void TestCanAllocateCleanBuffer(int desiredLength, bool testManagedByteBuffer = false) @@ -273,7 +273,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [InlineData(6666)] public void ManagedByteBuffer_ArrayIsCorrect(int desiredLength) { - using (IManagedByteBuffer buffer = this.MemoryManager.AllocateManagedByteBuffer(desiredLength)) + using (IManagedByteBuffer buffer = this.MemoryAllocator.AllocateManagedByteBuffer(desiredLength)) { ref byte array0 = ref buffer.Array[0]; ref byte span0 = ref buffer.GetReference(); @@ -286,7 +286,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public void GetMemory_ReturnsValidMemory() { - using (IBuffer buffer = this.MemoryManager.Allocate(42)) + using (IBuffer buffer = this.MemoryAllocator.Allocate(42)) { Span span0 = buffer.GetSpan(); span0[10].A = 30; @@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.Tests.Memory [Fact] public unsafe void GetMemory_ResultIsPinnable() { - using (IBuffer buffer = this.MemoryManager.Allocate(42)) + using (IBuffer buffer = this.MemoryAllocator.Allocate(42)) { Span span0 = buffer.GetSpan(); span0[10] = 30; diff --git a/tests/ImageSharp.Tests/Memory/SimpleGcMemoryManagerTests.cs b/tests/ImageSharp.Tests/Memory/SimpleGcMemoryManagerTests.cs index 0d1c2beb8..aedc53f66 100644 --- a/tests/ImageSharp.Tests/Memory/SimpleGcMemoryManagerTests.cs +++ b/tests/ImageSharp.Tests/Memory/SimpleGcMemoryManagerTests.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Memory public class BufferTests : BufferTestSuite { public BufferTests() - : base(new SimpleGcMemoryManager()) + : base(new SimpleGcMemoryAllocator()) { } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs index 10a34ec31..5b7deac01 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders { new TestPixel(1,1,1,1), new TestPixel(0,0,0,.8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) }, }; - private MemoryManager MemoryManager { get; } = Configuration.Default.MemoryManager; + private MemoryAllocator MemoryAllocator { get; } = Configuration.Default.MemoryAllocator; [Theory] [MemberData(nameof(NormalBlendFunctionData))] @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Normal().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Normal().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Multiply().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Multiply().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Add().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Add().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Subtract().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Subtract().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Screen().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Screen().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -248,7 +248,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Darken().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Darken().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -287,7 +287,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Lighten().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Lighten().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -326,7 +326,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.Overlay().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.Overlay().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -365,7 +365,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { Span dest = new Span(new TPixel[1]); - new DefaultPixelBlenders.HardLight().Blend(this.MemoryManager, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultPixelBlenders.HardLight().Blend(this.MemoryAllocator, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs index 97e4615c0..8eeddd406 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs @@ -56,8 +56,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats int times = 200000; int count = 1024; - using (IBuffer source = Configuration.Default.MemoryManager.Allocate(count)) - using (IBuffer dest = Configuration.Default.MemoryManager.Allocate(count)) + using (IBuffer source = Configuration.Default.MemoryAllocator.Allocate(count)) + using (IBuffer dest = Configuration.Default.MemoryAllocator.Allocate(count)) { this.Measure( times, @@ -441,7 +441,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { this.SourceBuffer = source; this.ExpectedDestBuffer = expectedDest; - this.ActualDestBuffer = Configuration.Default.MemoryManager.Allocate(expectedDest.Length); + this.ActualDestBuffer = Configuration.Default.MemoryAllocator.Allocate(expectedDest.Length); } public void Dispose() diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs index 1160e496c..ab19c21eb 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms var size = new Size(500, 500); var proc = new ResizeProcessor(KnownResamplers.Bicubic, 200, 200, size); - WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryManager, proc.Width, size.Width); + WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryAllocator, proc.Width, size.Width); var bld = new StringBuilder(); diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index ad0d43dcc..73ea6785f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs var image = new Image(w, h); - using (IBuffer workBuffer = Configuration.Default.MemoryManager.Allocate(w)) + using (IBuffer workBuffer = Configuration.Default.MemoryAllocator.Allocate(w)) { fixed (Bgra32* destPtr = &workBuffer.GetReference()) { @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs var image = new Image(w, h); - using (IBuffer workBuffer = Configuration.Default.MemoryManager.Allocate(w)) + using (IBuffer workBuffer = Configuration.Default.MemoryAllocator.Allocate(w)) { fixed (Bgr24* destPtr = &workBuffer.GetReference()) { @@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs long destRowByteCount = data.Stride; long sourceRowByteCount = w * sizeof(Bgra32); - using (IBuffer workBuffer = image.GetConfiguration().MemoryManager.Allocate(w)) + using (IBuffer workBuffer = image.GetConfiguration().MemoryAllocator.Allocate(w)) { fixed (Bgra32* sourcePtr = &workBuffer.GetReference()) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 3c5d5a7ba..fcf931935 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -27,11 +27,11 @@ namespace SixLabors.ImageSharp.Tests public static void MakeOpaque(this IImageProcessingContext ctx) where TPixel : struct, IPixel { - MemoryManager memoryManager = ctx.MemoryManager; + MemoryAllocator memoryAllocator = ctx.MemoryAllocator; ctx.Apply(img => { - using (Buffer2D temp = memoryManager.Allocate2D(img.Width, img.Height)) + using (Buffer2D temp = memoryAllocator.Allocate2D(img.Width, img.Height)) { Span tempSpan = temp.GetSpan(); foreach (ImageFrame frame in img.Frames)