Browse Source

The return of IPackedVector<T>

af/merge-core
Anton Firszov 9 years ago
parent
commit
3cdc423500
  1. 2
      src/ImageSharp/Colors/Color.cs
  2. 2
      src/ImageSharp/Colors/PackedPixel/Alpha8.cs
  3. 2
      src/ImageSharp/Colors/PackedPixel/Argb.cs
  4. 2
      src/ImageSharp/Colors/PackedPixel/Bgr565.cs
  5. 2
      src/ImageSharp/Colors/PackedPixel/Bgra4444.cs
  6. 2
      src/ImageSharp/Colors/PackedPixel/Bgra5551.cs
  7. 2
      src/ImageSharp/Colors/PackedPixel/Byte4.cs
  8. 2
      src/ImageSharp/Colors/PackedPixel/HalfSingle.cs
  9. 2
      src/ImageSharp/Colors/PackedPixel/HalfVector2.cs
  10. 2
      src/ImageSharp/Colors/PackedPixel/HalfVector4.cs
  11. 24
      src/ImageSharp/Colors/PackedPixel/IPackedVector{TPacked}.cs
  12. 2
      src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs
  13. 2
      src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs
  14. 2
      src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs
  15. 2
      src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs
  16. 2
      src/ImageSharp/Colors/PackedPixel/Rg32.cs
  17. 2
      src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs
  18. 2
      src/ImageSharp/Colors/PackedPixel/Rgba64.cs
  19. 2
      src/ImageSharp/Colors/PackedPixel/Short2.cs
  20. 2
      src/ImageSharp/Colors/PackedPixel/Short4.cs
  21. 18
      tests/ImageSharp.Tests/Common/ArrayPointerTests.cs

2
src/ImageSharp/Colors/Color.cs

@ -18,7 +18,7 @@ namespace ImageSharp
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations. /// as it avoids the need to create new values for modification operations.
/// </remarks> /// </remarks>
public partial struct Color : IPixel<Color> public partial struct Color : IPixel<Color>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The shift count for the red component /// The shift count for the red component

2
src/ImageSharp/Colors/PackedPixel/Alpha8.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing a single 8 bit normalized W values ranging from 0 to 1. /// Packed pixel type containing a single 8 bit normalized W values ranging from 0 to 1.
/// </summary> /// </summary>
public struct Alpha8 : IPixel<Alpha8> public struct Alpha8 : IPixel<Alpha8>, IPackedVector<byte>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Alpha8"/> struct. /// Initializes a new instance of the <see cref="Alpha8"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Argb.cs

@ -17,7 +17,7 @@ namespace ImageSharp
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations. /// as it avoids the need to create new values for modification operations.
/// </remarks> /// </remarks>
public struct Argb : IPixel<Argb> public struct Argb : IPixel<Argb>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The shift count for the blue component /// The shift count for the blue component

2
src/ImageSharp/Colors/PackedPixel/Bgr565.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing unsigned normalized values ranging from 0 to 1. The x and z components use 5 bits, and the y component uses 6 bits. /// Packed pixel type containing unsigned normalized values ranging from 0 to 1. The x and z components use 5 bits, and the y component uses 6 bits.
/// </summary> /// </summary>
public struct Bgr565 : IPixel<Bgr565> public struct Bgr565 : IPixel<Bgr565>, IPackedVector<ushort>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Bgr565"/> struct. /// Initializes a new instance of the <see cref="Bgr565"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Bgra4444.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing unsigned normalized values, ranging from 0 to 1, using 4 bits each for x, y, z, and w. /// Packed pixel type containing unsigned normalized values, ranging from 0 to 1, using 4 bits each for x, y, z, and w.
/// </summary> /// </summary>
public struct Bgra4444 : IPixel<Bgra4444> public struct Bgra4444 : IPixel<Bgra4444>, IPackedVector<ushort>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Bgra4444"/> struct. /// Initializes a new instance of the <see cref="Bgra4444"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Bgra5551.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing unsigned normalized values ranging from 0 to 1. The x , y and z components use 5 bits, and the w component uses 1 bit. /// Packed pixel type containing unsigned normalized values ranging from 0 to 1. The x , y and z components use 5 bits, and the w component uses 1 bit.
/// </summary> /// </summary>
public struct Bgra5551 : IPixel<Bgra5551> public struct Bgra5551 : IPixel<Bgra5551>, IPackedVector<ushort>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Bgra5551"/> struct. /// Initializes a new instance of the <see cref="Bgra5551"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Byte4.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing four 8-bit unsigned integer values, ranging from 0 to 255. /// Packed pixel type containing four 8-bit unsigned integer values, ranging from 0 to 255.
/// </summary> /// </summary>
public struct Byte4 : IPixel<Byte4> public struct Byte4 : IPixel<Byte4>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Byte4"/> struct. /// Initializes a new instance of the <see cref="Byte4"/> struct.

