]> git.sesse.net Git - mlt/blob - src/modules/opengl/optional_effect.h
Adjust for Movit moving into namespace movit.
[mlt] / src / modules / opengl / optional_effect.h
1 #ifndef OPTIONAL_EFFECT_H
2 #define OPTIONAL_EFFECT_H
3
4 #include <movit/effect.h>
5 #include <movit/effect_chain.h>
6 #include <assert.h>
7
8 // A wrapper effect that, at rewrite time, can remove itself entirely from the loop.
9 // It does so if "disable" is set to a nonzero value at finalization time.
10 template<class T>
11 class OptionalEffect : public T {
12 public:
13         OptionalEffect() : disable(0) { this->register_int("disable", &disable); }
14         virtual std::string effect_type_id() const { return "OptionalEffect[" + T::effect_type_id() + "]"; }
15         virtual void rewrite_graph(movit::EffectChain *graph, movit::Node *self) {
16                 if (disable) {
17                         assert(self->incoming_links.size() == 1);
18                         graph->replace_sender(self, self->incoming_links[0]);
19                         self->disabled = true;
20                 } else {
21                         T::rewrite_graph(graph, self);
22                 }
23         }
24
25 private:
26         int disable;
27 };
28
29 #endif