File: diffusion_effect.cpp

package info (click to toggle)
movit 1.7.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 3,248 kB
  • sloc: cpp: 16,677; sh: 3,940; makefile: 167
file content (61 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <assert.h>
#include <vector>

#include "blur_effect.h"
#include "diffusion_effect.h"
#include "effect_chain.h"
#include "util.h"

using namespace std;

namespace movit {

DiffusionEffect::DiffusionEffect()
	: blur(new BlurEffect),
	  overlay_matte(new OverlayMatteEffect),
	  owns_overlay_matte(true)
{
}

DiffusionEffect::~DiffusionEffect()
{
	if (owns_overlay_matte) {
		delete overlay_matte;
	}
}

void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
{
	assert(self->incoming_links.size() == 1);
	Node *input = self->incoming_links[0];

	Node *blur_node = graph->add_node(blur);
	Node *overlay_matte_node = graph->add_node(overlay_matte);
	owns_overlay_matte = false;
	graph->replace_receiver(self, overlay_matte_node);
	graph->connect_nodes(input, blur_node);
	graph->connect_nodes(blur_node, overlay_matte_node);
	graph->replace_sender(self, overlay_matte_node);

	self->disabled = true;
}

bool DiffusionEffect::set_float(const string &key, float value) {
	if (key == "blurred_mix_amount") {
		return overlay_matte->set_float(key, value);
	}
	return blur->set_float(key, value);
}

OverlayMatteEffect::OverlayMatteEffect()
	: blurred_mix_amount(0.3f)
{
	register_float("blurred_mix_amount", &blurred_mix_amount);
}

string OverlayMatteEffect::output_fragment_shader()
{
	return read_file("overlay_matte_effect.frag");
}

}  // namespace movit