Browse Source

Make CreatePixelOperations static

pull/2645/head
James Jackson-South 2 years ago
parent
commit
3a3ff89ec4
  1. 4
      src/ImageSharp/PixelFormats/IPixel.cs
  2. 2
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  3. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs
  4. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  5. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  6. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
  7. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  8. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
  9. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
  10. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
  11. 2
      src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
  12. 2
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  13. 2
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
  14. 2
      src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
  15. 2
      src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
  16. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  17. 2
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  18. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  19. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
  20. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  21. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
  22. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
  23. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
  24. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  25. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
  26. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  27. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  28. 2
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
  29. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  30. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs
  31. 2
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
  32. 2
      tests/ImageSharp.Tests/Color/RgbaDouble.cs
  33. 2
      tests/ImageSharp.Tests/TestFormat.cs

4
src/ImageSharp/PixelFormats/IPixel.cs

@ -14,14 +14,14 @@ namespace SixLabors.ImageSharp.PixelFormats;
public interface IPixel<TSelf> : IPixel, IEquatable<TSelf>
where TSelf : unmanaged, IPixel<TSelf>
{
#pragma warning disable CA1000 // Do not declare static members on generic types
/// <summary>
/// Creates a <see cref="PixelOperations{TPixel}"/> instance for this pixel type.
/// This method is not intended to be consumed directly. Use <see cref="PixelOperations{TPixel}.Instance"/> instead.
/// </summary>
/// <returns>The <see cref="PixelOperations{TPixel}"/> instance.</returns>
PixelOperations<TSelf> CreatePixelOperations();
static abstract PixelOperations<TSelf> CreatePixelOperations();
#pragma warning disable CA1000 // Do not declare static members on generic types
/// <summary>
/// Initializes the pixel instance from a generic scaled <see cref="Vector4"/>.
/// </summary>

2
src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

@ -75,7 +75,7 @@ public partial struct A8 : IPixel<A8>, IPackedVector<byte>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<A8> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<A8> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

@ -192,7 +192,7 @@ public partial struct Abgr32 : IPixel<Abgr32>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Abgr32> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Abgr32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

@ -185,7 +185,7 @@ public partial struct Argb32 : IPixel<Argb32>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Argb32> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Argb32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs

@ -95,7 +95,7 @@ public partial struct Bgr24 : IPixel<Bgr24>
PixelAlphaRepresentation.None);
/// <inheritdoc/>
public readonly PixelOperations<Bgr24> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Bgr24> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs

@ -73,7 +73,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel<Bgr565>, IPackedVector<ush
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc />
public readonly Rgba32 ToRgba32() => Rgba32.FromScaledVector4(this.ToScaledVector4());

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

@ -134,7 +134,7 @@ public partial struct Bgra32 : IPixel<Bgra32>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc/>
public readonly PixelOperations<Bgra32> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Bgra32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs

@ -86,7 +86,7 @@ public partial struct Bgra4444 : IPixel<Bgra4444>, IPackedVector<ushort>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs

@ -84,7 +84,7 @@ public partial struct Bgra5551 : IPixel<Bgra5551>, IPackedVector<ushort>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Bgra5551> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Bgra5551> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs

@ -86,7 +86,7 @@ public partial struct Byte4 : IPixel<Byte4>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs

@ -70,7 +70,7 @@ public partial struct HalfSingle : IPixel<HalfSingle>, IPackedVector<ushort>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<HalfSingle> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<HalfSingle> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs

@ -82,7 +82,7 @@ public partial struct HalfVector2 : IPixel<HalfVector2>, IPackedVector<uint>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<HalfVector2> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<HalfVector2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs

@ -87,7 +87,7 @@ public partial struct HalfVector4 : IPixel<HalfVector4>, IPackedVector<ulong>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<HalfVector4> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<HalfVector4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/L16.cs

@ -75,7 +75,7 @@ public partial struct L16 : IPixel<L16>, IPackedVector<ushort>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<L16> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<L16> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/L8.cs

@ -77,7 +77,7 @@ public partial struct L8 : IPixel<L8>, IPackedVector<byte>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<L8> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<L8> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/La16.cs

