]> git.sesse.net Git - movit/blobdiff - input.h
Make Input an abstract base class, and move the current functionality into FlatInput...
[movit] / input.h
diff --git a/input.h b/input.h
index d41b2662b957ac7602e93907e0d0c8c02db3ba16..ac03e8490c280c1aa2f86b65c465ecd9087de592 100644 (file)
--- a/input.h
+++ b/input.h
@@ -7,61 +7,25 @@
 #include "image_format.h"
 
 // An input is a degenerate case of an effect; it represents the picture data
-// that comes from the user. As such, it has zero “inputs” itself, and some of
-// the normal operations don't really make sense for it.
+// that comes from the user. As such, it has zero “inputs” itself. Also, it
+// has an extra operation called finalize(), which runs when the effect chain
+// is finalized.
+//
+// An input is, like any other effect, required to be able to output a GLSL
+// fragment giving a RGBA value (although that GLSL fragment will have zero
+// inputs itself), and set the required OpenGL state on set_gl_state(),
+// including possibly uploading the texture if so required.
 class Input : public Effect {
 public:
-       Input(ImageFormat format, unsigned width, unsigned height);
-
-       unsigned num_inputs() const { return 0; }
+       virtual unsigned num_inputs() const { return 0; }
 
        // Create the texture itself. We cannot do this in the constructor,
        // because we don't necessarily know all the settings (sRGB texture,
        // mipmap generation) at that point.
-       void finalize();
-
-       std::string output_fragment_shader();
-
-       // Uploads the texture if it has changed since last time.
-       void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num);
-
-       // Tells the input where to fetch the actual pixel data. Note that if you change
-       // this data, you must either call set_pixel_data() again (using the same pointer
-       // is fine), or invalidate_pixel_data(). Otherwise, the texture won't be re-uploaded
-       // on subsequent frames.
-       void set_pixel_data(const unsigned char *pixel_data)
-       {
-               this->pixel_data = pixel_data;
-               invalidate_pixel_data();
-       }
-
-       void invalidate_pixel_data()
-       {
-               needs_update = true;
-       }
-
-       const unsigned char *get_pixel_data() const
-       {
-               return pixel_data;
-       }
-
-       void set_pitch(unsigned pitch) {
-               assert(!finalized);
-               this->pitch = pitch;
-       }
-
-       unsigned get_pitch() {
-               return pitch;
-       }
+       virtual void finalize() = 0;
 
-private:
-       ImageFormat image_format;
-       GLenum format;
-       GLuint pbo, texture_num;
-       bool needs_update, finalized;
-       int use_srgb_texture_format, needs_mipmaps;
-       unsigned width, height, pitch, bytes_per_pixel;
-       const unsigned char *pixel_data;
+       virtual ColorSpace get_color_space() = 0;       
+       virtual GammaCurve get_gamma_curve() = 0;       
 };
 
 #endif // !defined(_INPUT_H)