]> git.sesse.net Git - movit/blob - diffusion_effect.cpp
Support negative values for lift in LiftGammaGainEffect.
[movit] / diffusion_effect.cpp
1 #include <assert.h>
2 #include <vector>
3
4 #include "blur_effect.h"
5 #include "diffusion_effect.h"
6 #include "effect_chain.h"
7 #include "util.h"
8
9 using namespace std;
10
11 namespace movit {
12
13 DiffusionEffect::DiffusionEffect()
14         : blur(new BlurEffect),
15           overlay_matte(new OverlayMatteEffect),
16           owns_overlay_matte(true)
17 {
18 }
19
20 DiffusionEffect::~DiffusionEffect()
21 {
22         if (owns_overlay_matte) {
23                 delete overlay_matte;
24         }
25 }
26
27 void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
28 {
29         assert(self->incoming_links.size() == 1);
30         Node *input = self->incoming_links[0];
31
32         Node *blur_node = graph->add_node(blur);
33         Node *overlay_matte_node = graph->add_node(overlay_matte);
34         owns_overlay_matte = false;
35         graph->replace_receiver(self, overlay_matte_node);
36         graph->connect_nodes(input, blur_node);
37         graph->connect_nodes(blur_node, overlay_matte_node);
38         graph->replace_sender(self, overlay_matte_node);
39
40         self->disabled = true;
41 }
42
43 bool DiffusionEffect::set_float(const string &key, float value) {
44         if (key == "blurred_mix_amount") {
45                 return overlay_matte->set_float(key, value);
46         }
47         return blur->set_float(key, value);
48 }
49
50 OverlayMatteEffect::OverlayMatteEffect()
51         : blurred_mix_amount(0.3f)
52 {
53         register_float("blurred_mix_amount", &blurred_mix_amount);
54 }
55
56 string OverlayMatteEffect::output_fragment_shader()
57 {
58         return read_file("overlay_matte_effect.frag");
59 }
60
61 }  // namespace movit