]> git.sesse.net Git - nageru/blobdiff - nageru/scene.h
Make so that auto white balance is stored per (physical) card, not per signal.
[nageru] / nageru / scene.h
index 8db75540559cfa29bf45611319e19380bb56fc1c..e126ca398c879b405f17d0d1b5ccd55848110152 100644 (file)
@@ -113,8 +113,8 @@ struct Block {
        // For LIVE_INPUT* only. We can't just always populate signal_to_connect,
        // since when we set this, CEF and video signals may not have numbers yet.
        // FIXME: Perhaps it would be simpler if they just did?
-       enum { CONNECT_NONE, CONNECT_SIGNAL, CONNECT_CEF, CONNECT_VIDEO } signal_type_to_connect = CONNECT_NONE;
-       int signal_to_connect = 0;  // For CONNECT_SIGNAL.
+       enum { CONNECT_NONE, CONNECT_CARD, CONNECT_CEF, CONNECT_VIDEO } signal_type_to_connect = CONNECT_NONE;
+       int card_to_connect = 0;  // For CONNECT_CARD.
 #ifdef HAVE_CEF
        CEFCapture *cef_to_connect = nullptr;  // For CONNECT_CEF.
 #endif
@@ -131,6 +131,10 @@ struct Block {
        std::map<std::string, std::array<float, 4>> vec4_parameters;
 
        std::string declaration_point;  // For error messages.
+
+       // Only for AUTO_WHITE_BALANCE_EFFECT. Points to the parent block with is_input = true,
+       // so that we know which signal to get the white balance from.
+       const Block *white_balance_controller_block = nullptr;
 };
 
 int Block_display(lua_State* L);
@@ -162,7 +166,8 @@ private:
 
        movit::Effect *instantiate_effects(const Block *block, size_t chain_idx, Instantiation *instantiation);
        size_t compute_chain_number_for_block(size_t block_idx, const std::bitset<256> &disabled) const;
-       static void find_inputs_for_block(lua_State *L, Scene *scene, Block *block);
+       static void find_inputs_for_block(lua_State *L, Scene *scene, Block *block, int first_input_idx = 3);
+       static Block *find_block_from_arg(lua_State *L, Scene *scene, int idx);
 
        // Find out which blocks (indexed by position in the “blocks” array),
        // if any, are disabled in a given instantiation. A disabled block is
@@ -182,6 +187,11 @@ private:
        // it returns true.
        bool is_noncanonical_chain(size_t chain_idx) const;
 
+       // For a given block, find any parents it may have that are inputs.
+       // If there is more than one, throws an error. If there are zero,
+       // returns nullptr (should probably also be an error).
+       const Block *find_root_input_block(lua_State *L, const Block *block);
+
 public:
        Scene(Theme *theme, float aspect_nom, float aspect_denom);
        size_t compute_chain_number(bool is_main_chain) const;
@@ -192,6 +202,7 @@ public:
        static int add_input(lua_State *L);
        static int add_effect(lua_State *L);
        static int add_optional_effect(lua_State *L);
+       static int add_auto_white_balance(lua_State *L);
        static int finalize(lua_State *L);
 };