]> git.sesse.net Git - movit/commitdiff
Merge remote-tracking branch 'origin/master'
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 22 Jan 2013 22:59:19 +0000 (23:59 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 22 Jan 2013 22:59:19 +0000 (23:59 +0100)
Makefile
deconvolution_sharpen_effect.h
demo.cpp
dither_effect_test.cpp
effect_chain_test.cpp
gtest_sdl_main.cpp
init.cpp
overlay_effect_test.cpp
padding_effect.cpp

index 8bfaf9fa6c5bac3796388c16cf3ed68d852ec3bb..cea223443588a324ef701b8d601dace68250d3af 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-GTEST_DIR = /usr/src/gtest
+GTEST_DIR ?= /usr/src/gtest
 
 EIGEN_CXXFLAGS := $(shell pkg-config --cflags eigen3)
 ifeq ($(EIGEN_CXXFLAGS),)
@@ -15,10 +15,20 @@ ifeq ($(GLEW_LIBS),)
 $(error Empty GLEW_LIBS. You probably need to install GLEW)
 endif
 
+SDL_CXXFLAGS := $(shell sdl-config --cflags)
+ifeq ($(SDL_CXXFLAGS),)
+$(error Empty SDL_CXXFLAGS. You probably need to install SDL)
+endif
+
+SDL_LIBS := $(shell sdl-config --libs)
+ifeq ($(SDL_LIBS),)
+$(error Empty SDL_LIBS. You probably need to install SDL)
+endif
+
 CC=gcc
 CXX=g++
 CXXFLAGS=-Wall -g -I$(GTEST_DIR)/include $(EIGEN_CXXFLAGS) $(GLEW_CXXFLAGS)
-LDFLAGS=-lSDL -lSDL_image -lGL -lrt -lpthread $(GLEW_LIBS)
+LDFLAGS=-lSDL -lSDL_image -lGL -lrt -lpthread -lpng $(GLEW_LIBS) $(SDL_LIBS)
 RANLIB=ranlib
 
 ifeq ($(COVERAGE),1)
index d0987f200b5c4e0284e3d295c3ee2d540f269d23..293916fd52da9433d7843ff9ca26c3526a8fdc06 100644 (file)
@@ -29,6 +29,9 @@ public:
        virtual std::string effect_type_id() const { return "DeconvolutionSharpenEffect"; }
        std::string output_fragment_shader();
 
+       // Samples a lot of times from its input.
+       virtual bool needs_texture_bounce() const { return true; }
+
        virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height)
        {
                this->width = width;
index 08b858d996070b725083a0d051e11618bfb9ed2f..6e5f18c58ef229578f2e673bc7723d67d7755d61 100644 (file)
--- a/demo.cpp
+++ b/demo.cpp
@@ -151,7 +151,7 @@ void write_png(const char *filename, unsigned char *screenbuf)
 
        png_init_io(png_ptr, fp);
        png_set_rows(png_ptr, info_ptr, row_pointers);
-       png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, png_voidp_NULL);
+       png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL);
        png_destroy_write_struct(&png_ptr, &info_ptr);
        fclose(fp);
 
@@ -162,7 +162,10 @@ int main(int argc, char **argv)
 {
        bool quit = false;
 
-       SDL_Init(SDL_INIT_EVERYTHING);
+       if (SDL_Init(SDL_INIT_EVERYTHING) == -1) {
+               fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
+               exit(1);
+       }
        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
index 81f6a2402d6d677e25c2e22727308ead45c491fd..bdba1212c76eaca680e3eabe6763cc6831c1b140 100644 (file)
@@ -50,5 +50,5 @@ TEST(DitherEffectTest, SinusoidBelowOneLevelComesThrough) {
                sum += 2.0 * (int(out_data[i]) - 0.2*255.0) * sin(i * frequency);
        }
 
-       EXPECT_NEAR(amplitude, sum / (size * 255.0f), 1e-5);
+       EXPECT_NEAR(amplitude, sum / (size * 255.0f), 1.1e-5);
 }
