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/blenkernel/intern/ipo.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/blenkernel/intern/ipo.c')
-rw-r--r--source/blender/blenkernel/intern/ipo.c100
1 files changed, 54 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 8a70f065e40..aac081991e3 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -2038,6 +2038,58 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips)
}
}
+typedef struct Seq_callback_data {
+ Main *bmain;
+ Scene *scene;
+ AnimData *adt;
+} Seq_callback_data;
+
+static bool seq_convert_callback(Sequence *seq, void *userdata)
+{
+ IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
+ short adrcode = SEQ_FAC1;
+
+ if (G.debug & G_DEBUG) {
+ printf("\tconverting sequence strip %s\n", seq->name + 2);
+ }
+
+ if (ELEM(NULL, seq->ipo, icu)) {
+ seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
+ return true;
+ }
+
+ /* patch adrcode, so that we can map
+ * to different DNA variables later
+ * (semi-hack (tm) )
+ */
+ switch (seq->type) {
+ case SEQ_TYPE_IMAGE:
+ case SEQ_TYPE_META:
+ case SEQ_TYPE_SCENE:
+ case SEQ_TYPE_MOVIE:
+ case SEQ_TYPE_COLOR:
+ adrcode = SEQ_FAC_OPACITY;
+ break;
+ case SEQ_TYPE_SPEED:
+ adrcode = SEQ_FAC_SPEED;
+ break;
+ }
+ icu->adrcode = adrcode;
+
+ Seq_callback_data *cd = (Seq_callback_data *)userdata;
+
+ /* convert IPO */
+ ipo_to_animdata(cd->bmain, (ID *)cd->scene, seq->ipo, NULL, NULL, seq);
+
+ if (cd->adt->action) {
+ cd->adt->action->idroot = ID_SCE; /* scene-rooted */
+ }
+
+ id_us_min(&seq->ipo->id);
+ seq->ipo = NULL;
+ return true;
+}
+
/* *************************************************** */
/* External API - Only Called from do_versions() */
@@ -2286,52 +2338,8 @@ void do_versions_ipos_to_animato(Main *bmain)
Scene *scene = (Scene *)id;
Editing *ed = scene->ed;
if (ed && ed->seqbasep) {
- Sequence *seq;
-
- AnimData *adt = BKE_animdata_ensure_id(id);
-
- SEQ_ALL_BEGIN (ed, seq) {
- IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL;
- short adrcode = SEQ_FAC1;
-
- if (G.debug & G_DEBUG) {
- printf("\tconverting sequence strip %s\n", seq->name + 2);
- }
-
- if (ELEM(NULL, seq->ipo, icu)) {
- seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
- continue;
- }
-
- /* patch adrcode, so that we can map
- * to different DNA variables later
- * (semi-hack (tm) )
- */
- switch (seq->type) {
- case SEQ_TYPE_IMAGE:
- case SEQ_TYPE_META:
- case SEQ_TYPE_SCENE:
- case SEQ_TYPE_MOVIE:
- case SEQ_TYPE_COLOR:
- adrcode = SEQ_FAC_OPACITY;
- break;
- case SEQ_TYPE_SPEED:
- adrcode = SEQ_FAC_SPEED;
- break;
- }
- icu->adrcode = adrcode;
-
- /* convert IPO */
- ipo_to_animdata(bmain, (ID *)scene, seq->ipo, NULL, NULL, seq);
-
- if (adt->action) {
- adt->action->idroot = ID_SCE; /* scene-rooted */
- }
-
- id_us_min(&seq->ipo->id);
- seq->ipo = NULL;
- }
- SEQ_ALL_END;
+ Seq_callback_data cb_data = {bmain, scene, BKE_animdata_ensure_id(id)};
+ SEQ_for_each_callback(&ed->seqbase, seq_convert_callback, &cb_data);
}
}