X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gamma_expansion_effect_test.cpp;h=71544b4738c1a92caa827d1d5c7e90d3a7941ca3;hp=b315d8f9c6fc05d2ca2a0bd2a875b9d23ecc8797;hb=caa05550e868db406e4b54e69d60b5573f59cb60;hpb=e8b8c6c9dbb4c5c68b70f43f45764e8dac404bff diff --git a/gamma_expansion_effect_test.cpp b/gamma_expansion_effect_test.cpp index b315d8f..71544b4 100644 --- a/gamma_expansion_effect_test.cpp +++ b/gamma_expansion_effect_test.cpp @@ -14,8 +14,8 @@ TEST(GammaExpansionEffectTest, sRGB_KeyValues) { 0.00309f, 0.00317f, }; float out_data[4]; - EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_sRGB); - tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB); + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR); expect_equal(expected_data, out_data, 2, 2); } @@ -25,8 +25,8 @@ TEST(GammaExpansionEffectTest, sRGB_RampAlwaysIncreases) { for (unsigned i = 0; i < 256; ++i) { data[i] = i / 255.0f; } - EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_sRGB); - tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB); + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR); for (unsigned i = 1; i < 256; ++i) { EXPECT_GT(out_data[i], out_data[i - 1]) @@ -34,6 +34,21 @@ TEST(GammaExpansionEffectTest, sRGB_RampAlwaysIncreases) { } } +TEST(GammaExpansionEffectTest, sRGB_AlphaIsUnchanged) { + float data[] = { + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.25f, + 0.0f, 0.0f, 0.0f, 0.5f, + 0.0f, 0.0f, 0.0f, 0.75f, + 0.0f, 0.0f, 0.0f, 1.0f, + }; + float out_data[5 * 4]; + EffectChainTester tester(data, 5, 1, FORMAT_RGBA, COLORSPACE_sRGB, GAMMA_sRGB); + tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(data, out_data, 5, 1); +} + TEST(GammaExpansionEffectTest, Rec709_KeyValues) { float data[] = { 0.0f, 1.0f, @@ -44,8 +59,8 @@ TEST(GammaExpansionEffectTest, Rec709_KeyValues) { 0.017778f, 0.018167f, }; float out_data[4]; - EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_REC_709); - tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709); + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR); expect_equal(expected_data, out_data, 2, 2); } @@ -55,11 +70,26 @@ TEST(GammaExpansionEffectTest, Rec709_RampAlwaysIncreases) { for (unsigned i = 0; i < 256; ++i) { data[i] = i / 255.0f; } - EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_REC_709); - tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709); + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR); for (unsigned i = 1; i < 256; ++i) { EXPECT_GT(out_data[i], out_data[i - 1]) << "No increase between " << i-1 << " and " << i; } } + +TEST(GammaExpansionEffectTest, Rec709_AlphaIsUnchanged) { + float data[] = { + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.25f, + 0.0f, 0.0f, 0.0f, 0.5f, + 0.0f, 0.0f, 0.0f, 0.75f, + 0.0f, 0.0f, 0.0f, 1.0f, + }; + float out_data[5 * 4]; + EffectChainTester tester(data, 5, 1, FORMAT_RGBA, COLORSPACE_sRGB, GAMMA_REC_709); + tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(data, out_data, 5, 1); +}