1 #ifndef _EFFECT_CHAIN_H
2 #define _EFFECT_CHAIN_H 1
9 enum PixelFormat { FORMAT_RGB, FORMAT_RGBA, FORMAT_BGR, FORMAT_BGRA };
13 COLORSPACE_REC_709 = 0, // Same as sRGB.
14 COLORSPACE_REC_601_525 = 1,
15 COLORSPACE_REC_601_625 = 2,
22 GAMMA_REC_709 = 2, // Same as Rec. 601.
26 PixelFormat pixel_format;
27 ColorSpace color_space;
28 GammaCurve gamma_curve;
33 EffectChain(unsigned width, unsigned height);
36 // input, effects, output, finalize need to come in that specific order.
38 void add_input(const ImageFormat &format);
40 // The returned pointer is owned by EffectChain.
41 Effect *add_effect(EffectId effect) {
42 return add_effect(effect, get_last_added_effect());
44 Effect *add_effect(EffectId effect, Effect *input);
46 // Similar to add_effect, but:
48 // * Does not insert any normalizing effects.
49 // * Does not ask the effect to insert itself, so it won't work
52 // We should really separate out these two “sides” of Effect in the
54 void add_effect_raw(Effect *effect, Effect *input);
56 void add_output(const ImageFormat &format);
59 //void render(unsigned char *src, unsigned char *dst);
60 void render_to_screen(unsigned char *src);
62 Effect *get_last_added_effect() {
63 return last_added_effect;
68 GLint glsl_program_num;
69 bool input_needs_mipmaps;
73 Effect *normalize_to_linear_gamma(Effect *input);
74 Effect *normalize_to_srgb(Effect *input);
76 // Create a GLSL program computing effects [start, end>.
77 Phase compile_glsl_program(unsigned start_index, unsigned end_index);
79 unsigned width, height;
80 ImageFormat input_format, output_format;
81 std::vector<Effect *> effects;
82 std::multimap<Effect *, Effect *> outgoing_links;
83 std::multimap<Effect *, Effect *> incoming_links;
84 Effect *last_added_effect;
86 GLuint source_image_num;
87 bool use_srgb_texture_format;
90 GLuint temp_textures[2];
92 std::vector<Phase> phases;
94 GLenum format, bytes_per_pixel;
97 // Used during the building of the effect chain.
98 ColorSpace current_color_space;
99 GammaCurve current_gamma_curve;
103 #endif // !defined(_EFFECT_CHAIN_H)