]> git.sesse.net Git - nageru/blob - theme.h
Reduce the warning storm a bit.
[nageru] / theme.h
1 #ifndef _THEME_H
2 #define _THEME_H 1
3
4 #include <epoxy/gl.h>
5 #include <lauxlib.h>
6 #include <lua.h>
7 #include <movit/effect_chain.h>
8 #include <movit/ycbcr_input.h>
9 #include <stdbool.h>
10 #include <stdio.h>
11 #include <functional>
12 #include <mutex>
13 #include <set>
14 #include <string>
15 #include <utility>
16 #include <vector>
17
18 namespace movit {
19 class ResourcePool;
20 struct ImageFormat;
21 struct YCbCrFormat;
22 }  // namespace movit
23
24 #define MAX_CARDS 16
25
26 class NonBouncingYCbCrInput : public movit::YCbCrInput {
27 public:
28         NonBouncingYCbCrInput(const movit::ImageFormat &image_format,
29                               const movit::YCbCrFormat &ycbcr_format,
30                               unsigned width, unsigned height,
31                               movit::YCbCrInputSplitting ycbcr_input_splitting = movit::YCBCR_INPUT_PLANAR)
32             : movit::YCbCrInput(image_format, ycbcr_format, width, height, ycbcr_input_splitting) {}
33
34         bool override_disable_bounce() const override { return true; }
35 };
36
37 class Theme {
38 public:
39         Theme(const char *filename, movit::ResourcePool *resource_pool, unsigned num_cards);
40
41         std::pair<movit::EffectChain *, std::function<void()>>
42         get_chain(unsigned num, float t, unsigned width, unsigned height);
43
44         void set_input_textures(int signal_num, GLuint tex_y, GLuint tex_cbcr) {
45                 input_textures[signal_num].tex_y = tex_y;
46                 input_textures[signal_num].tex_cbcr = tex_cbcr;
47         }
48         int get_num_channels() { return num_channels; }
49
50         std::vector<std::string> get_transition_names(float t);
51
52         void connect_signal(movit::YCbCrInput *input, int signal_num);
53         void transition_clicked(int transition_num, float t);
54         void channel_clicked(int preview_num);
55
56 private:
57         void register_class(const char *class_name, const luaL_Reg *funcs);
58
59         std::mutex m;
60         lua_State *L;
61         movit::ResourcePool *resource_pool;
62         struct {
63                 GLuint tex_y = 0, tex_cbcr = 0;
64         } input_textures[MAX_CARDS];
65         int num_channels;
66         unsigned num_cards;
67         std::set<int> signals_warned_about;
68 };
69
70 class LiveInputWrapper {
71 public:
72         LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bool override_bounce);
73
74         void connect_signal(int signal_num);
75         movit::YCbCrInput *get_input() const
76         {
77                 return input;
78         }
79
80 private:
81         Theme *theme;  // Not owned by us.
82         movit::YCbCrInput *input;  // Owned by the chain.
83         int connected_signal_num = 0;
84 };
85
86 #endif  // !defined(_THEME_H)