From a8ab5d4b89591bf865b9aac3136006c6083ca8e2 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 6 Mar 2017 01:15:07 +0100 Subject: [PATCH] Renamed BulkPixelOperation methods, removed ArrayExtensions and the unused dangerous PixelAccessor ctr. --- .../BulkPixelOperations{TColor}.cs | 10 +++---- .../Common/Extensions/ArrayExtensions.cs | 29 ------------------- .../Common/Memory/PinnedBuffer{T}.cs | 2 +- src/ImageSharp/Image/ImageBase{TColor}.cs | 3 -- src/ImageSharp/Image/PixelAccessor{TColor}.cs | 11 ------- .../ImageSharp.Sandbox46.csproj | 3 -- tests/ImageSharp.Sandbox46/Program.cs | 2 +- .../Colors/BulkPixelOperationsTests.cs | 10 +++---- .../PixelDataPoolTests.cs} | 0 9 files changed, 12 insertions(+), 58 deletions(-) delete mode 100644 src/ImageSharp/Common/Extensions/ArrayExtensions.cs rename tests/ImageSharp.Tests/{Image/PixelPoolTests.cs => Common/PixelDataPoolTests.cs} (100%) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs index 986994af7b..a84c3edf3e 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs @@ -58,7 +58,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination vectors. /// The number of pixels to convert. - internal virtual void PackToVector4( + internal virtual void ToVector4( ArrayPointer sourceColors, ArrayPointer destVectors, int count) @@ -105,7 +105,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void ToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; @@ -148,7 +148,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToXyzwBytes( + internal virtual void ToXyzwBytes( ArrayPointer sourceColors, ArrayPointer destBytes, int count) @@ -194,7 +194,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void ToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; @@ -237,7 +237,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToZyxwBytes( + internal virtual void ToZyxwBytes( ArrayPointer sourceColors, ArrayPointer destBytes, int count) diff --git a/src/ImageSharp/Common/Extensions/ArrayExtensions.cs b/src/ImageSharp/Common/Extensions/ArrayExtensions.cs deleted file mode 100644 index cce442c522..0000000000 --- a/src/ImageSharp/Common/Extensions/ArrayExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - - /// - /// Extension methods for arrays. - /// - public static class ArrayExtensions - { - /// - /// Locks the pixel buffer providing access to the pixels. - /// - /// The pixel format. - /// The pixel buffer. - /// Gets the width of the image represented by the pixel buffer. - /// The height of the image represented by the pixel buffer. - /// The - public static PixelAccessor Lock(this TColor[] pixels, int width, int height) - where TColor : struct, IPixel - { - return new PixelAccessor(width, height, pixels); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index d95d675571..04217a0123 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -23,7 +23,7 @@ namespace ImageSharp private GCHandle handle; /// - /// A value indicating wether this instance should return the array to the pool. + /// A value indicating whether this instance should return the array to the pool. /// private bool isPoolingOwner; diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index c2110eca4f..2badc008a2 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -163,9 +163,6 @@ namespace ImageSharp { Guard.NotNull(pixelSource, nameof(pixelSource)); - // TODO: Was this check really useful? If yes, we can define a bool PixelAccessor.IsBoundToImage to re-introduce it: - - // Guard.IsTrue(pixelSource.PooledMemory, nameof(pixelSource.PooledMemory), "pixelSource must be using pooled memory"); int newWidth = pixelSource.Width; int newHeight = pixelSource.Height; diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index 9201270d9d..e104b8ae77 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -53,17 +53,6 @@ namespace ImageSharp this.ParallelOptions = image.Configuration.ParallelOptions; } - /// - /// Initializes a new instance of the class. - /// - /// The width of the image represented by the pixel buffer. - /// The height of the image represented by the pixel buffer. - /// The pixel buffer. - public PixelAccessor(int width, int height, TColor[] pixels) - : this(width, height, new PinnedBuffer(width * height, pixels)) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 094eedb180..1d78994860 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -251,9 +251,6 @@ Tests\Formats\Jpg\YCbCrImageTests.cs - - Tests\Image\PixelPoolTests.cs - Tests\MetaData\ImagePropertyTests.cs diff --git a/tests/ImageSharp.Sandbox46/Program.cs b/tests/ImageSharp.Sandbox46/Program.cs index 3afd180941..4d6d159255 100644 --- a/tests/ImageSharp.Sandbox46/Program.cs +++ b/tests/ImageSharp.Sandbox46/Program.cs @@ -37,7 +37,7 @@ namespace ImageSharp.Sandbox46 /// public static void Main(string[] args) { - //RunDecodeJpegProfilingTests(); + // RunDecodeJpegProfilingTests(); TestPixelAccessorCopyFromXyzw(); Console.ReadLine(); } diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index c179b01a10..1c22411d09 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -67,7 +67,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToVector4(s, d, count) + (ops, s, d) => ops.ToVector4(s, d, count) ); } @@ -109,7 +109,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToXyzBytes(s, d, count) + (ops, s, d) => ops.ToXyzBytes(s, d, count) ); } @@ -150,7 +150,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToXyzwBytes(s, d, count) + (ops, s, d) => ops.ToXyzwBytes(s, d, count) ); } @@ -191,7 +191,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToZyxBytes(s, d, count) + (ops, s, d) => ops.ToZyxBytes(s, d, count) ); } @@ -232,7 +232,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToZyxwBytes(s, d, count) + (ops, s, d) => ops.ToZyxwBytes(s, d, count) ); } diff --git a/tests/ImageSharp.Tests/Image/PixelPoolTests.cs b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs similarity index 100% rename from tests/ImageSharp.Tests/Image/PixelPoolTests.cs rename to tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs