]> git.sesse.net Git - nageru/blobdiff - nageru/theme.h
Rework the chain concept.
[nageru] / nageru / theme.h
index 3d57750c9d9cd9ac39c272a1b66997637f15edbf..7c6b3243c85e5d61a1bd7ef42c77d64e7444c0a0 100644 (file)
 #include <vector>
 
 #include "bmusb/bmusb.h"
+#include "defs.h"
 #include "ref_counted_frame.h"
 #include "tweaked_inputs.h"
 
+class Scene;
 class CEFCapture;
 class FFmpegCapture;
 class LiveInputWrapper;
@@ -27,6 +29,55 @@ class EffectChain;
 class ResourcePool;
 }  // namespace movit
 
+enum EffectType {
+       // LIVE_INPUT_* also covers CEF and video inputs.
+       LIVE_INPUT_YCBCR,
+       LIVE_INPUT_YCBCR_WITH_DEINTERLACE,
+       LIVE_INPUT_YCBCR_PLANAR,
+       LIVE_INPUT_BGRA,
+       IMAGE_INPUT,
+
+       IDENTITY_EFFECT,
+       WHITE_BALANCE_EFFECT,
+       RESAMPLE_EFFECT,
+       PADDING_EFFECT,
+       INTEGRAL_PADDING_EFFECT,
+       OVERLAY_EFFECT,
+       RESIZE_EFFECT,
+       MULTIPLY_EFFECT,
+       MIX_EFFECT,
+       LIFT_GAMMA_GAIN_EFFECT
+};
+
+// An EffectBlueprint refers to an Effect before it's being added to the graph.
+// It contains enough information to instantiate the effect, including any
+// parameters that were set before it was added to the graph. Once it is
+// instantiated, it forwards its calls on to the real Effect instead.
+struct EffectBlueprint {
+       EffectBlueprint(EffectType effect_type) : effect_type(effect_type) {}
+
+       EffectType effect_type;
+       std::map<std::string, int> int_parameters;
+       std::map<std::string, float> float_parameters;
+       std::map<std::string, std::array<float, 3>> vec3_parameters;
+       std::map<std::string, std::array<float, 4>> vec4_parameters;
+
+       movit::Effect *effect = nullptr;  // Gets filled out when it's instantiated.
+};
+
+// Contains basically the same data as InputState, but does not hold on to
+// a reference to the frames. This is important so that we can release them
+// without having to wait for Lua's GC.
+struct InputStateInfo {
+       explicit InputStateInfo(const InputState& input_state);
+
+       unsigned last_width[MAX_VIDEO_CARDS], last_height[MAX_VIDEO_CARDS];
+       bool last_interlaced[MAX_VIDEO_CARDS], last_has_signal[MAX_VIDEO_CARDS], last_is_connected[MAX_VIDEO_CARDS];
+       unsigned last_frame_rate_nom[MAX_VIDEO_CARDS], last_frame_rate_den[MAX_VIDEO_CARDS];
+       bool has_last_subtitle[MAX_VIDEO_CARDS];
+       std::string last_subtitle[MAX_VIDEO_CARDS];
+};
+
 class Theme {
 public:
        Theme(const std::string &filename, const std::vector<std::string> &search_dirs, movit::ResourcePool *resource_pool, unsigned num_cards);
@@ -113,6 +164,7 @@ private:
        void register_constants();
        void register_class(const char *class_name, const luaL_Reg *funcs);
        int set_theme_menu(lua_State *L);
+       Chain get_chain_from_effect_chain(movit::EffectChain *effect_chain, unsigned num, const InputState &input_state);
 
        std::string theme_path;
 
@@ -147,6 +199,7 @@ private:
        std::function<void()> theme_menu_callback;
 
        friend class LiveInputWrapper;
+       friend class Scene;
        friend int ThemeMenu_set(lua_State *L);
 };
 
@@ -184,4 +237,12 @@ private:
        bool user_connectable;
 };
 
+// Utility functions used by Scene.
+void add_outputs_and_finalize(movit::EffectChain *chain, bool is_main_chain);
+Theme *get_theme_updata(lua_State* L);
+bool checkbool(lua_State* L, int idx);
+std::string checkstdstring(lua_State *L, int index);
+movit::Effect *instantiate_effect(movit::EffectChain *chain, EffectType effect_type);
+void print_warning(lua_State* L, const char *format, ...);
+
 #endif  // !defined(_THEME_H)