2 #define _FLAT_INPUT_H 1
7 // A FlatInput is the normal, “classic” case of an input, where everything
8 // comes from a single 2D array with chunky pixels.
9 class FlatInput : public Input {
11 FlatInput(ImageFormat format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height);
14 virtual std::string effect_type_id() const { return "FlatInput"; }
16 // Create the texture itself. We cannot do this in the constructor,
17 // because we don't necessarily know all the settings (sRGB texture,
18 // mipmap generation) at that point.
21 virtual bool can_output_linear_gamma() const {
22 return (movit_srgb_textures_supported &&
23 type == GL_UNSIGNED_BYTE &&
24 (image_format.gamma_curve == GAMMA_LINEAR ||
25 image_format.gamma_curve == GAMMA_sRGB));
28 std::string output_fragment_shader();
30 // Uploads the texture if it has changed since last time.
31 void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num);
33 unsigned get_width() const { return width; }
34 unsigned get_height() const { return height; }
35 Colorspace get_color_space() const { return image_format.color_space; }
36 GammaCurve get_gamma_curve() const { return image_format.gamma_curve; }
38 // Tells the input where to fetch the actual pixel data. Note that if you change
39 // this data, you must either call set_pixel_data() again (using the same pointer
40 // is fine), or invalidate_pixel_data(). Otherwise, the texture won't be re-uploaded
41 // on subsequent frames.
42 void set_pixel_data(const unsigned char *pixel_data)
44 assert(this->type == GL_UNSIGNED_BYTE);
45 this->pixel_data = pixel_data;
46 invalidate_pixel_data();
49 void set_pixel_data(const float *pixel_data)
51 assert(this->type == GL_FLOAT);
52 this->pixel_data = pixel_data;
53 invalidate_pixel_data();
56 void invalidate_pixel_data()
61 void set_pitch(unsigned pitch) {
67 ImageFormat image_format;
68 MovitPixelFormat pixel_format;
70 GLuint pbo, texture_num;
71 bool needs_update, finalized;
72 int output_linear_gamma, needs_mipmaps;
73 unsigned width, height, pitch, bytes_per_pixel;
74 const void *pixel_data;
77 #endif // !defined(_FLAT_INPUT_H)