diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index f5cd3ae8388..bd8642e403f 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -1754,8 +1754,8 @@ static bool version_merge_still_offsets(Strip *strip, void * /*user_data*/) static bool version_set_seq_single_frame_content(Strip *strip, void * /*user_data*/) { if ((strip->len == 1) && - (strip->type == STRIP_TYPE_IMAGE || ((strip->type & STRIP_TYPE_EFFECT) && - blender::seq::effect_get_num_inputs(strip->type) == 0))) + (strip->type == STRIP_TYPE_IMAGE || + (strip->is_effect() && blender::seq::effect_get_num_inputs(strip->type) == 0))) { strip->flag |= SEQ_SINGLE_FRAME_CONTENT; } diff --git a/source/blender/blenloader/intern/versioning_450.cc b/source/blender/blenloader/intern/versioning_450.cc index 0f115b593b4..489359a4fa3 100644 --- a/source/blender/blenloader/intern/versioning_450.cc +++ b/source/blender/blenloader/intern/versioning_450.cc @@ -4830,8 +4830,8 @@ static bool strip_effect_overdrop_to_alphaover(Strip *strip, void * /*user_data* if (strip->type == STRIP_TYPE_OVERDROP_REMOVED) { strip->type = STRIP_TYPE_ALPHAOVER; } - if (strip->blend_mode == STRIP_TYPE_OVERDROP_REMOVED) { - strip->blend_mode = STRIP_TYPE_ALPHAOVER; + if (strip->blend_mode == STRIP_BLEND_OVERDROP_REMOVED) { + strip->blend_mode = STRIP_BLEND_ALPHAOVER; } return true; } diff --git a/source/blender/blenloader/intern/versioning_legacy.cc b/source/blender/blenloader/intern/versioning_legacy.cc index 5da44b0ff30..03dace6fd03 100644 --- a/source/blender/blenloader/intern/versioning_legacy.cc +++ b/source/blender/blenloader/intern/versioning_legacy.cc @@ -447,7 +447,7 @@ static bool strip_set_alpha_mode_cb(Strip *strip, void * /*user_data*/) static bool strip_set_blend_mode_cb(Strip *strip, void * /*user_data*/) { - if (strip->blend_mode == 0) { + if (strip->blend_mode == STRIP_BLEND_REPLACE) { strip->blend_opacity = 100.0f; } return true; diff --git a/source/blender/editors/space_outliner/tree/tree_element_seq.cc b/source/blender/editors/space_outliner/tree/tree_element_seq.cc index 363c6baa695..db433e47f33 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_seq.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.cc @@ -27,7 +27,7 @@ TreeElementStrip::TreeElementStrip(TreeElement &legacy_te, Strip &strip) bool TreeElementStrip::expand_poll(const SpaceOutliner & /*space_outliner*/) const { - return !(strip_.type & STRIP_TYPE_EFFECT); + return !strip_.is_effect(); } void TreeElementStrip::expand(SpaceOutliner & /*space_outliner*/) const diff --git a/source/blender/editors/space_sequencer/sequencer_edit.cc b/source/blender/editors/space_sequencer/sequencer_edit.cc index 5b6c3a6d351..d847f8b5dff 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_edit.cc @@ -293,7 +293,7 @@ static bool sequencer_effect_poll(bContext *C) if (ed) { Strip *active_strip = seq::select_active_get(scene); - if (active_strip && (active_strip->type & STRIP_TYPE_EFFECT)) { + if (active_strip && active_strip->is_effect()) { return true; } } @@ -380,7 +380,7 @@ void sync_active_scene_and_time_with_scene_strip(bContext &C) sequence_scene, seqbase, sequence_scene->r.cfra); /* Ignore effect strips, sound strips and muted strips. */ query_strips.remove_if([&](const Strip *strip) { - return (strip->type & STRIP_TYPE_EFFECT) != 0 || strip->type == STRIP_TYPE_SOUND_RAM || + return strip->is_effect() || strip->type == STRIP_TYPE_SOUND_RAM || seq::render_is_muted(channels, strip); }); Vector strips = query_strips.extract_vector(); @@ -588,7 +588,7 @@ static wmOperatorStatus sequencer_snap_exec(bContext *C, wmOperator *op) /* Recalculate bounds of effect strips, offsetting the keyframes if not snapping any handle. */ LISTBASE_FOREACH (Strip *, strip, ed->current_strips()) { - if (strip->type & STRIP_TYPE_EFFECT) { + if (strip->is_effect()) { const bool either_handle_selected = (strip->flag & (SEQ_LEFTSEL | SEQ_RIGHTSEL)) != 0; if (strip->input1 && (strip->input1->flag & SELECT)) { @@ -1637,7 +1637,7 @@ static wmOperatorStatus sequencer_swap_inputs_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_sequencer_scene(C); Strip *active_strip = seq::select_active_get(scene); - if (!(active_strip->type & STRIP_TYPE_EFFECT)) { + if (!active_strip->is_effect()) { BKE_report(op->reports, RPT_ERROR, "Active strip is not an effect strip"); return OPERATOR_CANCELLED; } @@ -2160,7 +2160,7 @@ static wmOperatorStatus sequencer_offset_clear_exec(bContext *C, wmOperator * /* continue; } - if ((strip->type & STRIP_TYPE_EFFECT) == 0 && (strip->flag & SELECT)) { + if (!strip->is_effect() && (strip->flag & SELECT)) { strip->startofs = strip->endofs = 0; } } @@ -2175,7 +2175,7 @@ static wmOperatorStatus sequencer_offset_clear_exec(bContext *C, wmOperator * /* for (strip = static_cast(ed->current_strips()->first); strip; strip = static_cast(strip->next)) { - if ((strip->type & STRIP_TYPE_EFFECT) == 0 && (strip->flag & SELECT)) { + if (!strip->is_effect() && (strip->flag & SELECT)) { if (seq::transform_test_overlap(scene, ed->current_strips(), strip)) { seq::transform_seqbase_shuffle(ed->current_strips(), strip, scene); } @@ -2725,7 +2725,7 @@ static wmOperatorStatus sequencer_swap_exec(bContext *C, wmOperator *op) /* Do this in a new loop since both effects need to be calculated first. */ LISTBASE_FOREACH (Strip *, istrip, seqbase) { - if ((istrip->type & STRIP_TYPE_EFFECT) && + if (istrip->is_effect() && (strip_is_parent(istrip, active_strip) || strip_is_parent(istrip, strip))) { /* This may now overlap. */ @@ -2982,7 +2982,7 @@ static wmOperatorStatus sequencer_change_effect_type_exec(bContext *C, wmOperato /* Free previous effect and init new effect. */ seq::EffectHandle sh; - if ((strip->type & STRIP_TYPE_EFFECT) == 0) { + if (!strip->is_effect()) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/sequencer_select.cc b/source/blender/editors/space_sequencer/sequencer_select.cc index cda2671d85f..a9ab38328d8 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.cc +++ b/source/blender/editors/space_sequencer/sequencer_select.cc @@ -19,6 +19,7 @@ #include "BLI_math_geom.h" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" +#include "BLI_set.hh" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -1336,7 +1337,7 @@ wmOperatorStatus sequencer_select_exec(bContext *C, wmOperator *op) if (copy_handles_to_sel) { copy_to = seq::query_selected_strips(seq::active_seqbase_get(scene->ed)); copy_to.remove(selection.strip1); - copy_to.remove_if([](Strip *strip) { return (strip->type & STRIP_TYPE_EFFECT); }); + copy_to.remove_if([](Strip *strip) { return strip->is_effect(); }); } bool changed = false; @@ -2698,10 +2699,7 @@ static const EnumPropertyItem sequencer_prop_select_grouped_types[] = { {0, nullptr, 0, nullptr, nullptr}, }; -#define STRIP_IS_SOUND(_strip) \ - ((_strip->type & STRIP_TYPE_SOUND_RAM) && !(_strip->type & STRIP_TYPE_EFFECT)) - -#define STRIP_IS_EFFECT(_strip) ((_strip->type & STRIP_TYPE_EFFECT) != 0) +#define STRIP_IS_SOUND(_strip) (_strip->type == STRIP_TYPE_SOUND_RAM) #define STRIP_USE_DATA(_strip) \ (ELEM(_strip->type, STRIP_TYPE_SCENE, STRIP_TYPE_MOVIECLIP, STRIP_TYPE_MASK) || \ @@ -2752,11 +2750,11 @@ static bool select_grouped_type_effect(blender::Span strips, const int channel) { bool changed = false; - const bool is_effect = STRIP_IS_EFFECT(act_strip); + const bool is_effect = act_strip->is_effect(); for (Strip *strip : strips) { if (STRIP_CHANNEL_CHECK(strip, channel) && - (is_effect ? STRIP_IS_EFFECT(strip) : !STRIP_IS_EFFECT(strip))) + (is_effect ? strip->is_effect() : !strip->is_effect())) { strip->flag |= SELECT; changed = true; @@ -2831,22 +2829,18 @@ static bool select_grouped_effect(blender::Span strips, const int channel) { bool changed = false; - bool effects[STRIP_TYPE_MAX + 1]; + blender::Set effects; - for (int i = 0; i <= STRIP_TYPE_MAX; i++) { - effects[i] = false; - } - - for (Strip *strip : strips) { - if (STRIP_CHANNEL_CHECK(strip, channel) && (strip->type & STRIP_TYPE_EFFECT) && + for (const Strip *strip : strips) { + if (STRIP_CHANNEL_CHECK(strip, channel) && strip->is_effect() && seq::relation_is_effect_of_strip(strip, act_strip)) { - effects[strip->type] = true; + effects.add(StripType(strip->type)); } } for (Strip *strip : strips) { - if (STRIP_CHANNEL_CHECK(strip, channel) && effects[strip->type]) { + if (STRIP_CHANNEL_CHECK(strip, channel) && effects.contains(StripType(strip->type))) { if (strip->input1) { strip->input1->flag |= SELECT; } @@ -2930,7 +2924,6 @@ static bool select_grouped_effect_link(const Scene *scene, } #undef STRIP_IS_SOUND -#undef STRIP_IS_EFFECT #undef STRIP_USE_DATA static wmOperatorStatus sequencer_select_grouped_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/transform/transform_convert_sequencer.cc b/source/blender/editors/transform/transform_convert_sequencer.cc index 797b83e7eb1..3ef4a9e76a6 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.cc +++ b/source/blender/editors/transform/transform_convert_sequencer.cc @@ -480,7 +480,7 @@ static void create_trans_seq_clamp_data(TransInfo *t, const Scene *scene) VectorSet strips = seq::query_selected_strips(seq::active_seqbase_get(ed)); for (Strip *strip : strips) { - if (!(strip->type & STRIP_TYPE_EFFECT) || seq::effect_get_num_inputs(strip->type) == 0) { + if (!strip->is_effect() || seq::effect_get_num_inputs(strip->type) == 0) { continue; } /* If there is an effect strip with no inputs selected, prevent any x-direction movement, @@ -708,7 +708,7 @@ static void flushTransSeq(TransInfo *t) if (tdsq->sel_flag & SEQ_RIGHTSEL) { strip->runtime.flag &= ~STRIP_CLAMPED_RH; } - if (!seq::transform_single_image_check(strip) && !(strip->type & STRIP_TYPE_EFFECT)) { + if (!seq::transform_single_image_check(strip) && !strip->is_effect()) { if (offset_clamped[0] > offset[0] && new_frame == seq::time_start_frame_get(strip)) { strip->runtime.flag |= STRIP_CLAMPED_LH; } diff --git a/source/blender/editors/transform/transform_snap_sequencer.cc b/source/blender/editors/transform/transform_snap_sequencer.cc index f8ffe0c2c51..c9ef4e6e2de 100644 --- a/source/blender/editors/transform/transform_snap_sequencer.cc +++ b/source/blender/editors/transform/transform_snap_sequencer.cc @@ -214,7 +214,7 @@ static VectorSet query_snap_targets_timeline(Scene *scene, VectorSet effects_of_snap_sources = snap_sources; seq::iterator_set_expand(scene, seqbase, effects_of_snap_sources, query_strip_effects_fn); effects_of_snap_sources.remove_if([&](Strip *strip) { - return (strip->type & STRIP_TYPE_EFFECT) != 0 && seq::effect_get_num_inputs(strip->type) == 0; + return strip->is_effect() && seq::effect_get_num_inputs(strip->type) == 0; }); VectorSet snap_targets; @@ -310,7 +310,7 @@ static void points_build_targets_timeline(const Scene *scene, int content_end = seq::time_content_end_frame_get(scene, strip); /* Effects and single image strips produce incorrect content length. Skip these strips. */ - if ((strip->type & STRIP_TYPE_EFFECT) != 0 || strip->len == 1) { + if (strip->is_effect() || strip->len == 1) { content_start = seq::time_left_handle_frame_get(scene, strip); content_end = seq::time_right_handle_frame_get(scene, strip); } diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 2d6b3f2cac5..2fadd1898e9 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -267,7 +267,7 @@ typedef struct Strip { /** Frame offset from start/end of video file content to be ignored and invisible to the VSE. */ int anim_startofs, anim_endofs; - int blend_mode; /* StripType, but may be SEQ_BLEND_REPLACE */ + int blend_mode; /* StripBlendMode */ float blend_opacity; int8_t color_tag; /* StripColorTag */ @@ -301,6 +301,10 @@ typedef struct Strip { char _pad6[4]; StripRuntime runtime; + +#ifdef __cplusplus + bool is_effect() const; +#endif } Strip; typedef struct MetaStack { @@ -522,8 +526,7 @@ typedef enum eEffectTextAlignY { #define STRIP_FONT_NOT_LOADED -2 typedef struct ColorMixVars { - /** Value from STRIP_TYPE_XXX enumeration. */ - int blend_effect; + int blend_effect; /* StripBlendMode */ /** Blend factor [0.0f, 1.0f]. */ float factor; } ColorMixVars; @@ -795,7 +798,7 @@ typedef enum eStripAlphaMode { /** * #Strip.type * - * \warning #STRIP_TYPE_EFFECT BIT is used to determine if this is an effect strip! + * Note: update #Strip::is_effect when adding new effect types. */ typedef enum StripType { STRIP_TYPE_IMAGE = 0, @@ -807,7 +810,6 @@ typedef enum StripType { STRIP_TYPE_MOVIECLIP = 6, STRIP_TYPE_MASK = 7, - STRIP_TYPE_EFFECT = 8, STRIP_TYPE_CROSS = 8, STRIP_TYPE_ADD = 9, STRIP_TYPE_SUB = 10, @@ -815,9 +817,9 @@ typedef enum StripType { STRIP_TYPE_ALPHAUNDER = 12, STRIP_TYPE_GAMCROSS = 13, STRIP_TYPE_MUL = 14, - STRIP_TYPE_OVERDROP_REMOVED = - 15, /* Removed (behavior was the same as alpha-over), only used when reading old files. */ - /* STRIP_TYPE_PLUGIN = 24, */ /* Deprecated */ + /* Removed (behavior was the same as alpha-over), only used when reading old files. */ + STRIP_TYPE_OVERDROP_REMOVED = 15, + /* STRIP_TYPE_PLUGIN = 24, */ /* Removed */ STRIP_TYPE_WIPE = 25, STRIP_TYPE_GLOW = 26, STRIP_TYPE_TRANSFORM = 27, @@ -828,28 +830,6 @@ typedef enum StripType { STRIP_TYPE_GAUSSIAN_BLUR = 40, STRIP_TYPE_TEXT = 41, STRIP_TYPE_COLORMIX = 42, - - /* Blend modes */ - STRIP_TYPE_SCREEN = 43, - STRIP_TYPE_LIGHTEN = 44, - STRIP_TYPE_DODGE = 45, - STRIP_TYPE_DARKEN = 46, - STRIP_TYPE_COLOR_BURN = 47, - STRIP_TYPE_LINEAR_BURN = 48, - STRIP_TYPE_OVERLAY = 49, - STRIP_TYPE_HARD_LIGHT = 50, - STRIP_TYPE_SOFT_LIGHT = 51, - STRIP_TYPE_PIN_LIGHT = 52, - STRIP_TYPE_LIN_LIGHT = 53, - STRIP_TYPE_VIVID_LIGHT = 54, - STRIP_TYPE_HUE = 55, - STRIP_TYPE_SATURATION = 56, - STRIP_TYPE_VALUE = 57, - STRIP_TYPE_BLEND_COLOR = 58, - STRIP_TYPE_DIFFERENCE = 59, - STRIP_TYPE_EXCLUSION = 60, - - STRIP_TYPE_MAX = 60, } StripType; typedef enum eStripMovieClipFlag { @@ -857,13 +837,38 @@ typedef enum eStripMovieClipFlag { SEQ_MOVIECLIP_RENDER_STABILIZED = 1 << 1, } eStripMovieClipFlag; -enum { - SEQ_BLEND_REPLACE = 0, - /* All other BLEND_MODEs are simple STRIP_TYPE_EFFECT ids and therefore identical - * to the table above. (Only those effects that handle _exactly_ two inputs, - * otherwise, you can't really blend, right :) !) - */ -}; +typedef enum StripBlendMode { + STRIP_BLEND_REPLACE = 0, + + STRIP_BLEND_CROSS = 8, + STRIP_BLEND_ADD = 9, + STRIP_BLEND_SUB = 10, + STRIP_BLEND_ALPHAOVER = 11, + STRIP_BLEND_ALPHAUNDER = 12, + STRIP_BLEND_GAMCROSS = 13, + STRIP_BLEND_MUL = 14, + /* Removed (behavior was the same as alpha-over), only used when reading old files. */ + STRIP_BLEND_OVERDROP_REMOVED = 15, + + STRIP_BLEND_SCREEN = 43, + STRIP_BLEND_LIGHTEN = 44, + STRIP_BLEND_DODGE = 45, + STRIP_BLEND_DARKEN = 46, + STRIP_BLEND_COLOR_BURN = 47, + STRIP_BLEND_LINEAR_BURN = 48, + STRIP_BLEND_OVERLAY = 49, + STRIP_BLEND_HARD_LIGHT = 50, + STRIP_BLEND_SOFT_LIGHT = 51, + STRIP_BLEND_PIN_LIGHT = 52, + STRIP_BLEND_LIN_LIGHT = 53, + STRIP_BLEND_VIVID_LIGHT = 54, + STRIP_BLEND_HUE = 55, + STRIP_BLEND_SATURATION = 56, + STRIP_BLEND_VALUE = 57, + STRIP_BLEND_BLEND_COLOR = 58, + STRIP_BLEND_DIFFERENCE = 59, + STRIP_BLEND_EXCLUSION = 60, +} StripBlendMode; #define STRIP_HAS_PATH(_strip) \ (ELEM((_strip)->type, \ diff --git a/source/blender/makesrna/intern/rna_sequencer.cc b/source/blender/makesrna/intern/rna_sequencer.cc index 92595a0d2fa..f6f75799252 100644 --- a/source/blender/makesrna/intern/rna_sequencer.cc +++ b/source/blender/makesrna/intern/rna_sequencer.cc @@ -2132,38 +2132,38 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) } static const EnumPropertyItem blend_mode_items[] = { - {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, - {STRIP_TYPE_CROSS, "CROSS", 0, "Cross", ""}, + {STRIP_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, + {STRIP_BLEND_CROSS, "CROSS", 0, "Cross", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_DARKEN, "DARKEN", 0, "Darken", ""}, - {STRIP_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""}, - {STRIP_TYPE_COLOR_BURN, "BURN", 0, "Color Burn", ""}, - {STRIP_TYPE_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""}, + {STRIP_BLEND_DARKEN, "DARKEN", 0, "Darken", ""}, + {STRIP_BLEND_MUL, "MULTIPLY", 0, "Multiply", ""}, + {STRIP_BLEND_COLOR_BURN, "BURN", 0, "Color Burn", ""}, + {STRIP_BLEND_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, - {STRIP_TYPE_SCREEN, "SCREEN", 0, "Screen", ""}, - {STRIP_TYPE_DODGE, "DODGE", 0, "Color Dodge", ""}, - {STRIP_TYPE_ADD, "ADD", 0, "Add", ""}, + {STRIP_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, + {STRIP_BLEND_SCREEN, "SCREEN", 0, "Screen", ""}, + {STRIP_BLEND_DODGE, "DODGE", 0, "Color Dodge", ""}, + {STRIP_BLEND_ADD, "ADD", 0, "Add", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_OVERLAY, "OVERLAY", 0, "Overlay", ""}, - {STRIP_TYPE_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, - {STRIP_TYPE_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""}, - {STRIP_TYPE_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""}, - {STRIP_TYPE_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, - {STRIP_TYPE_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""}, + {STRIP_BLEND_OVERLAY, "OVERLAY", 0, "Overlay", ""}, + {STRIP_BLEND_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, + {STRIP_BLEND_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""}, + {STRIP_BLEND_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""}, + {STRIP_BLEND_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {STRIP_BLEND_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, - {STRIP_TYPE_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""}, - {STRIP_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""}, + {STRIP_BLEND_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, + {STRIP_BLEND_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""}, + {STRIP_BLEND_SUB, "SUBTRACT", 0, "Subtract", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_HUE, "HUE", 0, "Hue", ""}, - {STRIP_TYPE_SATURATION, "SATURATION", 0, "Saturation", ""}, - {STRIP_TYPE_BLEND_COLOR, "COLOR", 0, "Color", ""}, - {STRIP_TYPE_VALUE, "VALUE", 0, "Value", ""}, + {STRIP_BLEND_HUE, "HUE", 0, "Hue", ""}, + {STRIP_BLEND_SATURATION, "SATURATION", 0, "Saturation", ""}, + {STRIP_BLEND_BLEND_COLOR, "COLOR", 0, "Color", ""}, + {STRIP_BLEND_VALUE, "VALUE", 0, "Value", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, - {STRIP_TYPE_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, - {STRIP_TYPE_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {STRIP_BLEND_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, + {STRIP_BLEND_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, + {STRIP_BLEND_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -3659,31 +3659,31 @@ static void rna_def_text(StructRNA *srna) static void rna_def_color_mix(StructRNA *srna) { static const EnumPropertyItem blend_color_items[] = { - {STRIP_TYPE_DARKEN, "DARKEN", 0, "Darken", ""}, - {STRIP_TYPE_MUL, "MULTIPLY", 0, "Multiply", ""}, - {STRIP_TYPE_COLOR_BURN, "BURN", 0, "Color Burn", ""}, - {STRIP_TYPE_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""}, + {STRIP_BLEND_DARKEN, "DARKEN", 0, "Darken", ""}, + {STRIP_BLEND_MUL, "MULTIPLY", 0, "Multiply", ""}, + {STRIP_BLEND_COLOR_BURN, "BURN", 0, "Color Burn", ""}, + {STRIP_BLEND_LINEAR_BURN, "LINEAR_BURN", 0, "Linear Burn", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, - {STRIP_TYPE_SCREEN, "SCREEN", 0, "Screen", ""}, - {STRIP_TYPE_DODGE, "DODGE", 0, "Color Dodge", ""}, - {STRIP_TYPE_ADD, "ADD", 0, "Add", ""}, + {STRIP_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, + {STRIP_BLEND_SCREEN, "SCREEN", 0, "Screen", ""}, + {STRIP_BLEND_DODGE, "DODGE", 0, "Color Dodge", ""}, + {STRIP_BLEND_ADD, "ADD", 0, "Add", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_OVERLAY, "OVERLAY", 0, "Overlay", ""}, - {STRIP_TYPE_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, - {STRIP_TYPE_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""}, - {STRIP_TYPE_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""}, - {STRIP_TYPE_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, - {STRIP_TYPE_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""}, + {STRIP_BLEND_OVERLAY, "OVERLAY", 0, "Overlay", ""}, + {STRIP_BLEND_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""}, + {STRIP_BLEND_HARD_LIGHT, "HARD_LIGHT", 0, "Hard Light", ""}, + {STRIP_BLEND_VIVID_LIGHT, "VIVID_LIGHT", 0, "Vivid Light", ""}, + {STRIP_BLEND_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""}, + {STRIP_BLEND_PIN_LIGHT, "PIN_LIGHT", 0, "Pin Light", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, - {STRIP_TYPE_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""}, - {STRIP_TYPE_SUB, "SUBTRACT", 0, "Subtract", ""}, + {STRIP_BLEND_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, + {STRIP_BLEND_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""}, + {STRIP_BLEND_SUB, "SUBTRACT", 0, "Subtract", ""}, RNA_ENUM_ITEM_SEPR, - {STRIP_TYPE_HUE, "HUE", 0, "Hue", ""}, - {STRIP_TYPE_SATURATION, "SATURATION", 0, "Saturation", ""}, - {STRIP_TYPE_BLEND_COLOR, "COLOR", 0, "Color", ""}, - {STRIP_TYPE_VALUE, "VALUE", 0, "Value", ""}, + {STRIP_BLEND_HUE, "HUE", 0, "Hue", ""}, + {STRIP_BLEND_SATURATION, "SATURATION", 0, "Saturation", ""}, + {STRIP_BLEND_BLEND_COLOR, "COLOR", 0, "Color", ""}, + {STRIP_BLEND_VALUE, "VALUE", 0, "Value", ""}, {0, nullptr, 0, nullptr, nullptr}, }; diff --git a/source/blender/sequencer/intern/cache/source_image_cache.cc b/source/blender/sequencer/intern/cache/source_image_cache.cc index d8d62d719da..31e5d544c15 100644 --- a/source/blender/sequencer/intern/cache/source_image_cache.cc +++ b/source/blender/sequencer/intern/cache/source_image_cache.cc @@ -136,9 +136,7 @@ ImBuf *source_image_cache_get(const RenderData *context, const Strip *strip, flo /* For effect and scene strips, check if the cached result matches our current * render resolution. If it does not, remove stale source entries for this strip. */ - if (res != nullptr && - ((strip->type & STRIP_TYPE_EFFECT) != 0 || strip->type == STRIP_TYPE_SCENE)) - { + if (res != nullptr && (strip->is_effect() || strip->type == STRIP_TYPE_SCENE)) { if (res->x != context->rectx || res->y != context->recty) { cache->remove_entry(strip); return nullptr; diff --git a/source/blender/sequencer/intern/effects/effects.cc b/source/blender/sequencer/intern/effects/effects.cc index aa072cb1c09..39966f52c1c 100644 --- a/source/blender/sequencer/intern/effects/effects.cc +++ b/source/blender/sequencer/intern/effects/effects.cc @@ -156,7 +156,7 @@ void get_default_fac_fade(const Scene *scene, const Strip *strip, float timeline *fac = math::clamp(*fac, 0.0f, 1.0f); } -EffectHandle effect_handle_get(int strip_type) +EffectHandle effect_handle_get(StripType strip_type) { EffectHandle rval; @@ -185,26 +185,6 @@ EffectHandle effect_handle_get(int strip_type) case STRIP_TYPE_MUL: mul_effect_get_handle(rval); break; - case STRIP_TYPE_SCREEN: - case STRIP_TYPE_OVERLAY: - case STRIP_TYPE_COLOR_BURN: - case STRIP_TYPE_LINEAR_BURN: - case STRIP_TYPE_DARKEN: - case STRIP_TYPE_LIGHTEN: - case STRIP_TYPE_DODGE: - case STRIP_TYPE_SOFT_LIGHT: - case STRIP_TYPE_HARD_LIGHT: - case STRIP_TYPE_PIN_LIGHT: - case STRIP_TYPE_LIN_LIGHT: - case STRIP_TYPE_VIVID_LIGHT: - case STRIP_TYPE_BLEND_COLOR: - case STRIP_TYPE_HUE: - case STRIP_TYPE_SATURATION: - case STRIP_TYPE_VALUE: - case STRIP_TYPE_DIFFERENCE: - case STRIP_TYPE_EXCLUSION: - blend_mode_effect_get_handle(rval); - break; case STRIP_TYPE_COLORMIX: color_mix_effect_get_handle(rval); break; @@ -241,6 +221,70 @@ EffectHandle effect_handle_get(int strip_type) case STRIP_TYPE_TEXT: text_effect_get_handle(rval); break; + default: + break; + } + + return rval; +} + +static EffectHandle effect_handle_for_blend_mode_get(StripBlendMode blend) +{ + EffectHandle rval; + + rval.init = init_noop; + rval.num_inputs = num_inputs_default; + rval.load = load_noop; + rval.free = free_noop; + rval.early_out = early_out_noop; + rval.get_default_fac = get_default_fac_noop; + rval.execute = nullptr; + rval.copy = nullptr; + + switch (blend) { + case STRIP_BLEND_CROSS: + cross_effect_get_handle(rval); + break; + case STRIP_BLEND_ADD: + add_effect_get_handle(rval); + break; + case STRIP_BLEND_SUB: + sub_effect_get_handle(rval); + break; + case STRIP_BLEND_ALPHAOVER: + alpha_over_effect_get_handle(rval); + break; + case STRIP_BLEND_ALPHAUNDER: + alpha_under_effect_get_handle(rval); + break; + case STRIP_BLEND_GAMCROSS: + gamma_cross_effect_get_handle(rval); + break; + case STRIP_BLEND_MUL: + mul_effect_get_handle(rval); + break; + case STRIP_BLEND_SCREEN: + case STRIP_BLEND_LIGHTEN: + case STRIP_BLEND_DODGE: + case STRIP_BLEND_DARKEN: + case STRIP_BLEND_COLOR_BURN: + case STRIP_BLEND_LINEAR_BURN: + case STRIP_BLEND_OVERLAY: + case STRIP_BLEND_HARD_LIGHT: + case STRIP_BLEND_SOFT_LIGHT: + case STRIP_BLEND_PIN_LIGHT: + case STRIP_BLEND_LIN_LIGHT: + case STRIP_BLEND_VIVID_LIGHT: + case STRIP_BLEND_HUE: + case STRIP_BLEND_SATURATION: + case STRIP_BLEND_VALUE: + case STRIP_BLEND_BLEND_COLOR: + case STRIP_BLEND_DIFFERENCE: + case STRIP_BLEND_EXCLUSION: + blend_mode_effect_get_handle(rval); + break; + default: + break; } return rval; @@ -250,8 +294,8 @@ EffectHandle strip_effect_handle_get(Strip *strip) { EffectHandle rval = {}; - if (strip->type & STRIP_TYPE_EFFECT) { - rval = effect_handle_get(strip->type); + if (strip->is_effect()) { + rval = effect_handle_get(StripType(strip->type)); if ((strip->runtime.flag & STRIP_EFFECT_NOT_LOADED) != 0) { rval.load(strip); strip->runtime.flag &= ~STRIP_EFFECT_NOT_LOADED; @@ -261,18 +305,18 @@ EffectHandle strip_effect_handle_get(Strip *strip) return rval; } -EffectHandle strip_effect_get_sequence_blend(Strip *strip) +EffectHandle strip_blend_mode_handle_get(Strip *strip) { EffectHandle rval = {}; - if (strip->blend_mode != 0) { + if (strip->blend_mode != STRIP_BLEND_REPLACE) { if ((strip->runtime.flag & STRIP_EFFECT_NOT_LOADED) != 0) { /* load the effect first */ - rval = effect_handle_get(strip->type); + rval = effect_handle_get(StripType(strip->type)); rval.load(strip); } - rval = effect_handle_get(strip->blend_mode); + rval = effect_handle_for_blend_mode_get(StripBlendMode(strip->blend_mode)); if ((strip->runtime.flag & STRIP_EFFECT_NOT_LOADED) != 0) { /* now load the blend and unset unloaded flag */ rval.load(strip); @@ -285,13 +329,11 @@ EffectHandle strip_effect_get_sequence_blend(Strip *strip) int effect_get_num_inputs(int strip_type) { - EffectHandle rval = effect_handle_get(strip_type); - - int count = rval.num_inputs(); - if (rval.execute) { - return count; + EffectHandle rval = effect_handle_get(StripType(strip_type)); + if (rval.execute == nullptr) { + return 0; } - return 0; + return rval.num_inputs(); } } // namespace blender::seq diff --git a/source/blender/sequencer/intern/effects/effects.hh b/source/blender/sequencer/intern/effects/effects.hh index c3ae0aa17cd..b5af7a0a3a1 100644 --- a/source/blender/sequencer/intern/effects/effects.hh +++ b/source/blender/sequencer/intern/effects/effects.hh @@ -24,7 +24,7 @@ struct Strip; namespace blender::seq { -EffectHandle strip_effect_get_sequence_blend(Strip *strip); +EffectHandle strip_blend_mode_handle_get(Strip *strip); /** * Build frame map when speed in mode #SEQ_SPEED_MULTIPLY is animated. * This is, because `target_frame` value is integrated over time. @@ -91,7 +91,7 @@ void get_default_fac_fade(const Scene *scene, float timeline_frame, float *fac); -EffectHandle effect_handle_get(int strip_type); +EffectHandle effect_handle_get(StripType strip_type); void add_effect_get_handle(EffectHandle &rval); void adjustment_effect_get_handle(EffectHandle &rval); diff --git a/source/blender/sequencer/intern/effects/vse_effect_blend.cc b/source/blender/sequencer/intern/effects/vse_effect_blend.cc index 7410f862cd0..a05b4f1b191 100644 --- a/source/blender/sequencer/intern/effects/vse_effect_blend.cc +++ b/source/blender/sequencer/intern/effects/vse_effect_blend.cc @@ -158,71 +158,75 @@ static void apply_blend_function( } } -static void do_blend_effect_float( - float fac, int64_t size, const float *rect1, const float *rect2, int btype, float *out) +static void do_blend_effect_float(float fac, + int64_t size, + const float *rect1, + const float *rect2, + StripBlendMode btype, + float *out) { switch (btype) { - case STRIP_TYPE_ADD: + case STRIP_BLEND_ADD: apply_blend_function(fac, size, rect1, rect2, out, blend_color_add_float); break; - case STRIP_TYPE_SUB: + case STRIP_BLEND_SUB: apply_blend_function(fac, size, rect1, rect2, out, blend_color_sub_float); break; - case STRIP_TYPE_MUL: + case STRIP_BLEND_MUL: apply_blend_function(fac, size, rect1, rect2, out, blend_color_mul_float); break; - case STRIP_TYPE_DARKEN: + case STRIP_BLEND_DARKEN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_darken_float); break; - case STRIP_TYPE_COLOR_BURN: + case STRIP_BLEND_COLOR_BURN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_burn_float); break; - case STRIP_TYPE_LINEAR_BURN: + case STRIP_BLEND_LINEAR_BURN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_linearburn_float); break; - case STRIP_TYPE_SCREEN: + case STRIP_BLEND_SCREEN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_screen_float); break; - case STRIP_TYPE_LIGHTEN: + case STRIP_BLEND_LIGHTEN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_lighten_float); break; - case STRIP_TYPE_DODGE: + case STRIP_BLEND_DODGE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_dodge_float); break; - case STRIP_TYPE_OVERLAY: + case STRIP_BLEND_OVERLAY: apply_blend_function(fac, size, rect1, rect2, out, blend_color_overlay_float); break; - case STRIP_TYPE_SOFT_LIGHT: + case STRIP_BLEND_SOFT_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_softlight_float); break; - case STRIP_TYPE_HARD_LIGHT: + case STRIP_BLEND_HARD_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_hardlight_float); break; - case STRIP_TYPE_PIN_LIGHT: + case STRIP_BLEND_PIN_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_pinlight_float); break; - case STRIP_TYPE_LIN_LIGHT: + case STRIP_BLEND_LIN_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_linearlight_float); break; - case STRIP_TYPE_VIVID_LIGHT: + case STRIP_BLEND_VIVID_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_vividlight_float); break; - case STRIP_TYPE_BLEND_COLOR: + case STRIP_BLEND_BLEND_COLOR: apply_blend_function(fac, size, rect1, rect2, out, blend_color_color_float); break; - case STRIP_TYPE_HUE: + case STRIP_BLEND_HUE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_hue_float); break; - case STRIP_TYPE_SATURATION: + case STRIP_BLEND_SATURATION: apply_blend_function(fac, size, rect1, rect2, out, blend_color_saturation_float); break; - case STRIP_TYPE_VALUE: + case STRIP_BLEND_VALUE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_luminosity_float); break; - case STRIP_TYPE_DIFFERENCE: + case STRIP_BLEND_DIFFERENCE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_difference_float); break; - case STRIP_TYPE_EXCLUSION: + case STRIP_BLEND_EXCLUSION: apply_blend_function(fac, size, rect1, rect2, out, blend_color_exclusion_float); break; default: @@ -230,71 +234,75 @@ static void do_blend_effect_float( } } -static void do_blend_effect_byte( - float fac, int64_t size, const uchar *rect1, const uchar *rect2, int btype, uchar *out) +static void do_blend_effect_byte(float fac, + int64_t size, + const uchar *rect1, + const uchar *rect2, + StripBlendMode btype, + uchar *out) { switch (btype) { - case STRIP_TYPE_ADD: + case STRIP_BLEND_ADD: apply_blend_function(fac, size, rect1, rect2, out, blend_color_add_byte); break; - case STRIP_TYPE_SUB: + case STRIP_BLEND_SUB: apply_blend_function(fac, size, rect1, rect2, out, blend_color_sub_byte); break; - case STRIP_TYPE_MUL: + case STRIP_BLEND_MUL: apply_blend_function(fac, size, rect1, rect2, out, blend_color_mul_byte); break; - case STRIP_TYPE_DARKEN: + case STRIP_BLEND_DARKEN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_darken_byte); break; - case STRIP_TYPE_COLOR_BURN: + case STRIP_BLEND_COLOR_BURN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_burn_byte); break; - case STRIP_TYPE_LINEAR_BURN: + case STRIP_BLEND_LINEAR_BURN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_linearburn_byte); break; - case STRIP_TYPE_SCREEN: + case STRIP_BLEND_SCREEN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_screen_byte); break; - case STRIP_TYPE_LIGHTEN: + case STRIP_BLEND_LIGHTEN: apply_blend_function(fac, size, rect1, rect2, out, blend_color_lighten_byte); break; - case STRIP_TYPE_DODGE: + case STRIP_BLEND_DODGE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_dodge_byte); break; - case STRIP_TYPE_OVERLAY: + case STRIP_BLEND_OVERLAY: apply_blend_function(fac, size, rect1, rect2, out, blend_color_overlay_byte); break; - case STRIP_TYPE_SOFT_LIGHT: + case STRIP_BLEND_SOFT_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_softlight_byte); break; - case STRIP_TYPE_HARD_LIGHT: + case STRIP_BLEND_HARD_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_hardlight_byte); break; - case STRIP_TYPE_PIN_LIGHT: + case STRIP_BLEND_PIN_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_pinlight_byte); break; - case STRIP_TYPE_LIN_LIGHT: + case STRIP_BLEND_LIN_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_linearlight_byte); break; - case STRIP_TYPE_VIVID_LIGHT: + case STRIP_BLEND_VIVID_LIGHT: apply_blend_function(fac, size, rect1, rect2, out, blend_color_vividlight_byte); break; - case STRIP_TYPE_BLEND_COLOR: + case STRIP_BLEND_BLEND_COLOR: apply_blend_function(fac, size, rect1, rect2, out, blend_color_color_byte); break; - case STRIP_TYPE_HUE: + case STRIP_BLEND_HUE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_hue_byte); break; - case STRIP_TYPE_SATURATION: + case STRIP_BLEND_SATURATION: apply_blend_function(fac, size, rect1, rect2, out, blend_color_saturation_byte); break; - case STRIP_TYPE_VALUE: + case STRIP_BLEND_VALUE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_luminosity_byte); break; - case STRIP_TYPE_DIFFERENCE: + case STRIP_BLEND_DIFFERENCE: apply_blend_function(fac, size, rect1, rect2, out, blend_color_difference_byte); break; - case STRIP_TYPE_EXCLUSION: + case STRIP_BLEND_EXCLUSION: apply_blend_function(fac, size, rect1, rect2, out, blend_color_exclusion_byte); break; default: @@ -312,7 +320,7 @@ struct BlendModeEffectOp { do_blend_effect_byte(this->factor, size, src1, src2, this->blend_mode, dst); } } - int blend_mode; /* STRIP_TYPE_ */ + StripBlendMode blend_mode; float factor; }; @@ -326,7 +334,7 @@ static ImBuf *do_blend_mode_effect(const RenderData *context, ImBuf *dst = prepare_effect_imbufs(context, src1, src2); BlendModeEffectOp op; op.factor = fac; - op.blend_mode = strip->blend_mode; + op.blend_mode = StripBlendMode(strip->blend_mode); apply_effect_op(op, src1, src2, dst); return dst; } @@ -343,7 +351,7 @@ static void init_colormix_effect(Strip *strip) ColorMixVars *data = MEM_callocN("colormixvars"); strip->effectdata = data; - data->blend_effect = STRIP_TYPE_OVERLAY; + data->blend_effect = STRIP_BLEND_OVERLAY; data->factor = 1.0f; } @@ -357,7 +365,7 @@ static ImBuf *do_colormix_effect(const RenderData *context, ImBuf *dst = prepare_effect_imbufs(context, src1, src2); const ColorMixVars *data = static_cast(strip->effectdata); BlendModeEffectOp op; - op.blend_mode = data->blend_effect; + op.blend_mode = StripBlendMode(data->blend_effect); op.factor = data->factor; apply_effect_op(op, src1, src2, dst); return dst; diff --git a/source/blender/sequencer/intern/iterator.cc b/source/blender/sequencer/intern/iterator.cc index 9cb21d2b93b..a7246b0f35b 100644 --- a/source/blender/sequencer/intern/iterator.cc +++ b/source/blender/sequencer/intern/iterator.cc @@ -186,13 +186,11 @@ static bool must_render_strip(const VectorSet &strips, Strip *strip) bool strip_have_effect_in_stack = false; for (Strip *strip_iter : strips) { /* Strips is below another strip with replace blending are not rendered. */ - if (strip_iter->blend_mode == SEQ_BLEND_REPLACE && strip->channel < strip_iter->channel) { + if (strip_iter->blend_mode == STRIP_BLEND_REPLACE && strip->channel < strip_iter->channel) { return false; } - if ((strip_iter->type & STRIP_TYPE_EFFECT) != 0 && - relation_is_effect_of_strip(strip_iter, strip)) - { + if (strip_iter->is_effect() && relation_is_effect_of_strip(strip_iter, strip)) { /* Strips in same channel or higher than its effect are rendered. */ if (strip->channel >= strip_iter->channel) { return true; @@ -203,7 +201,7 @@ static bool must_render_strip(const VectorSet &strips, Strip *strip) } /* All non-generator effects are rendered (with respect to conditions above). */ - if ((strip->type & STRIP_TYPE_EFFECT) != 0 && effect_get_num_inputs(strip->type) != 0) { + if (strip->is_effect() && effect_get_num_inputs(strip->type) != 0) { return true; } @@ -265,7 +263,7 @@ void query_strip_effect_chain(const Scene *scene, r_strips.add(reference_strip); /* Find all input strips for `reference_strip`. */ - if (reference_strip->type & STRIP_TYPE_EFFECT) { + if (reference_strip->is_effect()) { if (reference_strip->input1) { query_strip_effect_chain(scene, reference_strip->input1, seqbase, r_strips); } diff --git a/source/blender/sequencer/intern/render.cc b/source/blender/sequencer/intern/render.cc index 0a94f13d88f..66f9c496ab8 100644 --- a/source/blender/sequencer/intern/render.cc +++ b/source/blender/sequencer/intern/render.cc @@ -402,7 +402,7 @@ static bool seq_input_have_to_preprocess(const RenderData *context, mul = strip->mul; - if (strip->blend_mode == SEQ_BLEND_REPLACE) { + if (strip->blend_mode == STRIP_BLEND_REPLACE) { mul *= strip->blend_opacity / 100.0f; } @@ -432,8 +432,7 @@ static bool seq_need_scale_to_render_size(const Strip *strip, bool is_proxy_imag if (is_proxy_image) { return false; } - if ((strip->type & STRIP_TYPE_EFFECT) != 0 || strip->type == STRIP_TYPE_MASK || - strip->type == STRIP_TYPE_META || + if (strip->is_effect() || strip->type == STRIP_TYPE_MASK || strip->type == STRIP_TYPE_META || (strip->type == STRIP_TYPE_SCENE && ((strip->flag & SEQ_SCENE_STRIPS) != 0))) { return false; @@ -682,7 +681,7 @@ static ImBuf *input_preprocess(const RenderData *context, } float mul = strip->mul; - if (strip->blend_mode == SEQ_BLEND_REPLACE) { + if (strip->blend_mode == STRIP_BLEND_REPLACE) { mul *= strip->blend_opacity / 100.0f; } @@ -712,7 +711,7 @@ static ImBuf *seq_render_preprocess_ibuf(const RenderData *context, } /* Proxies and non-generator effect strips are not stored in cache. */ - const bool is_effect_with_inputs = (strip->type & STRIP_TYPE_EFFECT) != 0 && + const bool is_effect_with_inputs = strip->is_effect() && (effect_get_num_inputs(strip->type) != 0 || (strip->type == STRIP_TYPE_ADJUSTMENT)); if (!is_proxy_image && !is_effect_with_inputs) { @@ -1658,20 +1657,14 @@ static ImBuf *do_render_strip_uncached(const RenderData *context, { ImBuf *ibuf = nullptr; float frame_index = give_frame_index(context->scene, strip, timeline_frame); - int type = (strip->type & STRIP_TYPE_EFFECT) ? STRIP_TYPE_EFFECT : strip->type; - switch (type) { - case STRIP_TYPE_META: { - ibuf = do_render_strip_seqbase(context, state, strip, frame_index); - break; - } - - case STRIP_TYPE_SCENE: { - if (strip->flag & SEQ_SCENE_STRIPS) { - if (strip->scene && (context->scene != strip->scene)) { - /* recursive check */ - if (BLI_linklist_index(state->scene_parents, strip->scene) != -1) { - break; - } + if (strip->type == STRIP_TYPE_META) { + ibuf = do_render_strip_seqbase(context, state, strip, frame_index); + } + else if (strip->type == STRIP_TYPE_SCENE) { + if (strip->flag & SEQ_SCENE_STRIPS) { + if (strip->scene && (context->scene != strip->scene)) { + /* recursive check */ + if (BLI_linklist_index(state->scene_parents, strip->scene) == -1) { LinkNode scene_parent{}; scene_parent.next = state->scene_parents; scene_parent.link = strip->scene; @@ -1690,53 +1683,40 @@ static ImBuf *do_render_strip_uncached(const RenderData *context, state->scene_parents = state->scene_parents->next; } } - else { - /* scene can be nullptr after deletions */ - ibuf = seq_render_scene_strip(context, strip, frame_index, timeline_frame); + } + else { + /* scene can be nullptr after deletions */ + ibuf = seq_render_scene_strip(context, strip, frame_index, timeline_frame); + } + } + else if (strip->is_effect()) { + ibuf = seq_render_effect_strip_impl(context, state, strip, timeline_frame); + } + else if (strip->type == STRIP_TYPE_IMAGE) { + ibuf = seq_render_image_strip(context, strip, timeline_frame, r_is_proxy_image); + } + else if (strip->type == STRIP_TYPE_MOVIE) { + ibuf = seq_render_movie_strip(context, strip, timeline_frame, r_is_proxy_image); + } + else if (strip->type == STRIP_TYPE_MOVIECLIP) { + ibuf = seq_render_movieclip_strip( + context, strip, round_fl_to_int(frame_index), r_is_proxy_image); + + if (ibuf) { + /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */ + ImBuf *i = IMB_dupImBuf(ibuf); + IMB_freeImBuf(ibuf); + ibuf = i; + + if (ibuf->float_buffer.data) { + seq_imbuf_to_sequencer_space(context->scene, ibuf, false); } - - break; - } - - case STRIP_TYPE_EFFECT: { - ibuf = seq_render_effect_strip_impl(context, state, strip, timeline_frame); - break; - } - - case STRIP_TYPE_IMAGE: { - ibuf = seq_render_image_strip(context, strip, timeline_frame, r_is_proxy_image); - break; - } - - case STRIP_TYPE_MOVIE: { - ibuf = seq_render_movie_strip(context, strip, timeline_frame, r_is_proxy_image); - break; - } - - case STRIP_TYPE_MOVIECLIP: { - ibuf = seq_render_movieclip_strip( - context, strip, round_fl_to_int(frame_index), r_is_proxy_image); - - if (ibuf) { - /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */ - ImBuf *i = IMB_dupImBuf(ibuf); - IMB_freeImBuf(ibuf); - ibuf = i; - - if (ibuf->float_buffer.data) { - seq_imbuf_to_sequencer_space(context->scene, ibuf, false); - } - } - - break; - } - - case STRIP_TYPE_MASK: { - /* ibuf is always new */ - ibuf = seq_render_mask_strip(context, strip, frame_index); - break; } } + else if (strip->type == STRIP_TYPE_MASK) { + /* ibuf is always new */ + ibuf = seq_render_mask_strip(context, strip, frame_index); + } if (ibuf) { seq_imbuf_assign_spaces(context->scene, ibuf); @@ -1784,12 +1764,12 @@ ImBuf *seq_render_strip(const RenderData *context, static bool seq_must_swap_input_in_blend_mode(Strip *strip) { - return ELEM(strip->blend_mode, STRIP_TYPE_ALPHAOVER, STRIP_TYPE_ALPHAUNDER); + return ELEM(strip->blend_mode, STRIP_BLEND_ALPHAOVER, STRIP_BLEND_ALPHAUNDER); } static StripEarlyOut strip_get_early_out_for_blend_mode(Strip *strip) { - EffectHandle sh = strip_effect_get_sequence_blend(strip); + EffectHandle sh = strip_blend_mode_handle_get(strip); float fac = strip->blend_opacity / 100.0f; StripEarlyOut early_out = sh.early_out(strip, fac); @@ -1812,7 +1792,7 @@ static ImBuf *seq_render_strip_stack_apply_effect( const RenderData *context, Strip *strip, float timeline_frame, ImBuf *ibuf1, ImBuf *ibuf2) { ImBuf *out; - EffectHandle sh = strip_effect_get_sequence_blend(strip); + EffectHandle sh = strip_blend_mode_handle_get(strip); BLI_assert(sh.execute != nullptr); float fac = strip->blend_opacity / 100.0f; int swap_input = seq_must_swap_input_in_blend_mode(strip); @@ -1829,7 +1809,7 @@ static ImBuf *seq_render_strip_stack_apply_effect( static bool is_opaque_alpha_over(const Strip *strip) { - if (strip->blend_mode != STRIP_TYPE_ALPHAOVER) { + if (strip->blend_mode != STRIP_BLEND_ALPHAOVER) { return false; } if (strip->blend_opacity < 100.0f) { @@ -1871,7 +1851,7 @@ static ImBuf *seq_render_strip_stack(const RenderData *context, if (out) { break; } - if (strip->blend_mode == SEQ_BLEND_REPLACE) { + if (strip->blend_mode == STRIP_BLEND_REPLACE) { out = seq_render_strip(context, state, strip, timeline_frame); break; } diff --git a/source/blender/sequencer/intern/sequencer.cc b/source/blender/sequencer/intern/sequencer.cc index 73544bf6ff5..e76d608922b 100644 --- a/source/blender/sequencer/intern/sequencer.cc +++ b/source/blender/sequencer/intern/sequencer.cc @@ -154,10 +154,10 @@ Strip *strip_alloc(ListBase *lb, int timeline_frame, int channel, int type) strip->speed_factor = 1.0f; if (strip->type == STRIP_TYPE_ADJUSTMENT) { - strip->blend_mode = STRIP_TYPE_CROSS; + strip->blend_mode = STRIP_BLEND_CROSS; } else { - strip->blend_mode = STRIP_TYPE_ALPHAOVER; + strip->blend_mode = STRIP_BLEND_ALPHAOVER; } strip->data = seq_strip_alloc(type); @@ -186,7 +186,7 @@ static void seq_strip_free_ex(Scene *scene, relations_strip_free_anim(strip); - if (strip->type & STRIP_TYPE_EFFECT) { + if (strip->is_effect()) { EffectHandle sh = strip_effect_handle_get(strip); sh.free(strip, do_id_user); } @@ -324,7 +324,7 @@ void editing_free(Scene *scene, const bool do_id_user) static void seq_new_fix_links_recursive(Strip *strip, blender::Map strip_map) { - if (strip->type & STRIP_TYPE_EFFECT) { + if (strip->is_effect()) { strip->input1 = strip_map.lookup_default(strip->input1, strip->input1); strip->input2 = strip_map.lookup_default(strip->input2, strip->input2); } @@ -594,7 +594,7 @@ static Strip *strip_duplicate(Main *bmain, else if (strip->type == STRIP_TYPE_IMAGE) { strip_new->data->stripdata = static_cast(MEM_dupallocN(strip->data->stripdata)); } - else if (strip->type & STRIP_TYPE_EFFECT) { + else if (strip->is_effect()) { EffectHandle sh; sh = strip_effect_handle_get(strip); if (sh.copy) { @@ -903,7 +903,7 @@ static bool strip_read_data_cb(Strip *strip, void *user_data) BLO_read_struct(reader, Stereo3dFormat, &strip->stereo3d_format); - if (strip->type & STRIP_TYPE_EFFECT) { + if (strip->is_effect()) { strip->runtime.flag |= STRIP_EFFECT_NOT_LOADED; } @@ -1177,3 +1177,10 @@ ListBase *Editing::current_channels() const /* NOTE: Const correctness is non-existent with ListBase anyway. */ return &const_cast(this->channels); } + +bool Strip::is_effect() const +{ + return (this->type >= STRIP_TYPE_CROSS && this->type <= STRIP_TYPE_OVERDROP_REMOVED) || + (this->type >= STRIP_TYPE_WIPE && this->type <= STRIP_TYPE_ADJUSTMENT) || + (this->type >= STRIP_TYPE_GAUSSIAN_BLUR && this->type <= STRIP_TYPE_COLORMIX); +} diff --git a/source/blender/sequencer/intern/strip_add.cc b/source/blender/sequencer/intern/strip_add.cc index a0fb581d2fb..5c020fd184a 100644 --- a/source/blender/sequencer/intern/strip_add.cc +++ b/source/blender/sequencer/intern/strip_add.cc @@ -101,7 +101,7 @@ static void strip_add_set_name(Scene *scene, Strip *strip, LoadData *load_data) else if (strip->type == STRIP_TYPE_MASK) { edit_strip_name_set(scene, strip, load_data->mask->id.name + 2); } - else if ((strip->type & STRIP_TYPE_EFFECT) != 0) { + else if (strip->is_effect()) { edit_strip_name_set(scene, strip, strip_give_name(strip)); } else { /* Image, sound and movie. */ @@ -172,7 +172,7 @@ Strip *add_effect_strip(Scene *scene, ListBase *seqbase, LoadData *load_data) EffectHandle sh = strip_effect_handle_get(strip); sh.init(strip); - if (seq::effect_get_num_inputs(strip->type) != 0) { + if (effect_get_num_inputs(strip->type) != 0) { strip->input1 = load_data->effect.input1; strip->input2 = load_data->effect.input2; } diff --git a/source/blender/sequencer/intern/strip_edit.cc b/source/blender/sequencer/intern/strip_edit.cc index ed08dd4c13c..0eeee93f4b8 100644 --- a/source/blender/sequencer/intern/strip_edit.cc +++ b/source/blender/sequencer/intern/strip_edit.cc @@ -58,12 +58,12 @@ bool edit_strip_swap(Scene *scene, Strip *strip_a, Strip *strip_b, const char ** } /* disallow effects to swap with non-effects strips */ - if ((strip_a->type & STRIP_TYPE_EFFECT) != (strip_b->type & STRIP_TYPE_EFFECT)) { + if (strip_a->is_effect() != strip_b->is_effect()) { *r_error_str = N_("Strips were not compatible"); return false; } - if ((strip_a->type & STRIP_TYPE_EFFECT) && (strip_b->type & STRIP_TYPE_EFFECT)) { + if (strip_a->is_effect() && strip_b->is_effect()) { if (effect_get_num_inputs(strip_a->type) != effect_get_num_inputs(strip_b->type)) { *r_error_str = N_("Strips must have the same number of inputs"); return false; @@ -356,14 +356,14 @@ static bool seq_edit_split_effect_inputs_intersect(const Scene *scene, bool input_does_intersect = false; if (strip->input1) { input_does_intersect |= seq_edit_split_intersect_check(scene, strip->input1, timeline_frame); - if ((strip->input1->type & STRIP_TYPE_EFFECT) != 0) { + if (strip->input1->is_effect()) { input_does_intersect |= seq_edit_split_effect_inputs_intersect( scene, strip->input1, timeline_frame); } } if (strip->input2) { input_does_intersect |= seq_edit_split_intersect_check(scene, strip->input2, timeline_frame); - if ((strip->input1->type & STRIP_TYPE_EFFECT) != 0) { + if (strip->input2->is_effect()) { input_does_intersect |= seq_edit_split_effect_inputs_intersect( scene, strip->input2, timeline_frame); } @@ -382,7 +382,7 @@ static bool seq_edit_split_operation_permitted_check(const Scene *scene, *r_error = "Strip is locked."; return false; } - if ((strip->type & STRIP_TYPE_EFFECT) == 0) { + if (!strip->is_effect()) { continue; } if (!seq_edit_split_intersect_check(scene, strip, timeline_frame)) { diff --git a/source/blender/sequencer/intern/strip_lookup.cc b/source/blender/sequencer/intern/strip_lookup.cc index 6c151632595..3be6171ca23 100644 --- a/source/blender/sequencer/intern/strip_lookup.cc +++ b/source/blender/sequencer/intern/strip_lookup.cc @@ -57,7 +57,7 @@ static void strip_by_scene_lookup_build(Strip *strip, StripLookup *lookup) static void strip_lookup_build_effect(Strip *strip, StripLookup *lookup) { - if ((strip->type & STRIP_TYPE_EFFECT) == 0) { + if (!strip->is_effect()) { return; } diff --git a/source/blender/sequencer/intern/strip_time.cc b/source/blender/sequencer/intern/strip_time.cc index 70796d8048b..57c56017be6 100644 --- a/source/blender/sequencer/intern/strip_time.cc +++ b/source/blender/sequencer/intern/strip_time.cc @@ -56,7 +56,7 @@ float give_frame_index(const Scene *scene, const Strip *strip, float timeline_fr float end = time_content_end_frame_get(scene, strip) - 1; float frame_index_max = strip->len - 1; - if (strip->type & STRIP_TYPE_EFFECT) { + if (strip->is_effect()) { end = time_right_handle_frame_get(scene, strip); frame_index_max = end - sta; } @@ -575,7 +575,7 @@ static void strip_time_slip_strip_ex(const Scene *scene, /* Effects only have a start frame and a length, so unless we're inside * a meta strip, there's no need to do anything. */ - if (!recursed && (strip->type & STRIP_TYPE_EFFECT)) { + if (!recursed && strip->is_effect()) { return; } diff --git a/source/blender/sequencer/intern/strip_transform.cc b/source/blender/sequencer/intern/strip_transform.cc index a07bd6f550a..114a14fa0d2 100644 --- a/source/blender/sequencer/intern/strip_transform.cc +++ b/source/blender/sequencer/intern/strip_transform.cc @@ -44,7 +44,7 @@ bool transform_single_image_check(const Strip *strip) bool transform_strip_can_be_translated(const Strip *strip) { - return !(strip->type & STRIP_TYPE_EFFECT) || (effect_get_num_inputs(strip->type) == 0); + return !strip->is_effect() || (effect_get_num_inputs(strip->type) == 0); } bool transform_test_overlap(const Scene *scene, Strip *strip1, Strip *strip2) @@ -259,7 +259,7 @@ static blender::VectorSet extract_standalone_strips( blender::VectorSet standalone_strips; for (Strip *strip : transformed_strips) { - if ((strip->type & STRIP_TYPE_EFFECT) == 0 || strip->input1 == nullptr) { + if (!strip->is_effect() || strip->input1 == nullptr) { standalone_strips.add(strip); } } @@ -434,13 +434,13 @@ static void strip_transform_handle_overwrite_trim(Scene *scene, target, scene, seqbasep, query_strip_effect_chain); /* Expand collection by adding all target's children, effects and their children. */ - if ((target->type & STRIP_TYPE_EFFECT) != 0) { + if (target->is_effect()) { iterator_set_expand(scene, seqbasep, targets, query_strip_effect_chain); } /* Trim all non effects, that have influence on effect length which is overlapping. */ for (Strip *strip : targets) { - if ((strip->type & STRIP_TYPE_EFFECT) != 0 && effect_get_num_inputs(strip->type) > 0) { + if (strip->is_effect() && effect_get_num_inputs(strip->type) > 0) { continue; } if (overlap == STRIP_OVERLAP_LEFT_SIDE) { diff --git a/source/blender/sequencer/intern/utils.cc b/source/blender/sequencer/intern/utils.cc index fc528fa26b7..18e96b6a07a 100644 --- a/source/blender/sequencer/intern/utils.cc +++ b/source/blender/sequencer/intern/utils.cc @@ -170,7 +170,7 @@ const char *strip_give_name(const Strip *strip) const char *name = get_default_stripname_by_type(strip->type); if (!name) { - if (!(strip->type & STRIP_TYPE_EFFECT)) { + if (!strip->is_effect()) { return strip->data->dirpath; }