Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2021-08-20 17:30:34 +0300
committerSebastian Parborg <darkdefende@gmail.com>2021-08-25 18:30:39 +0300
commitf49d438ced7c5874dbf43976d9901a462176f541 (patch)
treefae7b745eaf1e793b53119f3ec27c34621727c58 /source/blender/blenloader/intern/versioning_260.c
parent796035ad930383c26302ab6a57e8e6c90394603b (diff)
Cleanup and remove SEQ_ALL_BEGIN macro
We now use a for_each function with callback to iterate through all sequences in the scene. This has the benefit that we now only loop over the sequences in the scene once. Before we would loop over them twice and allocate memory to store temporary data. The allocation of temporary data lead to unintentional memory leaks if the code used returns to exit out of the iteration loop. The new for_each callback method doesn't allocate any temporary data and only iterates though all sequences once. Reviewed By: Richard Antalik, Bastien Montagne Differential Revision: http://developer.blender.org/D12278
Diffstat (limited to 'source/blender/blenloader/intern/versioning_260.c')
-rw-r--r--source/blender/blenloader/intern/versioning_260.c96
1 files changed, 52 insertions, 44 deletions
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 7c644fa3b55..b71dd5a27bb 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -663,6 +663,53 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
}
}
+static bool seq_colorbalance_update_cb(Sequence *seq, void *UNUSED(user_data))
+{
+ Strip *strip = seq->strip;
+
+ if (strip && strip->color_balance) {
+ SequenceModifierData *smd;
+ ColorBalanceModifierData *cbmd;
+
+ smd = SEQ_modifier_new(seq, NULL, seqModifierType_ColorBalance);
+ cbmd = (ColorBalanceModifierData *)smd;
+
+ cbmd->color_balance = *strip->color_balance;
+
+ /* multiplication with color balance used is handled differently,
+ * so we need to move multiplication to modifier so files would be
+ * compatible
+ */
+ cbmd->color_multiply = seq->mul;
+ seq->mul = 1.0f;
+
+ MEM_freeN(strip->color_balance);
+ strip->color_balance = NULL;
+ }
+ return true;
+}
+
+static bool seq_set_alpha_mode_cb(Sequence *seq, void *UNUSED(user_data))
+{
+ enum { SEQ_MAKE_PREMUL = (1 << 6) };
+ if (seq->flag & SEQ_MAKE_PREMUL) {
+ seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
+ }
+ else {
+ SEQ_alpha_mode_from_file_extension(seq);
+ }
+ return true;
+}
+
+static bool seq_set_wipe_angle_cb(Sequence *seq, void *UNUSED(user_data))
+{
+ if (seq->type == SEQ_TYPE_WIPE) {
+ WipeVars *wv = seq->effectdata;
+ wv->angle = DEG2RADF(wv->angle);
+ }
+ return true;
+}
+
/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
@@ -1492,32 +1539,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (scene->ed) {
- Sequence *seq;
-
- SEQ_ALL_BEGIN (scene->ed, seq) {
- Strip *strip = seq->strip;
-
- if (strip && strip->color_balance) {
- SequenceModifierData *smd;
- ColorBalanceModifierData *cbmd;
-
- smd = SEQ_modifier_new(seq, NULL, seqModifierType_ColorBalance);
- cbmd = (ColorBalanceModifierData *)smd;
-
- cbmd->color_balance = *strip->color_balance;
-
- /* multiplication with color balance used is handled differently,
- * so we need to move multiplication to modifier so files would be
- * compatible
- */
- cbmd->color_multiply = seq->mul;
- seq->mul = 1.0f;
-
- MEM_freeN(strip->color_balance);
- strip->color_balance = NULL;
- }
- }
- SEQ_ALL_END;
+ SEQ_for_each_callback(&scene->ed->seqbase, seq_colorbalance_update_cb, NULL);
}
}
}
@@ -1807,18 +1829,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
Tex *tex;
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sequence *seq;
-
- SEQ_ALL_BEGIN (scene->ed, seq) {
- enum { SEQ_MAKE_PREMUL = (1 << 6) };
- if (seq->flag & SEQ_MAKE_PREMUL) {
- seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
- }
- else {
- SEQ_alpha_mode_from_file_extension(seq);
- }
+ if (scene->ed) {
+ SEQ_for_each_callback(&scene->ed->seqbase, seq_set_alpha_mode_cb, NULL);
}
- SEQ_ALL_END;
if (scene->r.bake_samples == 0) {
scene->r.bake_samples = 256;
@@ -2450,14 +2463,9 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
- Sequence *seq;
- SEQ_ALL_BEGIN (scene->ed, seq) {
- if (seq->type == SEQ_TYPE_WIPE) {
- WipeVars *wv = seq->effectdata;
- wv->angle = DEG2RADF(wv->angle);
- }
+ if (scene->ed) {
+ SEQ_for_each_callback(&scene->ed->seqbase, seq_set_wipe_angle_cb, NULL);
}
- SEQ_ALL_END;
}
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {