]> git.sesse.net Git - nageru/blob - theme.h
Open up for inputs that are different from the native resolution. No deinterlacing...
[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 #include "defs.h"
19
20 namespace movit {
21 class ResourcePool;
22 struct ImageFormat;
23 struct YCbCrFormat;
24 }  // namespace movit
25
26 #define MAX_CARDS 16
27
28 class NonBouncingYCbCrInput : public movit::YCbCrInput {
29 public:
30         NonBouncingYCbCrInput(const movit::ImageFormat &image_format,
31                               const movit::YCbCrFormat &ycbcr_format,
32                               unsigned width, unsigned height,
33                               movit::YCbCrInputSplitting ycbcr_input_splitting = movit::YCBCR_INPUT_PLANAR)
34             : movit::YCbCrInput(image_format, ycbcr_format, width, height, ycbcr_input_splitting) {}
35
36         bool override_disable_bounce() const override { return true; }
37 };
38
39 class Theme {
40 public:
41         Theme(const char *filename, movit::ResourcePool *resource_pool, unsigned num_cards);
42
43         std::pair<movit::EffectChain *, std::function<void()>>
44         get_chain(unsigned num, float t, unsigned width, unsigned height);
45
46         void set_input_textures(int signal_num, GLuint tex_y, GLuint tex_cbcr, GLuint width, GLuint height) {
47                 auto &tex = input_textures[signal_num];
48                 tex.tex_y = tex_y;
49                 tex.tex_cbcr = tex_cbcr;
50                 tex.width = width;
51                 tex.height = height;
52         }
53         int get_num_channels() { return num_channels; }
54         std::string get_channel_name(unsigned channel);
55         bool get_supports_set_wb(unsigned channel);
56         void set_wb(unsigned channel, double r, double g, double b);
57
58         std::vector<std::string> get_transition_names(float t);
59
60         void connect_signal(movit::YCbCrInput *input, int signal_num);
61         void transition_clicked(int transition_num, float t);
62         void channel_clicked(int preview_num);
63
64 private:
65         void register_class(const char *class_name, const luaL_Reg *funcs);
66
67         std::mutex m;
68         lua_State *L;
69         movit::ResourcePool *resource_pool;
70         struct {
71                 GLuint tex_y = 0, tex_cbcr = 0;
72                 GLuint width = WIDTH, height = HEIGHT;
73         } input_textures[MAX_CARDS];
74         int num_channels;
75         unsigned num_cards;
76         std::set<int> signals_warned_about;
77 };
78
79 class LiveInputWrapper {
80 public:
81         LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bool override_bounce);
82
83         void connect_signal(int signal_num);
84         movit::YCbCrInput *get_input() const
85         {
86                 return input;
87         }
88
89 private:
90         Theme *theme;  // Not owned by us.
91         movit::YCbCrInput *input;  // Owned by the chain.
92         int connected_signal_num = 0;
93 };
94
95 #endif  // !defined(_THEME_H)