Add proper formats for sRGB without alpha.
[movit] / slice_effect.cpp
index 3cdd415..50504fe 100644 (file)
@@ -1,5 +1,6 @@
 #include <epoxy/gl.h>
 
+#include "effect_chain.h"
 #include "slice_effect.h"
 #include "effect_util.h"
 #include "util.h"
@@ -9,9 +10,14 @@ using namespace std;
 namespace movit {
 
 SliceEffect::SliceEffect()
+       : input_slice_size(1),
+         output_slice_size(1),
+         offset(0),
+         direction(VERTICAL)
 {
        register_int("input_slice_size", &input_slice_size);
        register_int("output_slice_size", &output_slice_size);
+       register_int("offset", &offset);
        register_int("direction", (int *)&direction);
 }
 
@@ -54,18 +60,18 @@ void SliceEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, un
                set_uniform_float(glsl_program_num, prefix, "output_coord_to_slice_num", float(output_width) / float(output_slice_size));
                set_uniform_float(glsl_program_num, prefix, "slice_num_to_input_coord", float(input_slice_size) / float(input_width));
                set_uniform_float(glsl_program_num, prefix, "slice_offset_to_input_coord", float(output_slice_size) / float(input_width));
+               set_uniform_float(glsl_program_num, prefix, "offset", float(offset) / float(input_width));
        } else {
                set_uniform_float(glsl_program_num, prefix, "output_coord_to_slice_num", float(output_height) / float(output_slice_size));
                set_uniform_float(glsl_program_num, prefix, "slice_num_to_input_coord", float(input_slice_size) / float(input_height));
                set_uniform_float(glsl_program_num, prefix, "slice_offset_to_input_coord", float(output_slice_size) / float(input_height));
+               set_uniform_float(glsl_program_num, prefix, "offset", float(offset) / float(input_height));
        }
 
-       // Normalized coordinates could potentially cause blurring of the
-       // image; it's not critical, but we have set changes_output_size()
-       // and needs_texture_bounce(), so simply turning off the interpolation
-       // is allowed.
-       assert(*sampler_num == 1);
-       glActiveTexture(GL_TEXTURE0);
+       // Normalized coordinates could potentially cause blurring of the image.
+       // It isn't critical, but still good practice.
+       Node *self = chain->find_node_for_effect(this);
+       glActiveTexture(chain->get_input_sampler(self, 0));
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        check_error();