]> git.sesse.net Git - movit/blob - diffusion_effect.cpp
Explicitly declare use of round() as an #extension.
[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 DiffusionEffect::DiffusionEffect()
12         : blur(new BlurEffect),
13           overlay_matte(new OverlayMatteEffect)
14 {
15 }
16
17 void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
18 {
19         assert(self->incoming_links.size() == 1);
20         Node *input = self->incoming_links[0];
21
22         Node *blur_node = graph->add_node(blur);
23         Node *overlay_matte_node = graph->add_node(overlay_matte);
24         graph->replace_receiver(self, overlay_matte_node);
25         graph->connect_nodes(input, blur_node);
26         graph->connect_nodes(blur_node, overlay_matte_node);
27         graph->replace_sender(self, overlay_matte_node);
28
29         self->disabled = true;
30 }
31
32 bool DiffusionEffect::set_float(const string &key, float value) {
33         if (key == "blurred_mix_amount") {
34                 return overlay_matte->set_float(key, value);
35         }
36         return blur->set_float(key, value);
37 }
38
39 OverlayMatteEffect::OverlayMatteEffect()
40         : blurred_mix_amount(0.3f)
41 {
42         register_float("blurred_mix_amount", &blurred_mix_amount);
43 }
44
45 string OverlayMatteEffect::output_fragment_shader()
46 {
47         return read_file("overlay_matte_effect.frag");
48 }