1 #ifndef _TWEAKED_INPUTS_H
2 #define _TWEAKED_INPUTS_H 1
4 // Some tweaked variations of Movit inputs.
6 #include <movit/ycbcr_input.h>
13 class NonBouncingYCbCrInput : public movit::YCbCrInput {
15 NonBouncingYCbCrInput(const movit::ImageFormat &image_format,
16 const movit::YCbCrFormat &ycbcr_format,
17 unsigned width, unsigned height,
18 movit::YCbCrInputSplitting ycbcr_input_splitting = movit::YCBCR_INPUT_PLANAR)
19 : movit::YCbCrInput(image_format, ycbcr_format, width, height, ycbcr_input_splitting) {}
21 bool override_disable_bounce() const override { return true; }
24 // We use FlatInput with RGBA inputs a few places where we can't tell when
25 // uploading the texture whether it needs to be converted from sRGB to linear
26 // or not. (FlatInput deals with this if you give it pixels, but we give it
27 // already uploaded textures.)
29 // If we have GL_EXT_texture_sRGB_decode (very common, as far as I can tell),
30 // we can just always upload with the sRGB flag turned on, and then turn it off
31 // if not requested; that's sRGBSwitchingFlatInput. If not, we just need to
32 // turn off the functionality altogether, which is NonsRGBCapableFlatInput.
34 // If you're using NonsRGBCapableFlatInput, upload with GL_RGBA8.
35 // If using sRGBSwitchingFlatInput, upload with GL_SRGB8_ALPHA8.
37 class NonsRGBCapableFlatInput : public movit::FlatInput {
39 NonsRGBCapableFlatInput(movit::ImageFormat format, movit::MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
40 : movit::FlatInput(format, pixel_format, type, width, height) {}
42 bool can_output_linear_gamma() const override { return false; }
45 class sRGBSwitchingFlatInput : public movit::FlatInput {
47 sRGBSwitchingFlatInput(movit::ImageFormat format, movit::MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
48 : movit::FlatInput(format, pixel_format, type, width, height) {}
50 ~sRGBSwitchingFlatInput();
51 void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override;
52 void clear_gl_state() override;
54 bool set_int(const std::string &key, int value) override
56 if (key == "output_linear_gamma") {
57 output_linear_gamma = value;
59 if (key == "needs_mipmaps") {
60 needs_mipmaps = value;
62 return movit::FlatInput::set_int(key, value);
66 bool output_linear_gamma = false;
67 bool needs_mipmaps = false;
68 GLuint sampler_obj = 0;
73 #endif // !defined(_TWEAKED_INPUTS_H)