1 // Unit tests for GammaCompressionEffect.
3 // Pretty much the inverse of the GammaExpansionEffect tests;
4 // EffectChainTest tests that they are actually inverses.
7 #include "gtest/gtest.h"
8 #include "gamma_expansion_effect.h"
10 TEST(GammaCompressionEffectTest, sRGB_KeyValues) {
13 0.00309f, 0.00317f, // On either side of the discontinuity.
15 float expected_data[] = {
20 EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
21 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
23 expect_equal(expected_data, out_data, 2, 2);
26 TEST(GammaCompressionEffectTest, sRGB_RampAlwaysIncreases) {
27 float data[256], out_data[256];
28 for (unsigned i = 0; i < 256; ++i) {
31 EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
32 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
34 for (unsigned i = 1; i < 256; ++i) {
35 EXPECT_GT(out_data[i], out_data[i - 1])
36 << "No increase between " << i-1 << " and " << i;
40 TEST(GammaCompressionEffectTest, Rec709_KeyValues) {
43 0.017778f, 0.018167f, // On either side of the discontinuity.
45 float expected_data[] = {
50 EffectChainTester tester(data, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
51 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_REC_709);
53 expect_equal(expected_data, out_data, 2, 2);
56 TEST(GammaCompressionEffectTest, Rec709_RampAlwaysIncreases) {
57 float data[256], out_data[256];
58 for (unsigned i = 0; i < 256; ++i) {
61 EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
62 tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_REC_709);
64 for (unsigned i = 1; i < 256; ++i) {
65 EXPECT_GT(out_data[i], out_data[i - 1])
66 << "No increase between " << i-1 << " and " << i;