1 // Unit tests for GammaExpansionEffect.
4 #include "gtest/gtest.h"
5 #include "gamma_expansion_effect.h"
7 TEST(GammaExpansionEffectTest, sRGB_KeyValues) {
10 0.040f, 0.041f, // On either side of the discontinuity.
12 float expected_data[] = {
17 EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
18 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
20 expect_equal(expected_data, out_data, 2, 2);
23 TEST(GammaExpansionEffectTest, sRGB_RampAlwaysIncreases) {
24 float data[256], out_data[256];
25 for (unsigned i = 0; i < 256; ++i) {
28 EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
29 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
31 for (unsigned i = 1; i < 256; ++i) {
32 EXPECT_GT(out_data[i], out_data[i - 1])
33 << "No increase between " << i-1 << " and " << i;
37 TEST(GammaExpansionEffectTest, Rec709_KeyValues) {
40 0.080f, 0.082f, // On either side of the discontinuity.
42 float expected_data[] = {
47 EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709);
48 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
50 expect_equal(expected_data, out_data, 2, 2);
53 TEST(GammaExpansionEffectTest, Rec709_RampAlwaysIncreases) {
54 float data[256], out_data[256];
55 for (unsigned i = 0; i < 256; ++i) {
58 EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709);
59 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
61 for (unsigned i = 1; i < 256; ++i) {
62 EXPECT_GT(out_data[i], out_data[i - 1])
63 << "No increase between " << i-1 << " and " << i;