]> git.sesse.net Git - movit/blob - glow_effect.h
Fix another issue where an input was used twice. Add unit tests, again.
[movit] / glow_effect.h
1 #ifndef _GLOW_EFFECT_H
2 #define _GLOW_EFFECT_H 1
3
4 // Glow: Cut out the highlights of the image (everything above a certain threshold),
5 // blur them, and overlay them onto the original image.
6 //
7 // FIXME: This might be broken after MixEffect started working in premultiplied alpha.
8 // We need to think about how this is going to work, and then add a test.
9
10 #include "effect.h"
11
12 class BlurEffect;
13 class MixEffect;
14 class HighlightCutoffEffect;
15
16 class GlowEffect : public Effect {
17 public:
18         GlowEffect();
19         virtual std::string effect_type_id() const { return "GlowEffect"; }
20
21         virtual bool needs_srgb_primaries() const { return false; }
22
23         virtual void rewrite_graph(EffectChain *graph, Node *self);
24         virtual bool set_float(const std::string &key, float value);
25
26         virtual std::string output_fragment_shader() {
27                 assert(false);
28         }
29         virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
30                 assert(false);
31         }
32
33 private:
34         BlurEffect *blur;
35         HighlightCutoffEffect *cutoff;
36         MixEffect *mix;
37 };
38
39 // An effect that cuts out only the highlights of an image;
40 // anything at the cutoff or below is set to 0.0, and then all other pixels
41 // get the cutoff subtracted. Used only as part of GlowEffect.
42
43 class HighlightCutoffEffect : public Effect {
44 public:
45         HighlightCutoffEffect();
46         virtual std::string effect_type_id() const { return "HighlightCutoffEffect"; }
47         std::string output_fragment_shader();
48
49 private:
50         float cutoff;
51 };
52
53 #endif // !defined(_GLOW_EFFECT_H)