1 #ifndef _EFFECT_CHAIN_H
2 #define _EFFECT_CHAIN_H 1
9 #include "image_format.h"
14 EffectChain(unsigned width, unsigned height);
17 // input, effects, output, finalize need to come in that specific order.
19 Input *add_input(const ImageFormat &format);
21 // The returned pointer is owned by EffectChain.
22 Effect *add_effect(EffectId effect) {
23 return add_effect(effect, last_added_effect());
25 Effect *add_effect(EffectId effect, Effect *input) {
26 std::vector<Effect *> inputs;
27 inputs.push_back(input);
28 return add_effect(effect, inputs);
30 Effect *add_effect(EffectId effect, Effect *input1, Effect *input2) {
31 std::vector<Effect *> inputs;
32 inputs.push_back(input1);
33 inputs.push_back(input2);
34 return add_effect(effect, inputs);
36 Effect *add_effect(EffectId effect, const std::vector<Effect *> &inputs);
38 // Similar to add_effect, but:
40 // * Does not insert any normalizing effects.
41 // * Does not ask the effect to insert itself, so it won't work
44 // We should really separate out these two “sides” of Effect in the
46 void add_effect_raw(Effect *effect, const std::vector<Effect *> &inputs);
48 void add_output(const ImageFormat &format);
51 //void render(unsigned char *src, unsigned char *dst);
52 void render_to_screen();
54 Effect *last_added_effect() {
55 if (effects.empty()) {
58 return effects.back();
64 GLint glsl_program_num;
65 bool input_needs_mipmaps;
66 std::vector<Effect *> inputs;
67 std::vector<Effect *> effects; // In order.
70 Effect *normalize_to_linear_gamma(Effect *input);
71 Effect *normalize_to_srgb(Effect *input);
73 void draw_vertex(float x, float y, const std::vector<Effect *> &inputs);
75 // Create a GLSL program computing the given effects in order.
76 Phase compile_glsl_program(const std::vector<Effect *> &inputs, const std::vector<Effect *> &effects);
78 // Create all GLSL programs needed to compute the given effect, and all outputs
79 // that depends on it (whenever possible).
80 void construct_glsl_programs(Effect *start, std::set<Effect *> *completed_effects);
82 unsigned width, height;
83 ImageFormat input_format, output_format;
84 std::vector<Effect *> effects;
85 std::map<Effect *, std::string> effect_ids;
86 std::map<Effect *, GLuint> effect_output_textures;
87 std::map<Effect *, std::vector<Effect *> > outgoing_links;
88 std::map<Effect *, std::vector<Effect *> > incoming_links;
91 std::vector<Phase> phases;
93 GLenum format, bytes_per_pixel;
96 // Used during the building of the effect chain.
97 std::map<Effect *, ColorSpace> output_color_space;
98 std::map<Effect *, GammaCurve> output_gamma_curve;
102 #endif // !defined(_EFFECT_CHAIN_H)