4 #include "blur_effect.h"
5 #include "effect_chain.h"
6 #include "mix_effect.h"
7 #include "unsharp_mask_effect.h"
14 UnsharpMaskEffect::UnsharpMaskEffect()
15 : blur(new BlurEffect),
18 CHECK(mix->set_float("strength_first", 1.0f));
19 CHECK(mix->set_float("strength_second", -0.3f));
22 void UnsharpMaskEffect::rewrite_graph(EffectChain *graph, Node *self)
24 assert(self->incoming_links.size() == 1);
25 Node *input = self->incoming_links[0];
27 Node *blur_node = graph->add_node(blur);
28 Node *mix_node = graph->add_node(mix);
29 graph->replace_receiver(self, mix_node);
30 graph->connect_nodes(input, blur_node);
31 graph->connect_nodes(blur_node, mix_node);
32 graph->replace_sender(self, mix_node);
34 self->disabled = true;
37 bool UnsharpMaskEffect::set_float(const string &key, float value) {
38 if (key == "amount") {
39 bool ok = mix->set_float("strength_first", 1.0f + value);
40 return ok && mix->set_float("strength_second", -value);
42 return blur->set_float(key, value);