]> git.sesse.net Git - movit/blobdiff - diffusion_effect.cpp
Add proper formats for sRGB without alpha.
[movit] / diffusion_effect.cpp
index cf3188bf6013bfe162148a71cc122c0ee10bcd59..145eaf695860608040afec87bc0120eb08188c6d 100644 (file)
@@ -1,33 +1,37 @@
-#include <math.h>
 #include <assert.h>
+#include <vector>
 
-#include "diffusion_effect.h"
 #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)
 {
 }
 
-std::string DiffusionEffect::output_fragment_shader()
+void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self)
 {
-       return read_file("sandbox_effect.frag");
-}
+       assert(self->incoming_links.size() == 1);
+       Node *input = self->incoming_links[0];
 
-void DiffusionEffect::add_self_to_effect_chain(EffectChain *chain, const std::vector<Effect *> &inputs) {
-       assert(inputs.size() == 1);
-       blur->add_self_to_effect_chain(chain, inputs);
+       Node *blur_node = graph->add_node(blur);
+       Node *overlay_matte_node = graph->add_node(overlay_matte);
+       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);
 
-       std::vector<Effect *> overlay_matte_inputs;
-       overlay_matte_inputs.push_back(inputs[0]);
-       overlay_matte_inputs.push_back(chain->get_last_added_effect());  // FIXME
-       overlay_matte->add_self_to_effect_chain(chain, overlay_matte_inputs);
+       self->disabled = true;
 }
 
-bool DiffusionEffect::set_float(const std::string &key, float value) {
+bool DiffusionEffect::set_float(const string &key, float value) {
        if (key == "blurred_mix_amount") {
                return overlay_matte->set_float(key, value);
        }
@@ -40,7 +44,9 @@ OverlayMatteEffect::OverlayMatteEffect()
        register_float("blurred_mix_amount", &blurred_mix_amount);
 }
 
-std::string OverlayMatteEffect::output_fragment_shader()
+string OverlayMatteEffect::output_fragment_shader()
 {
        return read_file("overlay_matte_effect.frag");
 }
+
+}  // namespace movit