#include "effect_chain.h"
#include "gamma_expansion_effect.h"
#include "gamma_compression_effect.h"
-#include "lift_gamma_gain_effect.h"
#include "colorspace_conversion_effect.h"
-#include "sandbox_effect.h"
-#include "saturation_effect.h"
-#include "mirror_effect.h"
-#include "vignette_effect.h"
-#include "blur_effect.h"
-#include "diffusion_effect.h"
-#include "glow_effect.h"
-#include "mix_effect.h"
#include "input.h"
EffectChain::EffectChain(unsigned width, unsigned height)
output_color_space[effect] = output_color_space[last_added_effect()];
}
-Effect *instantiate_effect(EffectId effect)
-{
- switch (effect) {
- case EFFECT_GAMMA_EXPANSION:
- return new GammaExpansionEffect();
- case EFFECT_GAMMA_COMPRESSION:
- return new GammaCompressionEffect();
- case EFFECT_COLOR_SPACE_CONVERSION:
- return new ColorSpaceConversionEffect();
- case EFFECT_SANDBOX:
- return new SandboxEffect();
- case EFFECT_LIFT_GAMMA_GAIN:
- return new LiftGammaGainEffect();
- case EFFECT_SATURATION:
- return new SaturationEffect();
- case EFFECT_MIRROR:
- return new MirrorEffect();
- case EFFECT_VIGNETTE:
- return new VignetteEffect();
- case EFFECT_BLUR:
- return new BlurEffect();
- case EFFECT_DIFFUSION:
- return new DiffusionEffect();
- case EFFECT_GLOW:
- return new GlowEffect();
- case EFFECT_MIX:
- return new MixEffect();
- }
- assert(false);
-}
-
// Set the "use_srgb_texture_format" option on all inputs that feed into this node,
// and update the output_gamma_curve[] map as we go.
//
return colorspace_conversion;
}
-Effect *EffectChain::add_effect(EffectId effect_id, const std::vector<Effect *> &inputs)
+Effect *EffectChain::add_effect(Effect *effect, const std::vector<Effect *> &inputs)
{
- Effect *effect = instantiate_effect(effect_id);
-
assert(inputs.size() == effect->num_inputs());
std::vector<Effect *> normalized_inputs = inputs;
#include <vector>
#include "effect.h"
-#include "effect_id.h"
#include "image_format.h"
#include "input.h"
Input *add_input(const ImageFormat &format);
- // The returned pointer is owned by EffectChain.
- Effect *add_effect(EffectId effect) {
+ // EffectChain takes ownership of the given effect.
+ // effect is returned back for convenience.
+ Effect *add_effect(Effect *effect) {
return add_effect(effect, last_added_effect());
}
- Effect *add_effect(EffectId effect, Effect *input) {
+ Effect *add_effect(Effect *effect, Effect *input) {
std::vector<Effect *> inputs;
inputs.push_back(input);
return add_effect(effect, inputs);
}
- Effect *add_effect(EffectId effect, Effect *input1, Effect *input2) {
+ Effect *add_effect(Effect *effect, Effect *input1, Effect *input2) {
std::vector<Effect *> inputs;
inputs.push_back(input1);
inputs.push_back(input2);
return add_effect(effect, inputs);
}
- Effect *add_effect(EffectId effect, const std::vector<Effect *> &inputs);
+ Effect *add_effect(Effect *effect, const std::vector<Effect *> &inputs);
// Similar to add_effect, but:
//
#include "util.h"
#include "widgets.h"
+#include "lift_gamma_gain_effect.h"
+#include "saturation_effect.h"
+#include "diffusion_effect.h"
+
unsigned char result[WIDTH * HEIGHT * 4];
float lift_theta = 0.0f, lift_rad = 0.0f, lift_v = 0.0f;
inout_format.gamma_curve = GAMMA_sRGB;
Input *input = chain.add_input(inout_format);
- Effect *lift_gamma_gain_effect = chain.add_effect(EFFECT_LIFT_GAMMA_GAIN);
- Effect *saturation_effect = chain.add_effect(EFFECT_SATURATION);
- Effect *diffusion_effect = chain.add_effect(EFFECT_DIFFUSION);
- //Effect *vignette_effect = chain.add_effect(EFFECT_VIGNETTE);
- //Effect *sandbox_effect = chain.add_effect(EFFECT_SANDBOX);
+ Effect *lift_gamma_gain_effect = chain.add_effect(new LiftGammaGainEffect());
+ Effect *saturation_effect = chain.add_effect(new SaturationEffect());
+ Effect *diffusion_effect = chain.add_effect(new DiffusionEffect());
+ //Effect *vignette_effect = chain.add_effect(new VignetteEffect());
+ //Effect *sandbox_effect = chain.add_effect(new SandboxEffect());
//sandbox_effect->set_float("parm", 42.0f);
- //chain.add_effect(EFFECT_MIRROR);
+ //chain.add_effect(new MirrorEffect());
chain.add_output(inout_format);
chain.finalize();