X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=diffusion_effect.cpp;h=afec9c80805490a97404d6e0c6e118759982dd9b;hp=f07f9d14eaa4cb1e4b32bb7f8323f47ed107c165;hb=95edbfccb0843da3cc105dadc5bc6d8e102f6071;hpb=e655afd53f2e56938bd4e7f72640eff56ef4a1ee diff --git a/diffusion_effect.cpp b/diffusion_effect.cpp index f07f9d1..afec9c8 100644 --- a/diffusion_effect.cpp +++ b/diffusion_effect.cpp @@ -1,17 +1,29 @@ -#include #include +#include -#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) + 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); @@ -19,6 +31,7 @@ void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self) 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); @@ -27,7 +40,7 @@ void DiffusionEffect::rewrite_graph(EffectChain *graph, Node *self) 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 +53,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