1 #ifndef _MOVIT_BLUR_EFFECT_H
2 #define _MOVIT_BLUR_EFFECT_H 1
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).
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).
21 class SingleBlurPassEffect;
23 class BlurEffect : public Effect {
27 virtual std::string effect_type_id() const { return "BlurEffect"; }
29 // We want this for the same reason as ResizeEffect; we could end up scaling
31 virtual bool needs_texture_bounce() const { return true; }
32 virtual bool needs_mipmaps() const { return true; }
33 virtual bool needs_srgb_primaries() const { return false; }
35 virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height);
37 virtual std::string output_fragment_shader() {
40 virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
44 virtual void rewrite_graph(EffectChain *graph, Node *self);
45 virtual bool set_float(const std::string &key, float value);
51 SingleBlurPassEffect *hpass, *vpass;
52 unsigned input_width, input_height;
55 class SingleBlurPassEffect : public Effect {
57 // If parent is non-NULL, calls to inform_input_size will be forwarded
58 // so that it can make reasonable decisions for both blur passes.
59 SingleBlurPassEffect(BlurEffect *parent);
60 virtual std::string effect_type_id() const { return "SingleBlurPassEffect"; }
62 std::string output_fragment_shader();
64 virtual bool needs_texture_bounce() const { return true; }
65 virtual bool needs_mipmaps() const { return true; }
66 virtual bool needs_srgb_primaries() const { return false; }
67 virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; }
69 virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height) {
71 parent->inform_input_size(input_num, width, height);
74 virtual bool changes_output_size() const { return true; }
76 virtual void get_output_size(unsigned *width, unsigned *height, unsigned *virtual_width, unsigned *virtual_height) const {
78 *height = this->height;
79 *virtual_width = this->virtual_width;
80 *virtual_height = this->virtual_height;
83 void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
84 void clear_gl_state();
86 enum Direction { HORIZONTAL = 0, VERTICAL = 1 };
92 int width, height, virtual_width, virtual_height;
95 #endif // !defined(_MOVIT_BLUR_EFFECT_H)