]> git.sesse.net Git - movit/blobdiff - effect_chain.h
Make a new system for meta-effects, and convert the blur to use it. Hides the two...
[movit] / effect_chain.h
index c8fe11e639ed36c52b10724f72cab87af01a1540..4abfb97eba1390f0ca7f16daff094bea14dabd60 100644 (file)
@@ -6,7 +6,7 @@
 #include "effect.h"
 #include "effect_id.h"
 
-enum PixelFormat { FORMAT_RGB, FORMAT_RGBA };
+enum PixelFormat { FORMAT_RGB, FORMAT_RGBA, FORMAT_BGR, FORMAT_BGRA };
 
 enum ColorSpace {
        COLORSPACE_sRGB = 0,
@@ -31,20 +31,49 @@ struct ImageFormat {
 class EffectChain {
 public:
        EffectChain(unsigned width, unsigned height);
+
+       // input, effects, output, finalize need to come in that specific order.
+
        void add_input(const ImageFormat &format);
 
-       // The pointer is owned by EffectChain.
+       // The returned pointer is owned by EffectChain.
        Effect *add_effect(EffectId effect);
 
        void add_output(const ImageFormat &format);
+       void finalize();
 
-       void render(unsigned char *src, unsigned char *dst);
+       //void render(unsigned char *src, unsigned char *dst);
+       void render_to_screen(unsigned char *src);
 
 private:
+       struct Phase {
+               GLint glsl_program_num;
+               bool input_needs_mipmaps;
+               unsigned start, end;
+       };
+
+       void normalize_to_linear_gamma();
+       void normalize_to_srgb();
+
+       // Create a GLSL program computing effects [start, end>.
+       Phase compile_glsl_program(unsigned start_index, unsigned end_index);
+
        unsigned width, height;
        ImageFormat input_format, output_format;
        std::vector<Effect *> effects;
 
+       GLuint source_image_num;
+       bool use_srgb_texture_format;
+
+       GLuint fbo;
+       GLuint temp_textures[2];
+
+       std::vector<Phase> phases;
+
+       GLenum format, bytes_per_pixel;
+       bool finalized;
+
+       // Used during the building of the effect chain.
        ColorSpace current_color_space;
        GammaCurve current_gamma_curve; 
 };