X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=flat_input_test.cpp;h=c8df483cee4fbcbce121c3ccaa69eac058136f47;hp=17ee9ce49f407abefc9206df05e1e69559f73c2f;hb=5c97329dd35909847e2120b0b368b2723ffe5a44;hpb=b16d7433b249c5381fa137d3ac3ef7867ae2eae4 diff --git a/flat_input_test.cpp b/flat_input_test.cpp index 17ee9ce..c8df483 100644 --- a/flat_input_test.cpp +++ b/flat_input_test.cpp @@ -1,8 +1,11 @@ // Unit tests for FlatInput. -#include "test_util.h" -#include "gtest/gtest.h" +#include + +#include "effect_chain.h" #include "flat_input.h" +#include "gtest/gtest.h" +#include "test_util.h" TEST(FlatInput, SimpleGrayscale) { const int size = 4; @@ -71,7 +74,38 @@ TEST(FlatInput, RGBA) { }; float out_data[4 * size]; - EffectChainTester tester(data, 1, size, FORMAT_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(data, 1, size, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR); + tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(expected_data, out_data, 4, size); +} + +// Note: The sRGB conversion itself is tested in EffectChainTester, +// since it also wants to test the chain building itself. +// Here, we merely test that alpha is left alone; the test will usually +// run using the sRGB OpenGL extension, but might be run with a +// GammaExpansionEffect if the card/driver happens not to support that. +TEST(FlatInput, AlphaIsNotModifiedBySRGBConversion) { + const int size = 5; + + unsigned char data[4 * size] = { + 0, 0, 0, 0, + 0, 0, 0, 63, + 0, 0, 0, 127, + 0, 0, 0, 191, + 0, 0, 0, 255, + }; + float expected_data[4 * size] = { + 0, 0, 0, 0.0 / 255.0, + 0, 0, 0, 63.0 / 255.0, + 0, 0, 0, 127.0 / 255.0, + 0, 0, 0, 191.0 / 255.0, + 0, 0, 0, 255.0 / 255.0, + }; + float out_data[4 * size]; + + EffectChainTester tester(NULL, 1, size); + tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB); tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); expect_equal(expected_data, out_data, 4, size); @@ -121,7 +155,7 @@ TEST(FlatInput, BGRA) { }; float out_data[4 * size]; - EffectChainTester tester(data, 1, size, FORMAT_BGRA, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(data, 1, size, FORMAT_BGRA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR); tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); expect_equal(expected_data, out_data, 4, size);