2 #define _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).
14 class SingleBlurPassEffect;
16 class BlurEffect : public Effect {
20 virtual std::string effect_type_id() const { return "BlurEffect"; }
22 // We want this for the same reason as ResizeEffect; we could end up scaling
24 virtual bool needs_texture_bounce() const { return true; }
25 virtual bool needs_mipmaps() const { return true; }
26 virtual bool needs_srgb_primaries() const { return false; }
27 virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED; }
29 virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height);
31 virtual std::string output_fragment_shader() {
34 virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
38 virtual void rewrite_graph(EffectChain *graph, Node *self);
39 virtual bool set_float(const std::string &key, float value);
45 SingleBlurPassEffect *hpass, *vpass;
46 unsigned input_width, input_height;
49 class SingleBlurPassEffect : public Effect {
51 // If parent is non-NULL, calls to inform_input_size will be forwarded
52 // so that it can make reasonable decisions for both blur passes.
53 SingleBlurPassEffect(BlurEffect *parent);
54 virtual std::string effect_type_id() const { return "SingleBlurPassEffect"; }
56 std::string output_fragment_shader();
58 virtual bool needs_texture_bounce() const { return true; }
59 virtual bool needs_mipmaps() const { return true; }
60 virtual bool needs_srgb_primaries() const { return false; }
62 virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height) {
64 parent->inform_input_size(input_num, width, height);
67 virtual bool changes_output_size() const { return true; }
69 virtual void get_output_size(unsigned *width, unsigned *height) const {
71 *height = this->height;
74 void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
75 void clear_gl_state();
77 enum Direction { HORIZONTAL = 0, VERTICAL = 1 };
86 #endif // !defined(_BLUR_EFFECT_H)