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