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