index 1b427a7dafbcffbecacbba007ec546341652f592..efe520f521492de013b0c221217616a063878938 100644 (file)
@@ -149,7 +149,7 @@ TEST(EffectChainTest, RewritingWorksAndTexturesAreAskedForsRGB) {
                1.0f, 0.9771f,
                0.8983f, 0.0f,
        };
-       float out_data[2];
+       float out_data[4];
        EffectChainTester tester(NULL, 2, 2);
        tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB);
        RewritingEffect<InvertEffect> *effect = new RewritingEffect<InvertEffect>();
@@ -344,7 +344,7 @@ TEST(EffectChainTest, IdentityThroughAlphaConversions) {
                0.0f, 0.2f, 0.2f, 0.3f,
                0.1f, 0.0f, 1.0f, 1.0f,
        };
-       float out_data[6];
+       float out_data[4 * size];
        EffectChainTester tester(data, size, 1, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR);
        tester.get_chain()->add_effect(new IdentityEffect());
        tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
index 21c923aa755a185e98ea5b9c817e024df750d223..fa3a835cda7f167e00b199535a68d28ae23ec0f2 100644 (file)
@@ -5,7 +5,10 @@
 
 int main(int argc, char **argv) {
        // Set up an OpenGL context using SDL.
-       SDL_Init(SDL_INIT_VIDEO);
+       if (SDL_Init(SDL_INIT_VIDEO) == -1) {
+               fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
+               exit(1);
+       }
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
index e0302d378a416421f97c8ceb158d52ad3f7d5d2d..b8b3cb4e884de457e57acc854b6ba0c593426df5 100644 (file)
--- a/init.cpp
+++ b/init.cpp
@@ -18,7 +18,7 @@ namespace {
 
 void measure_texel_subpixel_precision()
 {
-       static const unsigned width = 1024;
+       static const unsigned width = 4096;
 
        // Generate a destination texture to render to, and an FBO.
        GLuint dst_texnum, fbo;
index 865d392b73ea2b3db750e7132eb9ef53a5b061cb..d0867a13136e504a82bfa1a5dd3a0df9524186f1 100644 (file)
@@ -42,7 +42,7 @@ TEST(OverlayEffectTest, BottomDominatesTopWhenTopIsTransparent) {
        expect_equal(data_a, out_data, 4, 1);
 }
 
-TEST(OverlayEffectTest, ZeroAlphaBecomesAllZero) {
+TEST(OverlayEffectTest, ZeroAlphaRemainsZeroAlpha) {
        float data_a[] = {
                0.0f, 0.25f, 0.5f, 0.0f
        };
@@ -60,7 +60,7 @@ TEST(OverlayEffectTest, ZeroAlphaBecomesAllZero) {
        tester.get_chain()->add_effect(new OverlayEffect(), input1, input2);
        tester.run(out_data, GL_BGRA, COLORSPACE_sRGB, GAMMA_LINEAR);
 
-       expect_equal(expected_data, out_data, 4, 1);
+       EXPECT_FLOAT_EQ(0.0f, expected_data[3]);
 }
 
 // This is tested against what Photoshop does: (255,0,128, 0.25) over (128,255,0, 0.5)
index 9d6e292996f33aca18062597de166766d90a9550..2e428c4556d25bbec390fca0ad9a220e7362b86e 100644 (file)
@@ -46,14 +46,14 @@ void PaddingEffect::set_gl_state(GLuint glsl_program_num, const std::string &pre
        // than losing a pixel in the common cases of integer shift.
        // Thus the 1e-3 fudge factors.
        float texcoord_min[2] = {
-               (0.5f - 1e-3) / input_width,
-               (0.5f - 1e-3) / input_height
+               float((0.5f - 1e-3) / input_width),
+               float((0.5f - 1e-3) / input_height)
        };
        set_uniform_vec2(glsl_program_num, prefix, "texcoord_min", texcoord_min);
 
        float texcoord_max[2] = {
-               1.0f - (0.5f - 1e-3) / input_width,
-               1.0f - (0.5f - 1e-3) / input_height
+               float(1.0f - (0.5f - 1e-3) / input_width),
+               float(1.0f - (0.5f - 1e-3) / input_height)
        };
        set_uniform_vec2(glsl_program_num, prefix, "texcoord_max", texcoord_max);
 }