Browse Source

Restore GetPixelTypeInfo

pull/2645/head
James Jackson-South 2 years ago
parent
commit
8af75fe0d4
  1. 13
      src/ImageSharp/PixelFormats/IPixel.cs
  2. 4
      tests/ImageSharp.Tests/ImageSharp.Tests.csproj
  3. 12
      tests/ImageSharp.Tests/Issues/Issue594.cs
  4. 4
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
  5. 9
      tests/ImageSharp.Tests/TestUtilities/ApproximateFloatComparer.cs

13
src/ImageSharp/PixelFormats/IPixel.cs

@ -22,13 +22,6 @@ public interface IPixel<TSelf> : IPixel, IEquatable<TSelf>
PixelOperations<TSelf> CreatePixelOperations();
#pragma warning disable CA1000 // Do not declare static members on generic types
/// <summary>
/// Gets the pixel type information.
/// </summary>
/// <returns>The <see cref="PixelTypeInfo"/>.</returns>
static abstract PixelTypeInfo GetPixelTypeInfo();
/// <summary>
/// Initializes the pixel instance from a generic scaled <see cref="Vector4"/>.
/// </summary>
@ -141,6 +134,12 @@ public interface IPixel<TSelf> : IPixel, IEquatable<TSelf>
/// </summary>
public interface IPixel
{
/// <summary>
/// Gets the pixel type information.
/// </summary>
/// <returns>The <see cref="PixelTypeInfo"/>.</returns>
static abstract PixelTypeInfo GetPixelTypeInfo();
/// <summary>
/// Convert the pixel instance into <see cref="Rgba32"/> representation.
/// </summary>

4
tests/ImageSharp.Tests/ImageSharp.Tests.csproj

@ -80,9 +80,5 @@
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Folder Include="Formats\Qoi\" />
</ItemGroup>
</Project>

12
tests/ImageSharp.Tests/Issues/Issue594.cs

@ -8,9 +8,7 @@ namespace SixLabors.ImageSharp.Tests.Issues;
public class Issue594
{
// This test fails for unknown reason in Release mode on linux and is meant to help reproducing the issue
// see https://github.com/SixLabors/ImageSharp/issues/594
[Fact] // (Skip = "Skipped because of issue #594")]
[Fact]
public void NormalizedByte4Test()
{
// Test PackedValue
@ -50,9 +48,7 @@ public class Issue594
Assert.Equal(958796544U, new NormalizedByte4(0.0008f, 0.15f, 0.30f, 0.45f).PackedValue);
}
// This test fails for unknown reason in Release mode on linux and is meant to help reproducing the issue
// see https://github.com/SixLabors/ImageSharp/issues/594
[Fact] //(Skip = "Skipped because of issue #594")]
[Fact]
public void NormalizedShort4Test()
{
// Test PackedValue
@ -87,9 +83,7 @@ public class Issue594
Assert.Equal(4150390751449251866UL, new NormalizedShort4(0.0008f, 0.15f, 0.30f, 0.45f).PackedValue);
}
// This test fails for unknown reason in Release mode on linux and is meant to help reproducing the issue
// see https://github.com/SixLabors/ImageSharp/issues/594
[Fact] // (Skip = "Skipped because of issue #594")]
[Fact]
public void Short4Test()
{
// Test the limits.

4
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs

@ -1216,7 +1216,7 @@ public abstract class PixelOperationsTests<TPixel> : MeasureFixture
for (int i = 0; i < count; i++)
{
Assert.Equal((IPixel)expected[i], (IPixel)actual[i], comparer);
Assert.Equal(((IPixel)expected[i]).ToScaledVector4(), ((IPixel)actual[i]).ToScaledVector4(), comparer);
}
}
else
@ -1231,7 +1231,7 @@ public abstract class PixelOperationsTests<TPixel> : MeasureFixture
}
}
// TODO: We really need a PixelTypeInfo.BitsPerComponent property!!
// TODO: Figure out a means to use PixelTypeInfo here.
private static bool IsComplexPixel() => default(TDest) switch
{
HalfSingle or HalfVector2 or L16 or La32 or NormalizedShort2 or Rg32 or Short2 => true,

9
tests/ImageSharp.Tests/TestUtilities/ApproximateFloatComparer.cs

@ -4,7 +4,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.Intrinsics;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Tests;
@ -14,7 +13,6 @@ namespace SixLabors.ImageSharp.Tests;
internal readonly struct ApproximateFloatComparer :
IEqualityComparer<float>,
IEqualityComparer<Vector2>,
IEqualityComparer<IPixel>,
IEqualityComparer<Vector4>,
IEqualityComparer<ColorMatrix>,
IEqualityComparer<Vector256<float>>
@ -47,13 +45,6 @@ internal readonly struct ApproximateFloatComparer :
public int GetHashCode(Vector2 obj)
=> obj.GetHashCode();
/// <inheritdoc/>
public bool Equals(IPixel x, IPixel y)
=> this.Equals(x.ToScaledVector4(), y.ToScaledVector4());
public int GetHashCode(IPixel obj)
=> obj.ToScaledVector4().GetHashCode();
/// <inheritdoc/>
public bool Equals(Vector4 x, Vector4 y)
=> this.Equals(x.X, y.X)

Loading…
Cancel
Save