@ -104,7 +104,7 @@ public partial struct La16 : IPixel<La16>, IPackedVector<ushort>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc/>
public readonly PixelOperations<La16> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<La16> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/La32.cs

@ -101,7 +101,7 @@ public partial struct La32 : IPixel<La32>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc/>
public readonly PixelOperations<La32> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<La32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs

@ -85,7 +85,7 @@ public partial struct NormalizedByte2 : IPixel<NormalizedByte2>, IPackedVector<u
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<NormalizedByte2> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<NormalizedByte2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs

@ -92,7 +92,7 @@ public partial struct NormalizedByte4 : IPixel<NormalizedByte4>, IPackedVector<u
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<NormalizedByte4> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<NormalizedByte4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs

@ -87,7 +87,7 @@ public partial struct NormalizedShort2 : IPixel<NormalizedShort2>, IPackedVector
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<NormalizedShort2> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<NormalizedShort2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs

@ -93,7 +93,7 @@ public partial struct NormalizedShort4 : IPixel<NormalizedShort4>, IPackedVector
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<NormalizedShort4> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<NormalizedShort4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs

@ -82,7 +82,7 @@ public partial struct Rg32 : IPixel<Rg32>, IPackedVector<uint>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<Rg32> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Rg32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs

@ -104,7 +104,7 @@ public partial struct Rgb24 : IPixel<Rgb24>
PixelAlphaRepresentation.None);
/// <inheritdoc/>
public readonly PixelOperations<Rgb24> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Rgb24> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs

@ -89,7 +89,7 @@ public partial struct Rgb48 : IPixel<Rgb48>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<Rgb48> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Rgb48> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs

@ -84,7 +84,7 @@ public partial struct Rgba1010102 : IPixel<Rgba1010102>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Rgba1010102> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Rgba1010102> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs

@ -288,7 +288,7 @@ public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Rgba32> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Rgba32> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs

@ -210,7 +210,7 @@ public partial struct Rgba64 : IPixel<Rgba64>, IPackedVector<ulong>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Rgba64> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Rgba64> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs

@ -104,7 +104,7 @@ public partial struct RgbaVector : IPixel<RgbaVector>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<RgbaVector> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<RgbaVector> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs

@ -90,7 +90,7 @@ public partial struct Short2 : IPixel<Short2>, IPackedVector<uint>
PixelAlphaRepresentation.None);
/// <inheritdoc />
public readonly PixelOperations<Short2> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Short2> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs

@ -97,7 +97,7 @@ public partial struct Short4 : IPixel<Short4>, IPackedVector<ulong>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<Short4> CreatePixelOperations() => new PixelOperations();
public static PixelOperations<Short4> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.PixelFormats;
public partial class PixelOperations<TPixel>
where TPixel : unmanaged, IPixel<TPixel>
{
private static readonly Lazy<PixelOperations<TPixel>> LazyInstance = new(() => default(TPixel).CreatePixelOperations(), true);
private static readonly Lazy<PixelOperations<TPixel>> LazyInstance = new(TPixel.CreatePixelOperations, true);
/// <summary>
/// Gets the global <see cref="PixelOperations{TPixel}"/> instance for the pixel type <typeparamref name="TPixel"/>

2
tests/ImageSharp.Tests/Color/RgbaDouble.cs

@ -104,7 +104,7 @@ public struct RgbaDouble : IPixel<RgbaDouble>
PixelAlphaRepresentation.Unassociated);
/// <inheritdoc />
public readonly PixelOperations<RgbaDouble> CreatePixelOperations() => new();
public static PixelOperations<RgbaDouble> CreatePixelOperations() => new();
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]

2
tests/ImageSharp.Tests/TestFormat.cs

@ -275,7 +275,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat
PixelColorType.Red | PixelColorType.Green,
PixelAlphaRepresentation.None);
public PixelOperations<TestPixelForAgnosticDecode> CreatePixelOperations() => new();
public static PixelOperations<TestPixelForAgnosticDecode> CreatePixelOperations() => new();
public static TestPixelForAgnosticDecode FromScaledVector4(Vector4 vector) => default;

Loading…
Cancel
Save