Commit: dfa027fe09b53485802cb0d6224ffc6bbc058b87 Author: Jacques Lucke Date: Fri Nov 6 14:27:51 2020 +0100 Branches: master https://developer.blender.org/rBdfa027fe09b53485802cb0d6224ffc6bbc058b87
Refactor: move sequencer modifier .blend I/O to sequencer module Ref T76372. =================================================================== M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/writefile.c M source/blender/sequencer/CMakeLists.txt M source/blender/sequencer/SEQ_sequencer.h M source/blender/sequencer/intern/modifier.c =================================================================== diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ab6a178ec4d..727c2c02d2e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3859,15 +3859,6 @@ static void composite_patch(bNodeTree *ntree, Scene *scene) } } -static void lib_link_sequence_modifiers(BlendLibReader *reader, Scene *scene, ListBase *lb) -{ - LISTBASE_FOREACH (SequenceModifierData *, smd, lb) { - if (smd->mask_id) { - BLO_read_id_address(reader, scene->id.lib, &smd->mask_id); - } - } -} - /* check for cyclic set-scene, * libs can cause this case which is normally prevented, see (T#####) */ #define USE_SETSCENE_CHECK @@ -4020,7 +4011,7 @@ static void lib_link_scene(BlendLibReader *reader, Scene *sce) } BLI_listbase_clear(&seq->anims); - lib_link_sequence_modifiers(reader, sce, &seq->modifiers); + BKE_sequence_modifier_blend_read_lib(reader, sce, &seq->modifiers); } SEQ_ALL_END; @@ -4124,28 +4115,6 @@ static void direct_link_paint_helper(BlendDataReader *reader, const Scene *scene } } -static void direct_link_sequence_modifiers(BlendDataReader *reader, ListBase *lb) -{ - BLO_read_list(reader, lb); - - LISTBASE_FOREACH (SequenceModifierData *, smd, lb) { - if (smd->mask_sequence) { - BLO_read_data_address(reader, &smd->mask_sequence); - } - - if (smd->type == seqModifierType_Curves) { - CurvesModifierData *cmd = (CurvesModifierData *)smd; - - BKE_curvemapping_blend_read(reader, &cmd->curve_mapping); - } - else if (smd->type == seqModifierType_HueCorrect) { - HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - - BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping); - } - } -} - static void direct_link_scene(BlendDataReader *reader, Scene *sce) { sce->depsgraph_hash = NULL; @@ -4292,7 +4261,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) BLO_read_data_address(reader, &seq->strip->color_balance); } - direct_link_sequence_modifiers(reader, &seq->modifiers); + BKE_sequence_modifier_blend_read_data(reader, &seq->modifiers); } SEQ_ALL_END; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e9cb115a2c5..0a431e8dda1 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1292,31 +1292,6 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address } } -static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase) -{ - LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) { - const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); - - if (smti) { - BLO_write_struct_by_name(writer, smti->struct_name, smd); - - if (smd->type == seqModifierType_Curves) { - CurvesModifierData *cmd = (CurvesModifierData *)smd; - - BKE_curvemapping_blend_write(writer, &cmd->curve_mapping); - } - else if (smd->type == seqModifierType_HueCorrect) { - HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - - BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping); - } - } - else { - BLO_write_struct(writer, SequenceModifierData, smd); - } - } -} - static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) { if (BLO_write_is_undo(writer)) { @@ -1467,7 +1442,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) IDP_BlendWrite(writer, seq->prop); } - write_sequence_modifiers(writer, &seq->modifiers); + BKE_sequence_modifier_blend_write(writer, &seq->modifiers); } SEQ_ALL_END; diff --git a/source/blender/sequencer/CMakeLists.txt b/source/blender/sequencer/CMakeLists.txt index 3841a6e6414..bc3bda8d5b2 100644 --- a/source/blender/sequencer/CMakeLists.txt +++ b/source/blender/sequencer/CMakeLists.txt @@ -23,6 +23,7 @@ set(INC intern ../blenkernel ../blenlib + ../blenloader ../blentranslation ../depsgraph ../imbuf @@ -33,6 +34,9 @@ set(INC ../windowmanager ../../../intern/atomic ../../../intern/guardedalloc + + # dna_type_offsets.h + ${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern ) set(INC_SYS @@ -72,3 +76,6 @@ if(WITH_AUDASPACE) endif() blender_add_lib(bf_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") + +# Needed so we can use dna_type_offsets.h. +add_dependencies(bf_blenkernel bf_dna) diff --git a/source/blender/sequencer/SEQ_sequencer.h b/source/blender/sequencer/SEQ_sequencer.h index d969b43bd50..edd88ba9195 100644 --- a/source/blender/sequencer/SEQ_sequencer.h +++ b/source/blender/sequencer/SEQ_sequencer.h @@ -44,6 +44,9 @@ struct StripElem; struct TextVars; struct bContext; struct bSound; +struct BlendWriter; +struct BlendDataReader; +struct BlendLibReader; /* Wipe effect */ enum { @@ -461,6 +464,12 @@ struct ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context, void BKE_sequence_modifier_list_copy(struct Sequence *seqn, struct Sequence *seq); int BKE_sequence_supports_modifiers(struct Sequence *seq); +void BKE_sequence_modifier_blend_write(struct BlendWriter *writer, struct ListBase *modbase); +void BKE_sequence_modifier_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb); +void BKE_sequence_modifier_blend_read_lib(struct BlendLibReader *reader, + struct Scene *scene, + struct ListBase *lb); + /* ********************************************************************** * seqeffects.c * diff --git a/source/blender/sequencer/intern/modifier.c b/source/blender/sequencer/intern/modifier.c index cb15028cc23..a7d4ce2801a 100644 --- a/source/blender/sequencer/intern/modifier.c +++ b/source/blender/sequencer/intern/modifier.c @@ -46,6 +46,8 @@ #include "SEQ_sequencer.h" +#include "BLO_read_write.h" + #include "render.h" #include "sequencer.h" @@ -1486,3 +1488,65 @@ int BKE_sequence_supports_modifiers(Sequence *seq) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name .blend File I/O + * \{ */ + +void BKE_sequence_modifier_blend_write(BlendWriter *writer, ListBase *modbase) +{ + LISTBASE_FOREACH (SequenceModifierData *, smd, modbase) { + const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); + + if (smti) { + BLO_write_struct_by_name(writer, smti->struct_name, smd); + + if (smd->type == seqModifierType_Curves) { + CurvesModifierData *cmd = (CurvesModifierData *)smd; + + BKE_curvemapping_blend_write(writer, &cmd->curve_mapping); + } + else if (smd->type == seqModifierType_HueCorrect) { + HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; + + BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping); + } + } + else { + BLO_write_struct(writer, SequenceModifierData, smd); + } + } +} + +void BKE_sequence_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb) +{ + BLO_read_list(reader, lb); + + LISTBASE_FOREACH (SequenceModifierData *, smd, lb) { + if (smd->mask_sequence) { + BLO_read_data_address(reader, &smd->mask_sequence); + } + + if (smd->type == seqModifierType_Curves) { + CurvesModifierData *cmd = (CurvesModifierData *)smd; + + BKE_curvemapping_blend_read(reader, &cmd->curve_mapping); + } + else if (smd->type == seqModifierType_HueCorrect) { + HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; + + BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping); + } + } +} + +void BKE_sequence_modifier_blend_read_lib(BlendLibReader *reader, Scene *scene, ListBase *lb) +{ + LISTBASE_FOREACH (SequenceModifierData *, smd, lb) { + if (smd->mask_id) { + BLO_read_id_address(reader, scene->id.lib, &smd->mask_id); + } + } +} + +/** \} */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs