diff --git a/src/ImageSharp/PixelFormats/IPixel.cs b/src/ImageSharp/PixelFormats/IPixel.cs index 23b18354a..adf386614 100644 --- a/src/ImageSharp/PixelFormats/IPixel.cs +++ b/src/ImageSharp/PixelFormats/IPixel.cs @@ -14,14 +14,14 @@ namespace SixLabors.ImageSharp.PixelFormats; public interface IPixel : IPixel, IEquatable where TSelf : unmanaged, IPixel { +#pragma warning disable CA1000 // Do not declare static members on generic types /// /// Creates a instance for this pixel type. /// This method is not intended to be consumed directly. Use instead. /// /// The instance. - PixelOperations CreatePixelOperations(); + static abstract PixelOperations CreatePixelOperations(); -#pragma warning disable CA1000 // Do not declare static members on generic types /// /// Initializes the pixel instance from a generic scaled . /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs index fdf7ccb40..94fbf7eb7 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs @@ -75,7 +75,7 @@ public partial struct A8 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs index 65354c807..453a39228 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs @@ -192,7 +192,7 @@ public partial struct Abgr32 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs index 50557880a..f8608ecc5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs @@ -185,7 +185,7 @@ public partial struct Argb32 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs index 12e6736b7..a860edc56 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs @@ -95,7 +95,7 @@ public partial struct Bgr24 : IPixel PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs index fe26bb8fd..87055bf22 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs @@ -73,7 +73,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVector - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// public readonly Rgba32 ToRgba32() => Rgba32.FromScaledVector4(this.ToScaledVector4()); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs index fc5d55e64..0fe7e4cc2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs @@ -134,7 +134,7 @@ public partial struct Bgra32 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs index 4c89d8e94..55971210c 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs @@ -86,7 +86,7 @@ public partial struct Bgra4444 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs index fde937fb5..4c94dea5f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs @@ -84,7 +84,7 @@ public partial struct Bgra5551 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs index 8b4384ff7..680a7ee0b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs @@ -86,7 +86,7 @@ public partial struct Byte4 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 45cc061ae..888d992d8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs @@ -70,7 +70,7 @@ public partial struct HalfSingle : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs index 1fd312523..861a8480a 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs @@ -82,7 +82,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs index 4741bcf9e..d0b57d788 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs @@ -87,7 +87,7 @@ public partial struct HalfVector4 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index 41578a6f6..2b5241b0b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -75,7 +75,7 @@ public partial struct L16 : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index 90731f6e9..5d733bdbb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -77,7 +77,7 @@ public partial struct L8 : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index 948f0b144..69ca66218 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -104,7 +104,7 @@ public partial struct La16 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index 0381973d9..1886ef39a 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -101,7 +101,7 @@ public partial struct La32 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index e901adc9e..9551d7242 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -85,7 +85,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs index 1202801ab..1fb386725 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs @@ -92,7 +92,7 @@ public partial struct NormalizedByte4 : IPixel, IPackedVector - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index e15cdafa7..a17868f6d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -87,7 +87,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs index f692f73b2..2b33fec27 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs @@ -93,7 +93,7 @@ public partial struct NormalizedShort4 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs index 0dea02512..e7c97269e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs @@ -82,7 +82,7 @@ public partial struct Rg32 : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index a4445bd71..ac855d47d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -104,7 +104,7 @@ public partial struct Rgb24 : IPixel PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs index d4f1cabb2..e822d2abc 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs @@ -89,7 +89,7 @@ public partial struct Rgb48 : IPixel PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs index 0f7be1774..cdee22964 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs @@ -84,7 +84,7 @@ public partial struct Rgba1010102 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 8b5779a53..fc347c166 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -288,7 +288,7 @@ public partial struct Rgba32 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs index 73629461b..27c4752e1 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs @@ -210,7 +210,7 @@ public partial struct Rgba64 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs index 60555ad95..a27cffad8 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs @@ -104,7 +104,7 @@ public partial struct RgbaVector : IPixel PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 043599c36..403d3fbea 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -90,7 +90,7 @@ public partial struct Short2 : IPixel, IPackedVector PixelAlphaRepresentation.None); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs index df43703cb..b6cece2be 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs @@ -97,7 +97,7 @@ public partial struct Short4 : IPixel, IPackedVector PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new PixelOperations(); + public static PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index 174b3fae1..c769b389d 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.PixelFormats; public partial class PixelOperations where TPixel : unmanaged, IPixel { - private static readonly Lazy> LazyInstance = new(() => default(TPixel).CreatePixelOperations(), true); + private static readonly Lazy> LazyInstance = new(TPixel.CreatePixelOperations, true); /// /// Gets the global instance for the pixel type diff --git a/tests/ImageSharp.Tests/Color/RgbaDouble.cs b/tests/ImageSharp.Tests/Color/RgbaDouble.cs index bb8672941..9a751e879 100644 --- a/tests/ImageSharp.Tests/Color/RgbaDouble.cs +++ b/tests/ImageSharp.Tests/Color/RgbaDouble.cs @@ -104,7 +104,7 @@ public struct RgbaDouble : IPixel PixelAlphaRepresentation.Unassociated); /// - public readonly PixelOperations CreatePixelOperations() => new(); + public static PixelOperations CreatePixelOperations() => new(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index 89e2a11a9..10211f386 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -275,7 +275,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat PixelColorType.Red | PixelColorType.Green, PixelAlphaRepresentation.None); - public PixelOperations CreatePixelOperations() => new(); + public static PixelOperations CreatePixelOperations() => new(); public static TestPixelForAgnosticDecode FromScaledVector4(Vector4 vector) => default;