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:
authorRichard Antalik <richardantalik@gmail.com>2021-05-07 11:25:13 +0300
committerRichard Antalik <richardantalik@gmail.com>2021-05-07 11:26:39 +0300
commit700fe73560fb4fef9238910d0b49782d4e44795a (patch)
treea3f4793ad0329aa5c4f4c0b3efb69e1330a1c48c /source/blender/sequencer/SEQ_iterator.h
parent232b10f6633ea68f55125c45b7b24451a3102551 (diff)
VSE: New iterator design
This iterator design provides means to create simple and flexible API to query and work with collection of strips. It should be used in cases when conditions require multiple stages of recursive iteration of all strips or similar complex scenarios. Quick API overview: Basic queries are standalone functions that return SeqCollection Use SEQ_collection_create() and SEQ_collection_free() to construct such query functions. Use these functions to get strips of known conditions, like selected strips, movie strips, muted strips and so on. Use SEQ_reference_query() when querying strips with relation to some reference strip. For example to get its effects, strips that have same type or use same input file and so on. These aren't standalone functions because often you need to query strips relative to each strip in collection. Use SEQ_collection_expand() to query strips relative to each strip in collection. These will be merged to original collection. Use SEQ_collection_merge() to merge 2 collections To iterate collection elements use macro SEQ_ITERATOR_FOREACH() This API is quite specific, but I think it is best suited for tasks that are usualy solved in sequencer codebase. Old sequencer iterator has been completely removed. SEQ_ALL_BEGIN and SEQ_ALL_END macros re-use new iterator design. As initial use for this iterator select_grouped_effect_link() function has been rewritten. It was not only broken, but also it used DNA fields to aid iterating strips. Reviewed By: sergey Differential Revision: https://developer.blender.org/D10337
Diffstat (limited to 'source/blender/sequencer/SEQ_iterator.h')
-rw-r--r--source/blender/sequencer/SEQ_iterator.h61
1 files changed, 45 insertions, 16 deletions
diff --git a/source/blender/sequencer/SEQ_iterator.h b/source/blender/sequencer/SEQ_iterator.h
index b34f0558c56..7517c941c80 100644
--- a/source/blender/sequencer/SEQ_iterator.h
+++ b/source/blender/sequencer/SEQ_iterator.h
@@ -27,33 +27,62 @@
extern "C" {
#endif
+#include "BLI_ghash.h"
+
struct Editing;
struct Sequence;
+struct GSet;
+struct GSetIterator;
-typedef struct SeqIterator {
- struct Sequence **array;
- int tot, cur;
+#define SEQ_ITERATOR_FOREACH(var, collection) \
+ for (SeqIterator iter = {NULL}; SEQ_iterator_ensure(collection, &iter, &var) && var != NULL; \
+ var = SEQ_iterator_yield(&iter))
- struct Sequence *seq;
- int valid;
-} SeqIterator;
-
-#define SEQ_ALL_BEGIN(ed, _seq) \
+#define SEQ_ALL_BEGIN(ed, var) \
{ \
- SeqIterator iter_macro; \
- for (SEQ_iterator_begin(ed, &iter_macro, false); iter_macro.valid; \
- SEQ_iterator_next(&iter_macro)) { \
- _seq = iter_macro.seq;
+ SeqCollection *all_strips = SEQ_query_all_strips_recursive(&ed->seqbase); \
+ GSetIterator gsi; \
+ GSET_ITER (gsi, all_strips->set) { \
+ var = (Sequence *)(BLI_gsetIterator_getKey(&gsi));
#define SEQ_ALL_END \
} \
- SEQ_iterator_end(&iter_macro); \
+ SEQ_collection_free(all_strips); \
} \
((void)0)
-void SEQ_iterator_begin(struct Editing *ed, SeqIterator *iter, const bool use_current_sequences);
-void SEQ_iterator_next(SeqIterator *iter);
-void SEQ_iterator_end(SeqIterator *iter);
+typedef struct SeqCollection {
+ struct SeqCollection *next, *prev;
+ struct GSet *set;
+} SeqCollection;
+
+typedef struct SeqIterator {
+ GSetIterator gsi;
+ SeqCollection *collection;
+ bool iterator_initialized;
+} SeqIterator;
+
+bool SEQ_iterator_ensure(SeqCollection *collection,
+ SeqIterator *iterator,
+ struct Sequence **r_seq);
+struct Sequence *SEQ_iterator_yield(SeqIterator *iterator);
+
+SeqCollection *SEQ_collection_create(void);
+bool SEQ_collection_append_strip(struct Sequence *seq, SeqCollection *data);
+void SEQ_collection_free(SeqCollection *data);
+void SEQ_collection_merge(SeqCollection *collection_dst, SeqCollection *collection_src);
+void SEQ_collection_expand(struct ListBase *seqbase,
+ SeqCollection *collection,
+ void query_func(struct Sequence *seq_reference,
+ struct ListBase *seqbase,
+ SeqCollection *collection));
+SeqCollection *SEQ_query_by_reference(struct Sequence *seq_reference,
+ struct ListBase *seqbase,
+ void seq_query_func(struct Sequence *seq_reference,
+ struct ListBase *seqbase,
+ SeqCollection *collection));
+SeqCollection *SEQ_query_selected_strips(struct ListBase *seqbase);
+SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase);
#ifdef __cplusplus
}