]> git.sesse.net Git - movit/blobdiff - lift_gamma_gain_effect_test.cpp
Add proper formats for sRGB without alpha.
[movit] / lift_gamma_gain_effect_test.cpp
index 0b63063347c582420a8710cf01ea3b4e0e92cdb7..1be2847a91ee3d0c5260333461462a5452f3494a 100644 (file)
@@ -1,11 +1,15 @@
 // Unit tests for LiftGammaGainEffect.
 
+#include <epoxy/gl.h>
+
 #include "effect_chain.h"
 #include "gtest/gtest.h"
 #include "image_format.h"
 #include "lift_gamma_gain_effect.h"
 #include "test_util.h"
 
+namespace movit {
+
 TEST(LiftGammaGainEffectTest, DefaultIsNoop) {
        float data[] = {
                0.0f, 0.0f, 0.0f, 1.0f,
@@ -94,3 +98,25 @@ TEST(LiftGammaGainEffectTest, Gamma22IsApproximatelysRGB) {
 
        expect_equal(data, out_data, 4, 5);
 }
+
+TEST(LiftGammaGainEffectTest, OutOfGamutColorsAreClipped) {
+       float data[] = {
+               -0.5f, 0.3f, 0.0f, 1.0f,
+                0.5f, 0.0f, 0.0f, 1.0f,
+                0.0f, 1.5f, 0.5f, 0.3f,
+       };
+       float expected_data[] = {
+                0.0f, 0.3f, 0.0f, 1.0f,  // Clipped to zero.
+                0.5f, 0.0f, 0.0f, 1.0f,
+                0.0f, 1.5f, 0.5f, 0.3f,
+       };
+
+       float out_data[3 * 4];
+       EffectChainTester tester(data, 1, 3, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR);
+       tester.get_chain()->add_effect(new LiftGammaGainEffect());
+       tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
+
+       expect_equal(expected_data, out_data, 4, 3);
+}
+
+}  // namespace movit