X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=input.h;h=8687690aa1386bb13776962ec987d48b26d14248;hp=b3eb836a26a8f9d4e1754ddc3574e866763dce2a;hb=3d1f6c11c53cd9d3d5c1fb60f4accf050b7f135e;hpb=6a31570f6a85004d33a83bbe2f77642614361da6 diff --git a/input.h b/input.h index b3eb836..8687690 100644 --- a/input.h +++ b/input.h @@ -1,56 +1,36 @@ #ifndef _INPUT_H #define _INPUT_H 1 +#include + #include "effect.h" #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; - } + virtual void finalize() = 0; - const unsigned char *get_pixel_data() const - { - return pixel_data; - } + // Whether this input can deliver linear gamma directly if it's + // asked to. (If so, set the parameter “output_linear_gamma” + // to activate it.) + virtual bool can_output_linear_gamma() const = 0; -private: - ImageFormat image_format; - GLenum format; - GLuint pbo, texture_num; - bool needs_update; - int use_srgb_texture_format, needs_mipmaps; - unsigned width, height, bytes_per_pixel; - const unsigned char *pixel_data; + virtual ColorSpace get_color_space() const = 0; + virtual GammaCurve get_gamma_curve() const = 0; }; #endif // !defined(_INPUT_H)