2
src/ImageSharp/Colors/PackedPixel/HalfSingle.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing a single 16 bit floating point value. /// Packed pixel type containing a single 16 bit floating point value.
/// </summary> /// </summary>
public struct HalfSingle : IPixel<HalfSingle> public struct HalfSingle : IPixel<HalfSingle>, IPackedVector<ushort>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/HalfVector2.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing two 16-bit floating-point values. /// Packed pixel type containing two 16-bit floating-point values.
/// </summary> /// </summary>
public struct HalfVector2 : IPixel<HalfVector2> public struct HalfVector2 : IPixel<HalfVector2>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/HalfVector4.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing four 16-bit floating-point values. /// Packed pixel type containing four 16-bit floating-point values.
/// </summary> /// </summary>
public struct HalfVector4 : IPixel<HalfVector4> public struct HalfVector4 : IPixel<HalfVector4>, IPackedVector<ulong>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

24
src/ImageSharp/Colors/PackedPixel/IPackedVector{TPacked}.cs

@ -0,0 +1,24 @@
// <copyright file="IPackedVector{TPacked}.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;
using System.Numerics;
/// <summary>
/// This interface exists for ensuring signature compatibility to MonoGame and XNA packed color types.
/// <see href="https://msdn.microsoft.com/en-us/library/bb197661.aspx" />
/// </summary>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public interface IPackedVector<TPacked> : IPixel
where TPacked : struct, IEquatable<TPacked>
{
/// <summary>
/// Gets or sets the packed representation of the value.
/// </summary>
TPacked PackedValue { get; set; }
}
}

2
src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed packed pixel type containing two 8-bit signed normalized values, ranging from −1 to 1. /// Packed packed pixel type containing two 8-bit signed normalized values, ranging from −1 to 1.
/// </summary> /// </summary>
public struct NormalizedByte2 : IPixel<NormalizedByte2> public struct NormalizedByte2 : IPixel<NormalizedByte2>, IPackedVector<ushort>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing four 8-bit signed normalized values, ranging from −1 to 1. /// Packed pixel type containing four 8-bit signed normalized values, ranging from −1 to 1.
/// </summary> /// </summary>
public struct NormalizedByte4 : IPixel<NormalizedByte4> public struct NormalizedByte4 : IPixel<NormalizedByte4>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing two 16-bit signed normalized values, ranging from −1 to 1. /// Packed pixel type containing two 16-bit signed normalized values, ranging from −1 to 1.
/// </summary> /// </summary>
public struct NormalizedShort2 : IPixel<NormalizedShort2> public struct NormalizedShort2 : IPixel<NormalizedShort2>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing four 16-bit signed normalized values, ranging from −1 to 1. /// Packed pixel type containing four 16-bit signed normalized values, ranging from −1 to 1.
/// </summary> /// </summary>
public struct NormalizedShort4 : IPixel<NormalizedShort4> public struct NormalizedShort4 : IPixel<NormalizedShort4>, IPackedVector<ulong>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/Rg32.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing two 16-bit unsigned normalized values ranging from 0 to 1. /// Packed pixel type containing two 16-bit unsigned normalized values ranging from 0 to 1.
/// </summary> /// </summary>
public struct Rg32 : IPixel<Rg32> public struct Rg32 : IPixel<Rg32>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rg32"/> struct. /// Initializes a new instance of the <see cref="Rg32"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs

@ -13,7 +13,7 @@ namespace ImageSharp
/// Packed vector type containing unsigned normalized values ranging from 0 to 1. /// Packed vector type containing unsigned normalized values ranging from 0 to 1.
/// The x, y and z components use 10 bits, and the w component uses 2 bits. /// The x, y and z components use 10 bits, and the w component uses 2 bits.
/// </summary> /// </summary>
public struct Rgba1010102 : IPixel<Rgba1010102> public struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rgba1010102"/> struct. /// Initializes a new instance of the <see cref="Rgba1010102"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Rgba64.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing four 16-bit unsigned normalized values ranging from 0 to 1. /// Packed pixel type containing four 16-bit unsigned normalized values ranging from 0 to 1.
/// </summary> /// </summary>
public struct Rgba64 : IPixel<Rgba64> public struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong>
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rgba64"/> struct. /// Initializes a new instance of the <see cref="Rgba64"/> struct.

2
src/ImageSharp/Colors/PackedPixel/Short2.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing two 16-bit signed integer values. /// Packed pixel type containing two 16-bit signed integer values.
/// </summary> /// </summary>
public struct Short2 : IPixel<Short2> public struct Short2 : IPixel<Short2>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

2
src/ImageSharp/Colors/PackedPixel/Short4.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// <summary> /// <summary>
/// Packed pixel type containing four 16-bit signed integer values. /// Packed pixel type containing four 16-bit signed integer values.
/// </summary> /// </summary>
public struct Short4 : IPixel<Short4> public struct Short4 : IPixel<Short4>, IPackedVector<ulong>
{ {
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.

18
tests/ImageSharp.Tests/Common/ArrayPointerTests.cs

@ -26,23 +26,7 @@ namespace ImageSharp.Tests.Common
return result; return result;
} }
} }
[Fact]
public void ConstructWithNullArray_Throws()
{
Assert.Throws<ArgumentNullException>(
() =>
{
new ArrayPointer<int>(null, (void*)0);
});
Assert.Throws<ArgumentNullException>(
() =>
{
new ArrayPointer<int>(null, (void*)0);
});
}
[Fact] [Fact]
public void ConstructWithoutOffset() public void ConstructWithoutOffset()
{ {

Loading…
Cancel
Save