1 #ifndef _TWEAKED_INPUTS_H
2 #define _TWEAKED_INPUTS_H 1
4 // Some tweaked variations of Movit inputs.
9 #include <movit/image_format.h>
10 #include <movit/flat_input.h>
11 #include <movit/ycbcr_input.h>
18 class NonBouncingYCbCrInput : public movit::YCbCrInput {
20 NonBouncingYCbCrInput(const movit::ImageFormat &image_format,
21 const movit::YCbCrFormat &ycbcr_format,
22 unsigned width, unsigned height,
23 movit::YCbCrInputSplitting ycbcr_input_splitting = movit::YCBCR_INPUT_PLANAR)
24 : movit::YCbCrInput(image_format, ycbcr_format, width, height, ycbcr_input_splitting) {}
26 bool override_disable_bounce() const override { return true; }
29 // We use FlatInput with RGBA inputs a few places where we can't tell when
30 // uploading the texture whether it needs to be converted from sRGB to linear
31 // or not. (FlatInput deals with this if you give it pixels, but we give it
32 // already uploaded textures.)
34 // Since we require GL_EXT_texture_sRGB_decode (very common, as far as I can tell),
35 // we can just always upload with the sRGB flag turned on (upload your texture with
36 // GL_SRGB8_ALPHA8), and then sRGBSwitchingFlatInput will turn it off if not requested.
38 class sRGBSwitchingFlatInput : public movit::FlatInput {
40 sRGBSwitchingFlatInput(movit::ImageFormat format, movit::MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
41 : movit::FlatInput(format, pixel_format, type, width, height) {}
43 ~sRGBSwitchingFlatInput();
44 void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override;
45 void clear_gl_state() override;
47 bool set_int(const std::string &key, int value) override
49 if (key == "output_linear_gamma") {
50 output_linear_gamma = value;
52 if (key == "needs_mipmaps") {
53 needs_mipmaps = value;
55 return movit::FlatInput::set_int(key, value);
59 bool output_linear_gamma = false;
60 bool needs_mipmaps = false;
61 GLuint sampler_obj = 0;
65 #endif // !defined(_TWEAKED_INPUTS_H)