diff options
author | Richard Antalik <richardantalik@gmail.com> | 2021-06-16 01:29:17 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2021-06-16 01:29:17 +0300 |
commit | 1a5fa2b319e06ebbd2666987aa11240a371dcc09 (patch) | |
tree | fa19d3c2f8b603e302b063a600e78f16733b5c5d /source/blender/makesrna/intern/rna_sequencer.c | |
parent | 143a81ccceaf7d3abccc5a9dd4bb3520813dd222 (diff) |
VSE: Improve animation evaluation performance
Use lookup string callback function for `sequences_all` RNA property
`rna_SequenceEditor_sequences_all_lookup_string` using a GHash for faster lookups.
When names are changed or strips are added/removed the lookup is tagged invalid.
The next time the lookup is used it will rebuild it.
Reviewed By: sergey, jbakker
Differential Revision: https://developer.blender.org/D11544
Diffstat (limited to 'source/blender/makesrna/intern/rna_sequencer.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 2652003cb1c..29100cd7658 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -94,6 +94,8 @@ const EnumPropertyItem rna_enum_sequence_modifier_type_items[] = { # include "IMB_imbuf.h" +# include "SEQ_edit.h" + typedef struct SequenceSearchData { Sequence *seq; void *data; @@ -243,6 +245,21 @@ static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *it iter->valid = (internal->link != NULL); } +static int rna_SequenceEditor_sequences_all_lookup_string(PointerRNA *ptr, + const char *key, + PointerRNA *r_ptr) +{ + ID *id = ptr->owner_id; + Scene *scene = (Scene *)id; + + Sequence *seq = SEQ_sequence_lookup_by_name(scene, key); + if (seq) { + RNA_pointer_create(ptr->owner_id, &RNA_Sequence, seq, r_ptr); + return true; + } + return false; +} + /* internal use */ static int rna_SequenceEditor_elements_length(PointerRNA *ptr) { @@ -627,11 +644,10 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value) BLI_strncpy(oldname, seq->name + 2, sizeof(seq->name) - 2); /* copy the new name into the name slot */ - BLI_strncpy_utf8(seq->name + 2, value, sizeof(seq->name) - 2); + SEQ_edit_sequence_name_set(scene, seq, value); /* make sure the name is unique */ - SEQ_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq); - + SEQ_sequence_base_unique_name_recursive(scene, &scene->ed->seqbase, seq); /* fix all the animation data which may link to this */ /* Don't rename everywhere because these are per scene. */ @@ -1997,7 +2013,7 @@ static void rna_def_editor(BlenderRNA *brna) NULL, NULL, NULL, - NULL, + "rna_SequenceEditor_sequences_all_lookup_string", NULL); prop = RNA_def_property(srna, "meta_stack", PROP_COLLECTION, PROP_NONE); |