4 #include "unsharp_mask_effect.h"
5 #include "blur_effect.h"
6 #include "mix_effect.h"
7 #include "effect_chain.h"
10 UnsharpMaskEffect::UnsharpMaskEffect()
11 : blur(new BlurEffect),
14 mix->set_float("strength_first", 1.0f);
15 mix->set_float("strength_second", -0.3f);
18 void UnsharpMaskEffect::rewrite_graph(EffectChain *graph, Node *self)
20 assert(self->incoming_links.size() == 1);
21 Node *input = self->incoming_links[0];
23 Node *blur_node = graph->add_node(blur);
24 Node *mix_node = graph->add_node(mix);
25 graph->replace_receiver(self, mix_node);
26 graph->connect_nodes(input, blur_node);
27 graph->connect_nodes(blur_node, mix_node);
28 graph->replace_sender(self, mix_node);
30 self->disabled = true;
33 bool UnsharpMaskEffect::set_float(const std::string &key, float value) {
34 printf("%s = %f\n", key.c_str(), value);
35 if (key == "amount") {
36 bool ok = mix->set_float("strength_first", 1.0f + value);
37 return ok && mix->set_float("strength_second", -value);
39 return blur->set_float(key, value);