diff --git a/src/ImageSharp.Drawing/Paths/DrawPath.cs b/src/ImageSharp.Drawing/Paths/DrawPath.cs index a46d5751f..b6c821a60 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPath.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPath.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path, GraphicsOptions options) where TPixel : struct, IPixel { - return source.Fill(pen.StrokeFill, new ShapePath(source.GetMemoryManager(), path, pen), options); + return source.Fill(pen.StrokeFill, new ShapePath(path, pen), options); } /// diff --git a/src/ImageSharp.Drawing/Paths/FillPaths.cs b/src/ImageSharp.Drawing/Paths/FillPaths.cs index 5972c52a0..f554ed758 100644 --- a/src/ImageSharp.Drawing/Paths/FillPaths.cs +++ b/src/ImageSharp.Drawing/Paths/FillPaths.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path, GraphicsOptions options) where TPixel : struct, IPixel { - return source.Fill(brush, new ShapeRegion(source.GetMemoryManager(), path), options); + return source.Fill(brush, new ShapeRegion(path), options); } /// @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path) where TPixel : struct, IPixel { - return source.Fill(brush, new ShapeRegion(source.GetMemoryManager(), path), GraphicsOptions.Default); + return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); } /// diff --git a/src/ImageSharp.Drawing/Paths/ShapePath.cs b/src/ImageSharp.Drawing/Paths/ShapePath.cs index 9e2b22a75..4c2278719 100644 --- a/src/ImageSharp.Drawing/Paths/ShapePath.cs +++ b/src/ImageSharp.Drawing/Paths/ShapePath.cs @@ -18,12 +18,11 @@ namespace SixLabors.ImageSharp.Drawing /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The shape. /// The pen to apply to the shape. // SixLabors.shape willbe moving to a Span/ReadOnlySpan based API shortly use ToArray for now. - public ShapePath(MemoryManager memoryManager, IPath shape, Pens.IPen pen) - : base(memoryManager, shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern.ToArray())) + public ShapePath(IPath shape, Pens.IPen pen) + : base(shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern.ToArray())) { } } diff --git a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs index 77a3b0115..072a38cf8 100644 --- a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs @@ -15,16 +15,12 @@ namespace SixLabors.ImageSharp.Drawing /// internal class ShapeRegion : Region { - private readonly MemoryManager memoryManager; - /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// The shape. - public ShapeRegion(MemoryManager memoryManager, IPath shape) + public ShapeRegion(IPath shape) { - this.memoryManager = memoryManager; this.Shape = shape.AsClosedPath(); int left = (int)MathF.Floor(shape.Bounds.Left); int top = (int)MathF.Floor(shape.Bounds.Top); @@ -50,18 +46,17 @@ namespace SixLabors.ImageSharp.Drawing { var start = new PointF(this.Bounds.Left - 1, y); var end = new PointF(this.Bounds.Right + 1, y); - using (var innerBuffer = this.memoryManager.Allocate(buffer.Length)) - { - PointF[] array = innerBuffer.Array; - int count = this.Shape.FindIntersections(start, end, array, 0); - for (int i = 0; i < count; i++) - { - buffer[i + offset] = array[i].X; - } + // TODO: This is a temporal workaround because of the lack of Span API-s on IPath. We should use MemoryManager.Allocate() here! + PointF[] innerBuffer = new PointF[buffer.Length]; + int count = this.Shape.FindIntersections(start, end, innerBuffer, 0); - return count; + for (int i = 0; i < count; i++) + { + buffer[i + offset] = innerBuffer[i].X; } + + return count; } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Png/PngConfigurationModule.cs b/src/ImageSharp/Formats/Png/PngConfigurationModule.cs index abf5bc6bb..ab6f31d49 100644 --- a/src/ImageSharp/Formats/Png/PngConfigurationModule.cs +++ b/src/ImageSharp/Formats/Png/PngConfigurationModule.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// public void Configure(Configuration config) { - config.SetEncoder(ImageFormats.Png, new PngEncoder(config.MemoryManager)); + config.SetEncoder(ImageFormats.Png, new PngEncoder()); config.SetDecoder(ImageFormats.Png, new PngDecoder()); config.AddImageFormatDetector(new PngImageFormatDetector()); } diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 0546c5ee3..45d6fa3a2 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Formats.Png this.textEncoding = options.TextEncoding ?? PngConstants.DefaultEncoding; this.ignoreMetadata = options.IgnoreMetadata; } - + private MemoryManager MemoryManager => this.configuration.MemoryManager; /// @@ -441,7 +441,6 @@ namespace SixLabors.ImageSharp.Formats.Png this.scanline = this.configuration.MemoryManager.Allocate(this.bytesPerScanline, true); } - /// /// Calculates the correct number of bits per pixel for the given color type. /// diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index ee5651f2d..0c40ccf2a 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -2,7 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System.IO; - +using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Quantizers; @@ -14,17 +14,6 @@ namespace SixLabors.ImageSharp.Formats.Png /// public sealed class PngEncoder : IImageEncoder, IPngEncoderOptions { - private readonly MemoryManager memoryManager; - - /// - /// Initializes a new instance of the class. - /// - /// The to use for buffer allocations. - public PngEncoder(MemoryManager memoryManager) - { - this.memoryManager = memoryManager; - } - /// /// Gets or sets a value indicating whether the metadata should be ignored when the image is being encoded. /// @@ -79,7 +68,7 @@ namespace SixLabors.ImageSharp.Formats.Png public void Encode(Image image, Stream stream) where TPixel : struct, IPixel { - using (var encoder = new PngEncoderCore(this.memoryManager, this)) + using (var encoder = new PngEncoderCore(image.GetMemoryManager(), this)) { encoder.Encode(image, stream); } diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index e8e1726e9..d53125089 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -508,7 +508,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (this.quantizer == null) { - this.quantizer = new WuQuantizer(this.memoryManager); + this.quantizer = new WuQuantizer(); } // Quantize the image returning a palette. This boxing is icky. diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs index f5b4b7192..152d586af 100644 --- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. - using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/src/ImageSharp/Quantizers/Quantize.cs b/src/ImageSharp/Quantizers/Quantize.cs index 11494a867..0e3d806da 100644 --- a/src/ImageSharp/Quantizers/Quantize.cs +++ b/src/ImageSharp/Quantizers/Quantize.cs @@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp switch (mode) { case Quantization.Wu: - quantizer = new WuQuantizer(source.GetMemoryManager()); + quantizer = new WuQuantizer(); break; case Quantization.Palette: diff --git a/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs b/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs index 966ec6034..8f89c4961 100644 --- a/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs @@ -36,8 +36,6 @@ namespace SixLabors.ImageSharp.Quantizers public class WuQuantizer : QuantizerBase where TPixel : struct, IPixel { - private readonly MemoryManager memoryManager; - /// /// The index bits. /// @@ -121,15 +119,13 @@ namespace SixLabors.ImageSharp.Quantizers /// /// Initializes a new instance of the class. /// - /// The to use for buffer allocations. /// /// The Wu quantizer is a two pass algorithm. The initial pass sets up the 3-D color histogram, /// the second pass quantizes a color based on the position in the histogram. /// - public WuQuantizer(MemoryManager memoryManager) + public WuQuantizer() : base(false) { - this.memoryManager = memoryManager; } /// @@ -141,15 +137,17 @@ namespace SixLabors.ImageSharp.Quantizers this.palette = null; this.colorMap.Clear(); + MemoryManager memoryManager = image.MemoryManager; + try { - this.vwt = this.memoryManager.Allocate(TableLength, true); - this.vmr = this.memoryManager.Allocate(TableLength, true); - this.vmg = this.memoryManager.Allocate(TableLength, true); - this.vmb = this.memoryManager.Allocate(TableLength, true); - this.vma = this.memoryManager.Allocate(TableLength, true); - this.m2 = this.memoryManager.Allocate(TableLength, true); - this.tag = this.memoryManager.Allocate(TableLength, true); + 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); return base.Quantize(image, this.colors); } @@ -240,7 +238,7 @@ namespace SixLabors.ImageSharp.Quantizers } } - this.Get3DMoments(); + this.Get3DMoments(source.MemoryManager); this.BuildCube(); } @@ -458,21 +456,21 @@ namespace SixLabors.ImageSharp.Quantizers /// /// Converts the histogram into moments so that we can rapidly calculate the sums of the above quantities over any desired box. /// - private void Get3DMoments() + private void Get3DMoments(MemoryManager memoryManager) { - using (Buffer volume = this.memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeR = this.memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeG = this.memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeB = this.memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volumeA = this.memoryManager.Allocate(IndexCount * IndexAlphaCount)) - using (Buffer volume2 = this.memoryManager.Allocate(IndexCount * IndexAlphaCount)) - - using (Buffer area = this.memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaR = this.memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaG = this.memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaB = this.memoryManager.Allocate(IndexAlphaCount)) - using (Buffer areaA = this.memoryManager.Allocate(IndexAlphaCount)) - using (Buffer area2 = this.memoryManager.Allocate(IndexAlphaCount)) + using (Buffer volume = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (Buffer volumeR = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (Buffer volumeG = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (Buffer volumeB = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (Buffer volumeA = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + using (Buffer volume2 = memoryManager.Allocate(IndexCount * IndexAlphaCount)) + + using (Buffer area = memoryManager.Allocate(IndexAlphaCount)) + using (Buffer areaR = memoryManager.Allocate(IndexAlphaCount)) + using (Buffer areaG = memoryManager.Allocate(IndexAlphaCount)) + using (Buffer areaB = memoryManager.Allocate(IndexAlphaCount)) + using (Buffer areaA = memoryManager.Allocate(IndexAlphaCount)) + using (Buffer area2 = memoryManager.Allocate(IndexAlphaCount)) { for (int r = 1; r < IndexCount; r++) { diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs index 4ce5f5083..e5eb29544 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs @@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream()) { - PngEncoder encoder = new PngEncoder(Configuration.Default.MemoryManager) { Quantizer = new OctreeQuantizer(), PaletteSize = 256 }; + PngEncoder encoder = new PngEncoder() { Quantizer = new OctreeQuantizer(), PaletteSize = 256 }; this.bmpCore.SaveAsPng(memoryStream, encoder); } @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream()) { - PngEncoder options = new PngEncoder(Configuration.Default.MemoryManager) { Quantizer = new OctreeQuantizer { Dither = false }, PaletteSize = 256 }; + PngEncoder options = new PngEncoder() { Quantizer = new OctreeQuantizer { Dither = false }, PaletteSize = 256 }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream()) { - PngEncoder options = new PngEncoder(Configuration.Default.MemoryManager) { Quantizer = new PaletteQuantizer(), PaletteSize = 256 }; + PngEncoder options = new PngEncoder() { Quantizer = new PaletteQuantizer(), PaletteSize = 256 }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream()) { - PngEncoder options = new PngEncoder(Configuration.Default.MemoryManager) { Quantizer = new PaletteQuantizer { Dither = false }, PaletteSize = 256 }; + PngEncoder options = new PngEncoder() { Quantizer = new PaletteQuantizer { Dither = false }, PaletteSize = 256 }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream()) { - PngEncoder options = new PngEncoder(Configuration.Default.MemoryManager) { Quantizer = new WuQuantizer(Configuration.Default.MemoryManager), PaletteSize = 256 }; + PngEncoder options = new PngEncoder() { Quantizer = new WuQuantizer(), PaletteSize = 256 }; this.bmpCore.SaveAsPng(memoryStream, options); } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs index 383505e0d..53522a51f 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image new OctreeQuantizer() : new PaletteQuantizer(); - var options = new PngEncoder(Configuration.Default.MemoryManager) { Quantizer = quantizer }; + var options = new PngEncoder() { Quantizer = quantizer }; this.bmpCore.SaveAsPng(memoryStream, options); } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index d3fcc5322..5ca09ad1d 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -1,131 +1,144 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.IO; -using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.Processing; -using Moq; -using SixLabors.Primitives; -using SixLabors.Shapes; -using Xunit; - namespace SixLabors.ImageSharp.Tests.Drawing.Paths { - public class ShapeRegionTests + using System; + + using Moq; + + using SixLabors.ImageSharp.Drawing; + using SixLabors.Primitives; + using SixLabors.Shapes; + + using Xunit; + + public class ShapeRegionTests { private readonly Mock pathMock; - private readonly SixLabors.Primitives.RectangleF bounds; + + private readonly RectangleF bounds; public ShapeRegionTests() { this.pathMock = new Mock(); this.bounds = new RectangleF(10.5f, 10, 10, 10); - pathMock.Setup(x => x.Bounds).Returns(this.bounds); + this.pathMock.Setup(x => x.Bounds).Returns(this.bounds); // wire up the 2 mocks to reference eachother - pathMock.Setup(x => x.AsClosedPath()).Returns(() => pathMock.Object); + this.pathMock.Setup(x => x.AsClosedPath()).Returns(() => this.pathMock.Object); } [Fact] public void ShapeRegionWithPathCallsAsShape() { - new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); + new ShapeRegion(this.pathMock.Object); - pathMock.Verify(x => x.AsClosedPath()); + this.pathMock.Verify(x => x.AsClosedPath()); } [Fact] public void ShapeRegionWithPathRetainsShape() { - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); - Assert.Equal(pathMock.Object, region.Shape); + Assert.Equal(this.pathMock.Object, region.Shape); } [Fact] public void ShapeRegionFromPathConvertsBoundsProxyToShape() { - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); - Assert.Equal(Math.Floor(bounds.Left), region.Bounds.Left); - Assert.Equal(Math.Ceiling(bounds.Right), region.Bounds.Right); + Assert.Equal(Math.Floor(this.bounds.Left), region.Bounds.Left); + Assert.Equal(Math.Ceiling(this.bounds.Right), region.Bounds.Right); - pathMock.Verify(x => x.Bounds); + this.pathMock.Verify(x => x.Bounds); } [Fact] public void ShapeRegionFromPathMaxIntersectionsProxyToShape() { - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); int i = region.MaxIntersections; - pathMock.Verify(x => x.MaxIntersections); + this.pathMock.Verify(x => x.MaxIntersections); } [Fact] public void ShapeRegionFromPathScanYProxyToShape() { int yToScan = 10; - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); - - pathMock.Setup(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((s, e, b, o) => { - Assert.Equal(yToScan, s.Y); - Assert.Equal(yToScan, e.Y); - Assert.True(s.X < bounds.Left); - Assert.True(e.X > bounds.Right); - }).Returns(0); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); + + this.pathMock + .Setup( + x => x.FindIntersections( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())).Callback( + (s, e, b, o) => + { + Assert.Equal(yToScan, s.Y); + Assert.Equal(yToScan, e.Y); + Assert.True(s.X < this.bounds.Left); + Assert.True(e.X > this.bounds.Right); + }).Returns(0); int i = region.Scan(yToScan, new float[0], 0); - pathMock.Verify(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + this.pathMock.Verify( + x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), + Times.Once); } [Fact] public void ShapeRegionFromShapeScanYProxyToShape() { int yToScan = 10; - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); - - pathMock.Setup(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((s, e, b, o) => { - Assert.Equal(yToScan, s.Y); - Assert.Equal(yToScan, e.Y); - Assert.True(s.X < bounds.Left); - Assert.True(e.X > bounds.Right); - }).Returns(0); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); + + this.pathMock + .Setup( + x => x.FindIntersections( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny())).Callback( + (s, e, b, o) => + { + Assert.Equal(yToScan, s.Y); + Assert.Equal(yToScan, e.Y); + Assert.True(s.X < this.bounds.Left); + Assert.True(e.X > this.bounds.Right); + }).Returns(0); int i = region.Scan(yToScan, new float[0], 0); - pathMock.Verify(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + this.pathMock.Verify( + x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), + Times.Once); } [Fact] public void ShapeRegionFromShapeConvertsBoundsProxyToShape() { - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); - Assert.Equal(Math.Floor(bounds.Left), region.Bounds.Left); - Assert.Equal(Math.Ceiling(bounds.Right), region.Bounds.Right); + Assert.Equal(Math.Floor(this.bounds.Left), region.Bounds.Left); + Assert.Equal(Math.Ceiling(this.bounds.Right), region.Bounds.Right); - pathMock.Verify(x => x.Bounds); + this.pathMock.Verify(x => x.Bounds); } [Fact] public void ShapeRegionFromShapeMaxIntersectionsProxyToShape() { - ShapeRegion region = new ShapeRegion(Configuration.Default.MemoryManager, pathMock.Object); + ShapeRegion region = new ShapeRegion(this.pathMock.Object); int i = region.MaxIntersections; - pathMock.Verify(x => x.MaxIntersections); + this.pathMock.Verify(x => x.MaxIntersections); } } -} +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index a6a883d42..22a811fee 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -14,9 +14,6 @@ namespace SixLabors.ImageSharp.Tests { using System; - using SixLabors.ImageSharp.Advanced; - using SixLabors.ImageSharp.Memory; - public class GeneralFormatTests : FileTestBase { [Theory] @@ -179,7 +176,7 @@ namespace SixLabors.ImageSharp.Tests { using (var memoryStream = new MemoryStream()) { - image.Save(memoryStream, GetEncoder(image.GetMemoryManager(), format)); + image.Save(memoryStream, GetEncoder(format)); memoryStream.Position = 0; var imageInfo = Image.Identify(memoryStream); @@ -190,12 +187,12 @@ namespace SixLabors.ImageSharp.Tests } } - private static IImageEncoder GetEncoder(MemoryManager memoryManager, string format) + private static IImageEncoder GetEncoder(string format) { switch (format) { case "png": - return new PngEncoder(memoryManager); + return new PngEncoder(); case "gif": return new GifEncoder(); case "bmp": diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index ba6c19e46..28f156279 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests using (Image image = provider.GetImage()) using (var ms = new MemoryStream()) { - image.Save(ms, new PngEncoder(Configuration.Default.MemoryManager)); + image.Save(ms, new PngEncoder()); byte[] data = ms.ToArray().Take(8).ToArray(); byte[] expected = { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index 3a73867ba..fc17df93d 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png { // image.Save(provider.Utility.GetTestOutputFileName("bmp")); - image.Save(ms, new PngEncoder(Configuration.Default.MemoryManager)); + image.Save(ms, new PngEncoder()); ms.Position = 0; using (Image img2 = Image.Load(ms, new PngDecoder())) { @@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png image.Mutate(x => x.Resize(100, 100)); // image.Save(provider.Utility.GetTestOutputFileName("png", "resize")); - image.Save(ms, new PngEncoder(Configuration.Default.MemoryManager)); + image.Save(ms, new PngEncoder()); ms.Position = 0; using (Image img2 = Image.Load(ms, new PngDecoder())) { diff --git a/tests/ImageSharp.Tests/Image/ImageTests.cs b/tests/ImageSharp.Tests/Image/ImageTests.cs index 45ecf60a0..da813f428 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.cs @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests using (Image image = new Image(10, 10)) { - image.Save(file, new PngEncoder(Configuration.Default.MemoryManager)); + image.Save(file, new PngEncoder()); } using (Image img = Image.Load(file, out var mime)) { diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 5d569aa8f..18fd29237 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -12,7 +12,7 @@ { var palette = new PaletteQuantizer(); var octree = new OctreeQuantizer(); - var wu = new WuQuantizer(Configuration.Default.MemoryManager); + var wu = new WuQuantizer(); Assert.True(palette.Dither); Assert.True(octree.Dither); @@ -73,7 +73,7 @@ { Assert.True(image[0, 0].Equals(default(TPixel))); - IQuantizer quantizer = new WuQuantizer(Configuration.Default.MemoryManager) { Dither = dither }; + IQuantizer quantizer = new WuQuantizer() { Dither = dither }; foreach (ImageFrame frame in image.Frames) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs index b454f1608..dde34fcc4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceCodecTests.cs @@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests sourceImage.Mutate(c => c.Opacity(1)); } - var encoder = new PngEncoder(Configuration.Default.MemoryManager) { PngColorType = pngColorType }; + var encoder = new PngEncoder() { PngColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } }