]> git.sesse.net Git - movit/blob - blur_effect.h
Mark some appropriate effects as not needing sRGB primaries, and expand the comment...
[movit] / blur_effect.h
1 #ifndef _BLUR_EFFECT_H
2 #define _BLUR_EFFECT_H 1
3
4 // A separable 2D blur implemented by a combination of mipmap filtering
5 // and convolution (essentially giving a convolution with a piecewise linear
6 // approximation to the true impulse response).
7 //
8 // Works in two passes; first horizontal, then vertical (BlurEffect,
9 // which is what the user is intended to use, instantiates two copies of
10 // SingleBlurPassEffect behind the scenes).
11
12 #include "effect.h"
13
14 class SingleBlurPassEffect;
15
16 class BlurEffect : public Effect {
17 public:
18         BlurEffect();
19
20         virtual bool needs_srgb_primaries() const { return false; }
21
22         virtual std::string output_fragment_shader() {
23                 assert(false);
24         }
25         virtual void set_uniforms(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
26                 assert(false);
27         }
28
29         virtual bool needs_texture_bounce() const { return true; }
30         virtual bool needs_mipmaps() const { return true; }
31         virtual void add_self_to_effect_chain(EffectChain *chain, const std::vector<Effect *> &input);
32         virtual bool set_float(const std::string &key, float value);
33         
34 private:
35         SingleBlurPassEffect *hpass, *vpass;
36 };
37
38 class SingleBlurPassEffect : public Effect {
39 public:
40         SingleBlurPassEffect();
41         std::string output_fragment_shader();
42
43         virtual bool needs_srgb_primaries() const { return false; }
44         virtual bool needs_texture_bounce() const { return true; }
45         virtual bool needs_mipmaps() const { return true; }
46
47         void set_uniforms(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
48         
49         enum Direction { HORIZONTAL = 0, VERTICAL = 1 };
50
51 private:
52         float radius;
53         Direction direction;
54 };
55
56 #endif // !defined(_BLUR_EFFECT_H)