Cleanup: VSE: Add read/write callbacks to strip modifiers
This replaces the hardcoded function with modifier type callbacks to make it easier to customize the reading/writing for custom modifier data. No functional changes. Pull Request: https://projects.blender.org/blender/blender/pulls/145737
This commit is contained in:
@@ -57,6 +57,12 @@ struct StripModifierTypeInfo {
|
||||
|
||||
/** Register the panel types for the modifier's UI. */
|
||||
void (*panel_register)(ARegionType *region_type);
|
||||
|
||||
/* Callback to read custom strip modifier data. */
|
||||
void (*blend_write)(BlendWriter *writer, const StripModifierData *smd);
|
||||
|
||||
/* Callback to write custom strip modifier data. */
|
||||
void (*blend_read)(BlendDataReader *reader, StripModifierData *smd);
|
||||
};
|
||||
|
||||
void modifiers_init();
|
||||
|
||||
@@ -110,6 +110,8 @@ StripModifierTypeInfo seqModifierType_BrightContrast = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*apply*/ brightcontrast_apply,
|
||||
/*panel_register*/ brightcontrast_register,
|
||||
/*blend_write*/ nullptr,
|
||||
/*blend_read*/ nullptr,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -366,6 +366,8 @@ StripModifierTypeInfo seqModifierType_ColorBalance = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*apply*/ colorBalance_apply,
|
||||
/*panel_register*/ colorBalance_register,
|
||||
/*blend_write*/ nullptr,
|
||||
/*blend_read*/ nullptr,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -106,6 +106,18 @@ static void curves_register(ARegionType *region_type)
|
||||
modifier_panel_register(region_type, eSeqModifierType_Curves, curves_panel_draw);
|
||||
}
|
||||
|
||||
static void curves_write(BlendWriter *writer, const StripModifierData *smd)
|
||||
{
|
||||
const CurvesModifierData *cmd = reinterpret_cast<const CurvesModifierData *>(smd);
|
||||
BKE_curvemapping_blend_write(writer, &cmd->curve_mapping);
|
||||
}
|
||||
|
||||
static void curves_read(BlendDataReader *reader, StripModifierData *smd)
|
||||
{
|
||||
CurvesModifierData *cmd = reinterpret_cast<CurvesModifierData *>(smd);
|
||||
BKE_curvemapping_blend_read(reader, &cmd->curve_mapping);
|
||||
}
|
||||
|
||||
StripModifierTypeInfo seqModifierType_Curves = {
|
||||
/*idname*/ "Curves",
|
||||
/*name*/ CTX_N_(BLT_I18NCONTEXT_ID_SEQUENCE, "Curves"),
|
||||
@@ -116,6 +128,8 @@ StripModifierTypeInfo seqModifierType_Curves = {
|
||||
/*copy_data*/ curves_copy_data,
|
||||
/*apply*/ curves_apply,
|
||||
/*panel_register*/ curves_register,
|
||||
/*blend_write*/ curves_write,
|
||||
/*blend_read*/ curves_read,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -133,6 +133,18 @@ static void hue_correct_register(ARegionType *region_type)
|
||||
modifier_panel_register(region_type, eSeqModifierType_HueCorrect, hue_correct_panel_draw);
|
||||
}
|
||||
|
||||
static void hue_correct_write(BlendWriter *writer, const StripModifierData *smd)
|
||||
{
|
||||
const HueCorrectModifierData *hmd = reinterpret_cast<const HueCorrectModifierData *>(smd);
|
||||
BKE_curvemapping_blend_write(writer, &hmd->curve_mapping);
|
||||
}
|
||||
|
||||
static void hue_correct_read(BlendDataReader *reader, StripModifierData *smd)
|
||||
{
|
||||
HueCorrectModifierData *hmd = reinterpret_cast<HueCorrectModifierData *>(smd);
|
||||
BKE_curvemapping_blend_read(reader, &hmd->curve_mapping);
|
||||
}
|
||||
|
||||
StripModifierTypeInfo seqModifierType_HueCorrect = {
|
||||
/*idname*/ "HueCorrect",
|
||||
/*name*/ CTX_N_(BLT_I18NCONTEXT_ID_SEQUENCE, "Hue Correct"),
|
||||
@@ -143,6 +155,8 @@ StripModifierTypeInfo seqModifierType_HueCorrect = {
|
||||
/*copy_data*/ hue_correct_copy_data,
|
||||
/*apply*/ hue_correct_apply,
|
||||
/*panel_register*/ hue_correct_register,
|
||||
/*blend_write*/ hue_correct_write,
|
||||
/*blend_read*/ hue_correct_read,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -103,6 +103,8 @@ StripModifierTypeInfo seqModifierType_Mask = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*apply*/ maskmodifier_apply,
|
||||
/*panel_register*/ maskmodifier_register,
|
||||
/*blend_write*/ nullptr,
|
||||
/*blend_read*/ nullptr,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -24,6 +24,8 @@ StripModifierTypeInfo seqModifierType_None = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*apply*/ nullptr,
|
||||
/*panel_register*/ nullptr,
|
||||
/*blend_write*/ nullptr,
|
||||
/*blend_read*/ nullptr,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "BKE_colortools.hh"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLO_read_write.hh"
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "DNA_sequence_types.h"
|
||||
@@ -57,6 +60,25 @@ static void sound_equalizermodifier_register(ARegionType *region_type)
|
||||
region_type, eSeqModifierType_SoundEqualizer, sound_equalizermodifier_draw);
|
||||
}
|
||||
|
||||
static void sound_equalizermodifier_write(BlendWriter *writer, const StripModifierData *smd)
|
||||
{
|
||||
const SoundEqualizerModifierData *semd = reinterpret_cast<const SoundEqualizerModifierData *>(
|
||||
smd);
|
||||
LISTBASE_FOREACH (EQCurveMappingData *, eqcmd, &semd->graphics) {
|
||||
BLO_write_struct_by_name(writer, "EQCurveMappingData", eqcmd);
|
||||
BKE_curvemapping_blend_write(writer, &eqcmd->curve_mapping);
|
||||
}
|
||||
}
|
||||
|
||||
static void sound_equalizermodifier_read(BlendDataReader *reader, StripModifierData *smd)
|
||||
{
|
||||
SoundEqualizerModifierData *semd = reinterpret_cast<SoundEqualizerModifierData *>(smd);
|
||||
BLO_read_struct_list(reader, EQCurveMappingData, &semd->graphics);
|
||||
LISTBASE_FOREACH (EQCurveMappingData *, eqcmd, &semd->graphics) {
|
||||
BKE_curvemapping_blend_read(reader, &eqcmd->curve_mapping);
|
||||
}
|
||||
}
|
||||
|
||||
StripModifierTypeInfo seqModifierType_SoundEqualizer = {
|
||||
/*idname*/ "SoundEqualizer",
|
||||
/*name*/ CTX_N_(BLT_I18NCONTEXT_ID_SEQUENCE, "Equalizer"),
|
||||
@@ -67,6 +89,8 @@ StripModifierTypeInfo seqModifierType_SoundEqualizer = {
|
||||
/*copy_data*/ sound_equalizermodifier_copy_data,
|
||||
/*apply*/ nullptr,
|
||||
/*panel_register*/ sound_equalizermodifier_register,
|
||||
/*blend_write*/ sound_equalizermodifier_write,
|
||||
/*blend_read*/ sound_equalizermodifier_read,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -388,6 +388,8 @@ StripModifierTypeInfo seqModifierType_Tonemap = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*apply*/ tonemapmodifier_apply,
|
||||
/*panel_register*/ tonemapmodifier_register,
|
||||
/*blend_write*/ nullptr,
|
||||
/*blend_read*/ nullptr,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -103,6 +103,8 @@ StripModifierTypeInfo seqModifierType_WhiteBalance = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*apply*/ whiteBalance_apply,
|
||||
/*panel_register*/ whiteBalance_register,
|
||||
/*blend_write*/ nullptr,
|
||||
/*blend_read*/ nullptr,
|
||||
};
|
||||
|
||||
}; // namespace blender::seq
|
||||
|
||||
@@ -624,23 +624,8 @@ void modifier_blend_write(BlendWriter *writer, ListBase *modbase)
|
||||
|
||||
if (smti) {
|
||||
BLO_write_struct_by_name(writer, smti->struct_name, smd);
|
||||
|
||||
if (smd->type == eSeqModifierType_Curves) {
|
||||
CurvesModifierData *cmd = (CurvesModifierData *)smd;
|
||||
|
||||
BKE_curvemapping_blend_write(writer, &cmd->curve_mapping);
|
||||
}
|
||||
else if (smd->type == eSeqModifierType_HueCorrect) {
|
||||
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
|
||||
|
||||
BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping);
|
||||
}
|
||||
else if (smd->type == eSeqModifierType_SoundEqualizer) {
|
||||
SoundEqualizerModifierData *semd = (SoundEqualizerModifierData *)smd;
|
||||
LISTBASE_FOREACH (EQCurveMappingData *, eqcmd, &semd->graphics) {
|
||||
BLO_write_struct_by_name(writer, "EQCurveMappingData", eqcmd);
|
||||
BKE_curvemapping_blend_write(writer, &eqcmd->curve_mapping);
|
||||
}
|
||||
if (smti->blend_write) {
|
||||
smti->blend_write(writer, smd);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -658,22 +643,9 @@ void modifier_blend_read_data(BlendDataReader *reader, ListBase *lb)
|
||||
BLO_read_struct(reader, Strip, &smd->mask_strip);
|
||||
}
|
||||
|
||||
if (smd->type == eSeqModifierType_Curves) {
|
||||
CurvesModifierData *cmd = (CurvesModifierData *)smd;
|
||||
|
||||
BKE_curvemapping_blend_read(reader, &cmd->curve_mapping);
|
||||
}
|
||||
else if (smd->type == eSeqModifierType_HueCorrect) {
|
||||
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
|
||||
|
||||
BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping);
|
||||
}
|
||||
else if (smd->type == eSeqModifierType_SoundEqualizer) {
|
||||
SoundEqualizerModifierData *semd = (SoundEqualizerModifierData *)smd;
|
||||
BLO_read_struct_list(reader, EQCurveMappingData, &semd->graphics);
|
||||
LISTBASE_FOREACH (EQCurveMappingData *, eqcmd, &semd->graphics) {
|
||||
BKE_curvemapping_blend_read(reader, &eqcmd->curve_mapping);
|
||||
}
|
||||
const StripModifierTypeInfo *smti = modifier_type_info_get(smd->type);
|
||||
if (smti && smti->blend_read) {
|
||||
smti->blend_read(reader, smd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user