]> git.sesse.net Git - movit/blobdiff - effect_chain.h
Remember to clear the needs_update flag on 1D textures after upload.
[movit] / effect_chain.h
index f521e9c40c083667d58e1aa795a615dc841c4700..561d823ffa4cf208c7dc239ffc86bb071843394a 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _EFFECT_CHAIN_H
 #define _EFFECT_CHAIN_H 1
 
+#include <set>
 #include <vector>
 
 #include "effect.h"
@@ -39,7 +40,7 @@ public:
 
        // The returned pointer is owned by EffectChain.
        Effect *add_effect(EffectId effect) {
-               return add_effect(effect, get_last_added_effect());
+               return add_effect(effect, last_added_effect());
        }
        Effect *add_effect(EffectId effect, Effect *input) {
                std::vector<Effect *> inputs;
@@ -70,36 +71,46 @@ public:
        //void render(unsigned char *src, unsigned char *dst);
        void render_to_screen(unsigned char *src);
 
-       Effect *get_last_added_effect() { 
-               return last_added_effect;
+       Effect *last_added_effect() {
+               if (effects.empty()) {
+                       return NULL;
+               } else {
+                       return effects.back();
+               }       
        }
 
 private:
        struct Phase {
                GLint glsl_program_num;
                bool input_needs_mipmaps;
-               unsigned start, end;
+               std::vector<Effect *> inputs;
+               std::vector<Effect *> effects;  // In order.
        };
 
        Effect *normalize_to_linear_gamma(Effect *input);
        Effect *normalize_to_srgb(Effect *input);
 
-       // Create a GLSL program computing effects [start, end>.
-       Phase compile_glsl_program(unsigned start_index, unsigned end_index);
+       void draw_vertex(float x, float y, const std::vector<Effect *> &inputs);
+
+       // Create a GLSL program computing the given effects in order.
+       Phase compile_glsl_program(const std::vector<Effect *> &inputs, const std::vector<Effect *> &effects);
+
+       // Create all GLSL programs needed to compute the given effect, and all outputs
+       // that depends on it (whenever possible).
+       void construct_glsl_programs(Effect *start, std::set<Effect *> *completed_effects);
 
        unsigned width, height;
        ImageFormat input_format, output_format;
-       std::vector<Effect *> effects;
-       std::multimap<Effect *, Effect *> outgoing_links;
-       std::multimap<Effect *, Effect *> incoming_links;
-       Effect *last_added_effect;
+       std::vector<Effect *> effects, unexpanded_effects;
+       std::map<Effect *, std::string> effect_ids;
+       std::map<Effect *, GLuint> effect_output_textures;
+       std::map<Effect *, std::vector<Effect *> > outgoing_links;
+       std::map<Effect *, std::vector<Effect *> > incoming_links;
 
        GLuint source_image_num;
        bool use_srgb_texture_format;
 
        GLuint fbo;
-       GLuint temp_textures[2];
-
        std::vector<Phase> phases;
 
        GLenum format, bytes_per_pixel;