]> git.sesse.net Git - movit/blob - padding_effect.h
Fix another stack overflow in EffectChainTest.
[movit] / padding_effect.h
1 #ifndef _PADDING_EFFECT_H
2 #define _PADDING_EFFECT_H 1
3
4 // Takes an image and pads it to fit a larger image, or crops it to fit a smaller one
5 // (although the latter is implemented slightly less efficiently, and you cannot both
6 // pad and crop in the same effect).
7 //
8 // The source image is cut off at the texel borders (so there is no interpolation
9 // outside them), and then given a user-specific color; by default, full transparent.
10 //
11 // The border color is taken to be in linear gamma, sRGB, with premultiplied alpha.
12 // You may not change it after calling finalize(), since that could change the
13 // graph (need_linear_light() etc. depend on the border color you choose).
14
15 #include "effect.h"
16
17 class PaddingEffect : public Effect {
18 public:
19         PaddingEffect();
20         virtual std::string effect_type_id() const { return "PaddingEffect"; }
21         std::string output_fragment_shader();
22         void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
23
24         virtual bool needs_linear_light() const;
25         virtual bool needs_srgb_primaries() const;
26         virtual AlphaHandling alpha_handling() const;
27         
28         virtual bool changes_output_size() const { return true; }
29         virtual void get_output_size(unsigned *width, unsigned *height) const;
30         virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height);
31
32 private:
33         RGBATriplet border_color;
34         int input_width, input_height;
35         int output_width, output_height;
36         float top, left;
37 };
38
39 #endif // !defined(_PADDING_EFFECT_H)