]> git.sesse.net Git - movit/blobdiff - padding_effect.cpp
Fix a small overallocation.
[movit] / padding_effect.cpp
index f8d30d480886aa364d103f90e3d38b1899e0f32d..15381a32567e7bdd6ffed157c8aea6b52cdf4aff 100644 (file)
@@ -1,9 +1,14 @@
-#include <math.h>
 #include <GL/glew.h>
+#include <assert.h>
 
+#include "effect_util.h"
 #include "padding_effect.h"
 #include "util.h"
 
+using namespace std;
+
+namespace movit {
+
 PaddingEffect::PaddingEffect()
        : border_color(0.0f, 0.0f, 0.0f, 0.0f),
          output_width(1280),
@@ -18,12 +23,12 @@ PaddingEffect::PaddingEffect()
        register_float("left", &left);
 }
 
-std::string PaddingEffect::output_fragment_shader()
+string PaddingEffect::output_fragment_shader()
 {
        return read_file("padding_effect.frag");
 }
 
-void PaddingEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num)
+void PaddingEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
 {
        Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
 
@@ -63,12 +68,16 @@ void PaddingEffect::set_gl_state(GLuint glsl_program_num, const std::string &pre
 // differently in different modes.
 
 // 0.0 and 1.0 are interpreted the same, no matter the gamma ramp.
-// Alpha is not affected by gamma.
+// Alpha is not affected by gamma per se, but the combination of
+// premultiplied alpha and non-linear gamma curve does not make sense,
+// so if could possibly be converting blank alpha to non-blank
+// (ie., premultiplied), we need our output to be in linear light.
 bool PaddingEffect::needs_linear_light() const
 {
        if ((border_color.r == 0.0 || border_color.r == 1.0) &&
            (border_color.g == 0.0 || border_color.g == 1.0) &&
-           (border_color.b == 0.0 || border_color.b == 1.0)) {
+           (border_color.b == 0.0 || border_color.b == 1.0) &&
+           border_color.a == 1.0) {
                return false;
        }
        return true;
@@ -123,3 +132,5 @@ void PaddingEffect::inform_input_size(unsigned input_num, unsigned width, unsign
        input_width = width;
        input_height = height;
 }
+
+}  // namespace movit