]> git.sesse.net Git - movit/blob - overlay_effect.h
Clamp alpha in MixEffect.
[movit] / overlay_effect.h
1 #ifndef _OVERLAY_EFFECT_H
2 #define _OVERLAY_EFFECT_H 1
3
4 // Put one image on top of another, using alpha where appropriate.
5 // (If both images are the same aspect and the top image has alpha=1.0
6 // for all pixels, you will not see anything of the one on the bottom.)
7 //
8 // This is the “over” operation from Porter-Duff blending, also used
9 // when merging layers in e.g. GIMP or Photoshop.
10 //
11 // The first input is the bottom, and the second is the top.
12
13 #include "effect.h"
14
15 class OverlayEffect : public Effect {
16 public:
17         OverlayEffect();
18         virtual std::string effect_type_id() const { return "OverlayEffect"; }
19         std::string output_fragment_shader();
20
21         virtual bool needs_srgb_primaries() const { return false; }
22         virtual unsigned num_inputs() const { return 2; }
23
24         // Actually, if either image has blank alpha, our output will have
25         // blank alpha, too. However, understanding that would require changes
26         // to EffectChain, so postpone that optimization for later.
27         virtual AlphaHandling alpha_handling() const { return INPUT_AND_OUTPUT_ALPHA_PREMULTIPLIED; }
28 };
29
30 #endif // !defined(_OVERLAY_EFFECT_H)