]> git.sesse.net Git - nageru/blob - nageru/tweaked_inputs.h
Fix a comment typo.
[nageru] / nageru / tweaked_inputs.h
1 #ifndef _TWEAKED_INPUTS_H
2 #define _TWEAKED_INPUTS_H 1
3
4 // Some tweaked variations of Movit inputs.
5
6 #include <movit/flat_input.h>
7 #include <movit/ycbcr_input.h>
8
9 namespace movit {
10 struct ImageFormat;
11 struct YCbCrFormat;
12 }  // namespace movit
13
14 class NonBouncingYCbCrInput : public movit::YCbCrInput {
15 public:
16         NonBouncingYCbCrInput(const movit::ImageFormat &image_format,
17                               const movit::YCbCrFormat &ycbcr_format,
18                               unsigned width, unsigned height,
19                               movit::YCbCrInputSplitting ycbcr_input_splitting = movit::YCBCR_INPUT_PLANAR)
20             : movit::YCbCrInput(image_format, ycbcr_format, width, height, ycbcr_input_splitting) {}
21
22         bool override_disable_bounce() const override { return true; }
23 };
24
25 // We use FlatInput with RGBA inputs a few places where we can't tell when
26 // uploading the texture whether it needs to be converted from sRGB to linear
27 // or not. (FlatInput deals with this if you give it pixels, but we give it
28 // already uploaded textures.)
29 //
30 // Since we require GL_EXT_texture_sRGB_decode (very common, as far as I can tell),
31 // we can just always upload with the sRGB flag turned on (upload your texture with
32 // GL_SRGB8_ALPHA8), and then sRGBSwitchingFlatInput will turn it off if not requested.
33
34 class sRGBSwitchingFlatInput : public movit::FlatInput {
35 public:
36         sRGBSwitchingFlatInput(movit::ImageFormat format, movit::MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
37             : movit::FlatInput(format, pixel_format, type, width, height) {}
38
39         ~sRGBSwitchingFlatInput();
40         void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override;
41         void clear_gl_state() override;
42
43         bool set_int(const std::string &key, int value) override
44         {
45                 if (key == "output_linear_gamma") {
46                         output_linear_gamma = value;
47                 }
48                 if (key == "needs_mipmaps") {
49                         needs_mipmaps = value;
50                 }
51                 return movit::FlatInput::set_int(key, value);
52         }
53
54 private:
55         bool output_linear_gamma = false;
56         bool needs_mipmaps = false;
57         GLuint sampler_obj = 0;
58         GLuint texture_unit;
59 };
60
61 #endif  // !defined(_TWEAKED_INPUTS_H)