]> git.sesse.net Git - movit/blob - overlay_effect.h
Support 10- and 12-bit Y'CbCr output.
[movit] / overlay_effect.h
1 #ifndef _MOVIT_OVERLAY_EFFECT_H
2 #define _MOVIT_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 <string>
14
15 #include "effect.h"
16
17 namespace movit {
18
19 class OverlayEffect : public Effect {
20 public:
21         OverlayEffect();
22         virtual std::string effect_type_id() const { return "OverlayEffect"; }
23         std::string output_fragment_shader();
24
25         virtual bool needs_srgb_primaries() const { return false; }
26         virtual unsigned num_inputs() const { return 2; }
27         virtual bool one_to_one_sampling() const { return true; }
28
29         // Actually, if _either_ image has blank alpha, our output will have
30         // blank alpha, too (this only tells the framework that having _both_
31         // images with blank alpha would result in blank alpha).
32         // However, understanding that would require changes
33         // to EffectChain, so postpone that optimization for later.
34         virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; }
35
36 private:
37         // If true, overlays input1 on top of input2 instead of vice versa.
38         // Must be set before finalize.
39         bool swap_inputs;
40 };
41
42 }  // namespace movit
43
44 #endif // !defined(_MOVIT_OVERLAY_EFFECT_H)