]> git.sesse.net Git - movit/commitdiff
Merge branch 'master' into epoxy
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 11 Mar 2014 23:07:32 +0000 (00:07 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 11 Mar 2014 23:08:04 +0000 (00:08 +0100)
1  2 
Makefile.in
effect_chain.h
luma_mix_effect_test.cpp

diff --combined Makefile.in
index 13fbadcb29573afe59af09f68abb943a06050488,f88fd5ad05a8c0fa309d91a9738d100b93b10771..0c2e9eed6f9f6bfa31c42b53f81440486c4fe81c
@@@ -8,16 -8,12 +8,16 @@@ datarootdir = @datarootdir
  datadir = @datadir@
  top_builddir = @top_builddir@
  with_demo_app = @with_demo_app@
 +with_SDL2 = @with_SDL2@
  
  CC=@CC@
  CXX=@CXX@
 -CXXFLAGS=-Wall @CXXFLAGS@ -I$(GTEST_DIR)/include @Eigen3_CFLAGS@ @GLEW_CFLAGS@
 -LDFLAGS=@GLEW_LIBS@ @SDL_LIBS@ -lpthread
 -DEMO_LDLIBS=@SDL_image_LIBS@ -lrt -lpthread @libpng_LIBS@
 +CXXFLAGS=-Wall @CXXFLAGS@ -I$(GTEST_DIR)/include @SDL2_CFLAGS@ @SDL_CFLAGS@ @Eigen3_CFLAGS@ @epoxy_CFLAGS@
 +ifeq ($(with_SDL2),yes)
 +CXXFLAGS += -DHAVE_SDL2
 +endif
 +LDFLAGS=@epoxy_LIBS@ @SDL2_LIBS@ @SDL_LIBS@ -lpthread
 +DEMO_LDLIBS=@SDL2_image_LIBS@ @SDL_image_LIBS@ -lrt -lpthread @libpng_LIBS@
  SHELL=@SHELL@
  LIBTOOL=@LIBTOOL@ --tag=CXX
  RANLIB=ranlib
@@@ -61,6 -57,7 +61,7 @@@ TESTED_EFFECTS += fft_pass_effec
  TESTED_EFFECTS += vignette_effect
  TESTED_EFFECTS += slice_effect
  TESTED_EFFECTS += complex_modulate_effect
+ TESTED_EFFECTS += luma_mix_effect
  
  UNTESTED_EFFECTS = sandbox_effect
  UNTESTED_EFFECTS += mirror_effect
diff --combined effect_chain.h
index 549fa603027c3476c9ce8fb9ab6dcae522400a02,cbc1221020bbfa0063767da30275ee7e45662891..02906fe0b9885b0263db412a16b3b4d0fd540031
@@@ -17,7 -17,7 +17,7 @@@
  // the EffectChain holds textures and other OpenGL objects that are tied to the
  // context.
  
 -#include <GL/glew.h>
 +#include <epoxy/gl.h>
  #include <stdio.h>
  #include <map>
  #include <set>
@@@ -139,6 -139,13 +139,13 @@@ public
                inputs.push_back(input2);
                return add_effect(effect, inputs);
        }
+       Effect *add_effect(Effect *effect, Effect *input1, Effect *input2, Effect *input3) {
+               std::vector<Effect *> inputs;
+               inputs.push_back(input1);
+               inputs.push_back(input2);
+               inputs.push_back(input3);
+               return add_effect(effect, inputs);
+       }
        Effect *add_effect(Effect *effect, const std::vector<Effect *> &inputs);
  
        void add_output(const ImageFormat &format, OutputAlphaFormat alpha_format);
diff --combined luma_mix_effect_test.cpp
index 0000000000000000000000000000000000000000,618b73388bfc3d3c46ec2cefba7b0f3803d7488e..4a506f5aaf4942d631aba27c4b18d99f3089d16f
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,99 +1,99 @@@
 -#include <GL/glew.h>
+ // Unit tests for LumaMixEffect.
++#include <epoxy/gl.h>
+ #include "effect_chain.h"
+ #include "gtest/gtest.h"
+ #include "image_format.h"
+ #include "input.h"
+ #include "luma_mix_effect.h"
+ #include "test_util.h"
+ namespace movit {
+ TEST(LumaMixEffectTest, HardWipe) {
+       float data_a[] = {
+               0.0f, 0.25f,
+               0.75f, 1.0f,
+       };
+       float data_b[] = {
+               1.0f, 0.5f,
+               0.65f, 0.6f,
+       };
+       float data_luma[] = {
+               0.0f, 0.25f,
+               0.5f, 0.75f,
+       };
+       EffectChainTester tester(data_a, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *input1 = tester.get_chain()->last_added_effect();
+       Effect *input2 = tester.add_input(data_b, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *input3 = tester.add_input(data_luma, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *luma_mix_effect = tester.get_chain()->add_effect(new LumaMixEffect(), input1, input2, input3);
+       ASSERT_TRUE(luma_mix_effect->set_float("transition_width", 100000.0f));
+       float out_data[4];
+       ASSERT_TRUE(luma_mix_effect->set_float("progress", 0.0f));
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+       expect_equal(data_a, out_data, 2, 2);
+       // Lower right from B, the rest from A.
+       float expected_data_049[] = {
+               0.0f, 0.25f,
+               0.75f, 0.6f,
+       };
+       ASSERT_TRUE(luma_mix_effect->set_float("progress", 0.49f));
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+       expect_equal(expected_data_049, out_data, 2, 2);
+       // Lower two from B, the rest from A.
+       float expected_data_051[] = {
+               0.0f, 0.25f,
+               0.65f, 0.6f,
+       };
+       ASSERT_TRUE(luma_mix_effect->set_float("progress", 0.51f));
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+       expect_equal(expected_data_051, out_data, 2, 2);
+       ASSERT_TRUE(luma_mix_effect->set_float("progress", 1.0f));
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+       expect_equal(data_b, out_data, 2, 2);
+ }
+ TEST(LumaMixEffectTest, SoftWipeHalfWayThrough) {
+       float data_a[] = {
+               0.0f, 0.25f,
+               0.75f, 1.0f,
+       };
+       float data_b[] = {
+               1.0f, 0.5f,
+               0.65f, 0.6f,
+       };
+       float data_luma[] = {
+               0.0f, 0.25f,
+               0.5f, 0.75f,
+       };
+       // At this point, the luma range and the mix range should exactly line up,
+       // so we get a straight-up fade by luma.
+       float expected_data[] = {
+               data_a[0] + (data_b[0] - data_a[0]) * data_luma[0],
+               data_a[1] + (data_b[1] - data_a[1]) * data_luma[1],
+               data_a[2] + (data_b[2] - data_a[2]) * data_luma[2],
+               data_a[3] + (data_b[3] - data_a[3]) * data_luma[3],
+       };
+       float out_data[4];
+       EffectChainTester tester(data_a, 2, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *input1 = tester.get_chain()->last_added_effect();
+       Effect *input2 = tester.add_input(data_b, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *input3 = tester.add_input(data_luma, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR);
+       Effect *luma_mix_effect = tester.get_chain()->add_effect(new LumaMixEffect(), input1, input2, input3);
+       ASSERT_TRUE(luma_mix_effect->set_float("transition_width", 1.0f));
+       ASSERT_TRUE(luma_mix_effect->set_float("progress", 0.5f));
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+       expect_equal(expected_data, out_data, 2, 2);
+ }
+ }  // namespace movit