]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Fix a (harmless) Valgrind hit.
[movit] / effect_chain.cpp
index 6f53008c72eb43c0df26079d1ba8c1f95d9d57b0..c55ee26849617374010b879785b6fcfd5cd55b52 100644 (file)
@@ -13,6 +13,7 @@
 #include "gamma_compression_effect.h"
 #include "lift_gamma_gain_effect.h"
 #include "colorspace_conversion_effect.h"
+#include "sandbox_effect.h"
 #include "saturation_effect.h"
 #include "mirror_effect.h"
 #include "vignette_effect.h"
@@ -42,6 +43,8 @@ Effect *instantiate_effect(EffectId effect)
                return new GammaCompressionEffect();
        case EFFECT_COLOR_SPACE_CONVERSION:
                return new ColorSpaceConversionEffect();
+       case EFFECT_SANDBOX:
+               return new SandboxEffect();
        case EFFECT_LIFT_GAMMA_GAIN:
                return new LiftGammaGainEffect();
        case EFFECT_SATURATION:
@@ -220,8 +223,6 @@ void EffectChain::finalize()
                unsigned num_textures = std::max<int>(phases.size() - 1, 2);
                glGenTextures(num_textures, temp_textures);
 
-               unsigned char *empty = new unsigned char[width * height * 4];
-               memset(empty, 0, width * height * 4);
                for (unsigned i = 0; i < num_textures; ++i) {
                        glBindTexture(GL_TEXTURE_2D, temp_textures[i]);
                        check_error();
@@ -229,10 +230,9 @@ void EffectChain::finalize()
                        check_error();
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                        check_error();
-                       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, empty);
+                       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
                        check_error();
                }
-               delete[] empty;
        }
        
        // Translate the input format to OpenGL's enums.
@@ -306,6 +306,11 @@ void EffectChain::render_to_screen(unsigned char *src)
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        check_error();
+
+       // Intel/Mesa seems to have a broken glGenerateMipmap() for non-FBO textures, so do it here.
+       glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, phases[0].input_needs_mipmaps ? GL_TRUE : GL_FALSE);
+       check_error();
+
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
        check_error();
 
@@ -339,8 +344,11 @@ void EffectChain::render_to_screen(unsigned char *src)
                        check_error();
                }
                if (phases[phase].input_needs_mipmaps) {
-                       glGenerateMipmap(GL_TEXTURE_2D);
-                       check_error();
+                       if (phase != 0) {
+                               // For phase 0, it's done further up.
+                               glGenerateMipmap(GL_TEXTURE_2D);
+                               check_error();
+                       }
                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
                        check_error();
                } else {