Movit can hardly be said to be in alpha stage anymore.
[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 {
17 }
18
19 void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
20 {
21         assert(self->incoming_links.size() == 1);
22         Node *input = self->incoming_links[0];
23
24         Node *blur_node = graph->add_node(blur);
25         Node *overlay_matte_node = graph->add_node(overlay_matte);
26         graph->replace_receiver(self, overlay_matte_node);
27         graph->connect_nodes(input, blur_node);
28         graph->connect_nodes(blur_node, overlay_matte_node);
29         graph->replace_sender(self, overlay_matte_node);
30
31         self->disabled = true;
32 }
33
34 bool DiffusionEffect::set_float(const string &key, float value) {
35         if (key == "blurred_mix_amount") {
36                 return overlay_matte->set_float(key, value);
37         }
38         return blur->set_float(key, value);
39 }
40
41 OverlayMatteEffect::OverlayMatteEffect()
42         : blurred_mix_amount(0.3f)
43 {
44         register_float("blurred_mix_amount", &blurred_mix_amount);
45 }
46
47 string OverlayMatteEffect::output_fragment_shader()
48 {
49         return read_file("overlay_matte_effect.frag");
50 }
51
52 }  // namespace movit