From b1eb8fac002d248680fa70e23582c691ad74414f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 18 Nov 2020 23:32:51 +0000 Subject: [PATCH] Move property to base. --- ...elOperationsTests.Specialized.Generated.cs | 56 ------------------- .../Generated/_Common.ttinclude | 2 - .../PixelOperations/PixelOperationsTests.cs | 15 ++--- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs index 9d6ec89606..1069eb9aca 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs @@ -18,8 +18,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public A8_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = A8.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => A8.PixelOperations.Instance; @@ -40,8 +38,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Argb32_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Argb32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Argb32.PixelOperations.Instance; @@ -62,8 +58,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Bgr24_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Bgr24.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Bgr24.PixelOperations.Instance; @@ -84,8 +78,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Bgr565_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Bgr565.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Bgr565.PixelOperations.Instance; @@ -106,8 +98,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Bgra32_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Bgra32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Bgra32.PixelOperations.Instance; @@ -128,8 +118,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Bgra4444_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Bgra4444.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Bgra4444.PixelOperations.Instance; @@ -150,8 +138,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Bgra5551_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Bgra5551.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Bgra5551.PixelOperations.Instance; @@ -172,8 +158,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Byte4_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Byte4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Byte4.PixelOperations.Instance; @@ -194,8 +178,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public HalfSingle_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = HalfSingle.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => HalfSingle.PixelOperations.Instance; @@ -216,8 +198,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public HalfVector2_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = HalfVector2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => HalfVector2.PixelOperations.Instance; @@ -238,8 +218,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public HalfVector4_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = HalfVector4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => HalfVector4.PixelOperations.Instance; @@ -260,8 +238,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public L16_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = L16.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => L16.PixelOperations.Instance; @@ -282,8 +258,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public L8_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = L8.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => L8.PixelOperations.Instance; @@ -304,8 +278,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public La16_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = La16.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => La16.PixelOperations.Instance; @@ -326,8 +298,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public La32_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = La32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => La32.PixelOperations.Instance; @@ -348,8 +318,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public NormalizedByte2_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = NormalizedByte2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => NormalizedByte2.PixelOperations.Instance; @@ -370,8 +338,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public NormalizedByte4_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = NormalizedByte4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => NormalizedByte4.PixelOperations.Instance; @@ -392,8 +358,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public NormalizedShort2_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = NormalizedShort2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => NormalizedShort2.PixelOperations.Instance; @@ -414,8 +378,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public NormalizedShort4_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = NormalizedShort4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => NormalizedShort4.PixelOperations.Instance; @@ -436,8 +398,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Rg32_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Rg32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Rg32.PixelOperations.Instance; @@ -458,8 +418,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Rgb24_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Rgb24.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Rgb24.PixelOperations.Instance; @@ -480,8 +438,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Rgb48_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Rgb48.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Rgb48.PixelOperations.Instance; @@ -502,8 +458,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Rgba1010102_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Rgba1010102.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Rgba1010102.PixelOperations.Instance; @@ -524,8 +478,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Rgba32_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Rgba32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Rgba32.PixelOperations.Instance; @@ -546,8 +498,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Rgba64_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Rgba64.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Rgba64.PixelOperations.Instance; @@ -568,8 +518,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public RgbaVector_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = RgbaVector.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => RgbaVector.PixelOperations.Instance; @@ -590,8 +538,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Short2_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Short2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Short2.PixelOperations.Instance; @@ -612,8 +558,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations public Short4_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = Short4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations Operations => Short4.PixelOperations.Instance; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude index 50026b3f86..8c436eecca 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude @@ -74,8 +74,6 @@ using Xunit.Abstractions; public <#=pixelType#>_OperationsTests(ITestOutputHelper output) : base(output) { - var alphaRepresentation = <#=pixelType#>.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation; - this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated; } protected override PixelOperations<<#=pixelType#>> Operations => <#=pixelType#>.PixelOperations.Instance; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 543184e34b..059a218031 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -36,8 +36,6 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations null; #endif - protected bool HasUnassociatedAlpha { get; set; } = true; - protected PixelOperationsTests(ITestOutputHelper output) : base(output) { @@ -73,7 +71,9 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations protected Configuration Configuration => Configuration.Default; - protected virtual PixelOperations Operations => PixelOperations.Instance; + protected virtual PixelOperations Operations { get; } = PixelOperations.Instance; + + protected bool HasUnassociatedAlpha => this.Operations.GetPixelTypeInfo().AlphaRepresentation == PixelAlphaRepresentation.Unassociated; internal static TPixel[] CreateExpectedPixelData(Vector4[] source, RefAction vectorModifier = null) { @@ -217,8 +217,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations expected, (s, d) => { - PixelConversionModifiers modifiers = this.HasUnassociatedAlpha - ? PixelConversionModifiers.Premultiply + PixelConversionModifiers modifiers = this.HasUnassociatedAlpha ? PixelConversionModifiers.Premultiply : PixelConversionModifiers.None; this.Operations.FromVector4Destructive(this.Configuration, s, d.GetSpan(), modifiers); @@ -253,8 +252,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations expected, (s, d) => { - PixelConversionModifiers modifiers = this.HasUnassociatedAlpha - ? PixelConversionModifiers.Premultiply + PixelConversionModifiers modifiers = this.HasUnassociatedAlpha ? PixelConversionModifiers.Premultiply : PixelConversionModifiers.None; this.Operations.FromVector4Destructive( @@ -297,8 +295,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations expected, (s, d) => { - PixelConversionModifiers modifiers = this.HasUnassociatedAlpha - ? PixelConversionModifiers.Premultiply + PixelConversionModifiers modifiers = this.HasUnassociatedAlpha ? PixelConversionModifiers.Premultiply : PixelConversionModifiers.None; this.Operations.FromVector4Destructive(