Browse Source

Renamed BulkPixelOperation methods, removed ArrayExtensions and the unused dangerous PixelAccessor ctr.

pull/125/head
Anton Firszov 9 years ago
parent
commit
a8ab5d4b89
  1. 10
      src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs
  2. 29
      src/ImageSharp/Common/Extensions/ArrayExtensions.cs
  3. 2
      src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs
  4. 3
      src/ImageSharp/Image/ImageBase{TColor}.cs
  5. 11
      src/ImageSharp/Image/PixelAccessor{TColor}.cs
  6. 3
      tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj
  7. 2
      tests/ImageSharp.Sandbox46/Program.cs
  8. 10
      tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs
  9. 0
      tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs

10
src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs

@ -58,7 +58,7 @@ namespace ImageSharp
/// <param name="sourceColors">The <see cref="ArrayPointer{TColor}"/> to the source colors.</param>
/// <param name="destVectors">The <see cref="ArrayPointer{Vector4}"/> to the destination vectors.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackToVector4(
internal virtual void ToVector4(
ArrayPointer<TColor> sourceColors,
ArrayPointer<Vector4> destVectors,
int count)
@ -105,7 +105,7 @@ namespace ImageSharp
/// <param name="sourceColors">The <see cref="ArrayPointer{TColor}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="ArrayPointer{Byte}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackToXyzBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count)
internal virtual void ToXyzBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count)
{
byte* sp = (byte*)sourceColors;
byte[] dest = destBytes.Array;
@ -148,7 +148,7 @@ namespace ImageSharp
/// <param name="sourceColors">The <see cref="ArrayPointer{TColor}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="ArrayPointer{Byte}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackToXyzwBytes(
internal virtual void ToXyzwBytes(
ArrayPointer<TColor> sourceColors,
ArrayPointer<byte> destBytes,
int count)
@ -194,7 +194,7 @@ namespace ImageSharp
/// <param name="sourceColors">The <see cref="ArrayPointer{TColor}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="ArrayPointer{Byte}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackToZyxBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count)
internal virtual void ToZyxBytes(ArrayPointer<TColor> sourceColors, ArrayPointer<byte> destBytes, int count)
{
byte* sp = (byte*)sourceColors;
byte[] dest = destBytes.Array;
@ -237,7 +237,7 @@ namespace ImageSharp
/// <param name="sourceColors">The <see cref="ArrayPointer{TColor}"/> to the source colors.</param>
/// <param name="destBytes">The <see cref="ArrayPointer{Byte}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
internal virtual void PackToZyxwBytes(
internal virtual void ToZyxwBytes(
ArrayPointer<TColor> sourceColors,
ArrayPointer<byte> destBytes,
int count)

29
src/ImageSharp/Common/Extensions/ArrayExtensions.cs

@ -1,29 +0,0 @@
// <copyright file="ArrayExtensions.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
/// <summary>
/// Extension methods for arrays.
/// </summary>
public static class ArrayExtensions
{
/// <summary>
/// Locks the pixel buffer providing access to the pixels.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="pixels">The pixel buffer.</param>
/// <param name="width">Gets the width of the image represented by the pixel buffer.</param>
/// <param name="height">The height of the image represented by the pixel buffer.</param>
/// <returns>The <see cref="PixelAccessor{TColor}"/></returns>
public static PixelAccessor<TColor> Lock<TColor>(this TColor[] pixels, int width, int height)
where TColor : struct, IPixel<TColor>
{
return new PixelAccessor<TColor>(width, height, pixels);
}
}
}

2
src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs

@ -23,7 +23,7 @@ namespace ImageSharp
private GCHandle handle;
/// <summary>
/// A value indicating wether this <see cref="PinnedBuffer{T}"/> instance should return the array to the pool.
/// A value indicating whether this <see cref="PinnedBuffer{T}"/> instance should return the array to the pool.
/// </summary>
private bool isPoolingOwner;

3
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<TColor>.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;

11
src/ImageSharp/Image/PixelAccessor{TColor}.cs

@ -53,17 +53,6 @@ namespace ImageSharp
this.ParallelOptions = image.Configuration.ParallelOptions;
}
/// <summary>
/// Initializes a new instance of the <see cref="PixelAccessor{TColor}"/> class.
/// </summary>
/// <param name="width">The width of the image represented by the pixel buffer.</param>
/// <param name="height">The height of the image represented by the pixel buffer.</param>
/// <param name="pixels">The pixel buffer.</param>
public PixelAccessor(int width, int height, TColor[] pixels)
: this(width, height, new PinnedBuffer<TColor>(width * height, pixels))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PixelAccessor{TColor}"/> class.
/// </summary>

3
tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj

@ -251,9 +251,6 @@
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\YCbCrImageTests.cs">
<Link>Tests\Formats\Jpg\YCbCrImageTests.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Image\PixelPoolTests.cs">
<Link>Tests\Image\PixelPoolTests.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\MetaData\ImagePropertyTests.cs">
<Link>Tests\MetaData\ImagePropertyTests.cs</Link>
</Compile>

2
tests/ImageSharp.Sandbox46/Program.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Sandbox46
/// </param>
public static void Main(string[] args)
{
//RunDecodeJpegProfilingTests();
// RunDecodeJpegProfilingTests();
TestPixelAccessorCopyFromXyzw();
Console.ReadLine();
}

10
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)
);
}

0
tests/ImageSharp.Tests/Image/PixelPoolTests.cs → tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs

Loading…
Cancel
Save