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:
authorHans Goudey <h.goudey@me.com>2021-06-16 05:17:51 +0300
committerHans Goudey <h.goudey@me.com>2021-06-16 05:41:16 +0300
commit6fe76f602f76494ff93f8c9381a9d5f7522bef6f (patch)
tree5ded9a3dc3b69e138c6c591963d5fe2fe8ba1a68
parentf5dee9b7a5cb164cf6fee92ad0912f03f06df443 (diff)
parent0b0c7ca0177f790dfd431c22b4cd279fa402b61c (diff)
Merge branch 'master' into temp-spreadsheet-row-filter
-rw-r--r--source/blender/blenkernel/BKE_curve.h2
-rw-r--r--source/blender/blenkernel/intern/scene.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c2
-rw-r--r--source/blender/blenloader/intern/versioning_290.c53
-rw-r--r--source/blender/editors/include/ED_info.h4
-rw-r--r--source/blender/editors/space_info/info_stats.c82
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c2
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc5
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c1
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h7
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c24
-rw-r--r--source/blender/sequencer/CMakeLists.txt1
-rw-r--r--source/blender/sequencer/SEQ_edit.h2
-rw-r--r--source/blender/sequencer/SEQ_sequencer.h11
-rw-r--r--source/blender/sequencer/SEQ_utils.h4
-rw-r--r--source/blender/sequencer/intern/sequence_lookup.c161
-rw-r--r--source/blender/sequencer/intern/sequencer.c3
-rw-r--r--source/blender/sequencer/intern/strip_add.c34
-rw-r--r--source/blender/sequencer/intern/strip_edit.c9
-rw-r--r--source/blender/sequencer/intern/utils.c9
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
24 files changed, 368 insertions, 77 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index eb9c68f80ec..2687a5ea16c 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -156,7 +156,7 @@ struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu);
void BKE_curve_bevelList_free(struct ListBase *bev);
void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render);
-ListBase BKE_curve_bevel_make(const struct Curve *ob);
+ListBase BKE_curve_bevel_make(const struct Curve *curve);
void BKE_curve_forward_diff_bezier(
float q0, float q1, float q2, float q3, float *p, int it, int stride);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 86d4c03d51a..2a5a2bf93a1 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1145,6 +1145,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &ed->act_seq);
ed->cache = NULL;
ed->prefetch_job = NULL;
+ ed->runtime.sequence_lookup = NULL;
/* recursive link sequences, lb will be correctly initialized */
link_recurs_seq(reader, &ed->seqbase);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index cf8f45ca227..c9f0cb62fcb 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1785,7 +1785,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep)
{
for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) {
- SEQ_sequence_base_unique_name_recursive(&sce->ed->seqbase, seq);
+ SEQ_sequence_base_unique_name_recursive(sce, &sce->ed->seqbase, seq);
if (seq->seqbase.first != NULL) {
do_versions_seq_unique_name_all_strips(sce, &seq->seqbase);
}
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 7bee6e08e08..31b11c4f152 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -118,24 +118,38 @@ static bool can_use_proxy(const Sequence *seq, int psize)
}
/* image_size is width or height depending what RNA property is converted - X or Y. */
-static void seq_convert_transform_animation(const Scene *scene,
+static void seq_convert_transform_animation(const Sequence *seq,
+ const Scene *scene,
const char *path,
- const int image_size)
+ const int image_size,
+ const int scene_size)
{
if (scene->adt == NULL || scene->adt->action == NULL) {
return;
}
- FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
- if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
- BezTriple *bezt = fcu->bezt;
- for (int i = 0; i < fcu->totvert; i++, bezt++) {
- /* Same math as with old_image_center_*, but simplified. */
- bezt->vec[0][1] = image_size / 2 + bezt->vec[0][1] - scene->r.xsch / 2;
- bezt->vec[1][1] = image_size / 2 + bezt->vec[1][1] - scene->r.xsch / 2;
- bezt->vec[2][1] = image_size / 2 + bezt->vec[2][1] - scene->r.xsch / 2;
+ /* Hardcoded legacy bit-flags which has been removed. */
+ const uint32_t use_transform_flag = (1 << 16);
+ const uint32_t use_crop_flag = (1 << 17);
+
+ /* Convert offset animation, but only if crop is not used. */
+ if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) {
+ FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
+ if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
+ BezTriple *bezt = fcu->bezt;
+ for (int i = 0; i < fcu->totvert; i++, bezt++) {
+ /* Same math as with old_image_center_*, but simplified. */
+ bezt->vec[0][1] = (image_size - scene_size) / 2 + bezt->vec[0][1];
+ bezt->vec[1][1] = (image_size - scene_size) / 2 + bezt->vec[1][1];
+ bezt->vec[2][1] = (image_size - scene_size) / 2 + bezt->vec[2][1];
+ }
}
}
+ else { /* Else, remove offset animation. */
+ FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
+ BLI_remlink(&scene->adt->action->curves, fcu);
+ BKE_fcurve_free(fcu);
+ }
}
static void seq_convert_transform_crop(const Scene *scene,
@@ -232,18 +246,15 @@ static void seq_convert_transform_crop(const Scene *scene,
t->xofs = old_image_center_x - scene->r.xsch / 2;
t->yofs = old_image_center_y - scene->r.ysch / 2;
- /* Convert offset animation, but only if crop is not used. */
- if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) {
- char name_esc[(sizeof(seq->name) - 2) * 2], *path;
- BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc));
+ char name_esc[(sizeof(seq->name) - 2) * 2], *path;
+ BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc));
- path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
- seq_convert_transform_animation(scene, path, image_size_x);
- MEM_freeN(path);
- path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
- seq_convert_transform_animation(scene, path, image_size_y);
- MEM_freeN(path);
- }
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
+ seq_convert_transform_animation(seq, scene, path, image_size_x, scene->r.xsch);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
+ seq_convert_transform_animation(seq, scene, path, image_size_y, scene->r.ysch);
+ MEM_freeN(path);
seq->flag &= ~use_transform_flag;
seq->flag &= ~use_crop_flag;
diff --git a/source/blender/editors/include/ED_info.h b/source/blender/editors/include/ED_info.h
index 9ac6b6c1085..dde26c072d0 100644
--- a/source/blender/editors/include/ED_info.h
+++ b/source/blender/editors/include/ED_info.h
@@ -27,9 +27,10 @@ extern "C" {
#endif
struct Main;
+struct wmWindowManager;
/* info_stats.c */
-void ED_info_stats_clear(struct ViewLayer *view_layer);
+void ED_info_stats_clear(struct wmWindowManager *wm, struct ViewLayer *view_layer);
const char *ED_info_statusbar_string(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer);
@@ -41,6 +42,7 @@ const char *ED_info_statistics_string(struct Main *bmain,
void ED_info_draw_stats(struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,
+ struct View3D *v3d_local,
int x,
int *y,
int height);
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index ebdf32a1cdb..20d901a05bc 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -31,6 +31,7 @@
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
#include "DNA_windowmanager_types.h"
#include "BLF_api.h"
@@ -63,6 +64,8 @@
#include "ED_info.h"
+#include "WM_api.h"
+
#include "UI_resources.h"
#include "GPU_capabilities.h"
@@ -123,12 +126,19 @@ static bool stats_mesheval(Mesh *me_eval, bool is_selected, SceneStats *stats)
return true;
}
-static void stats_object(Object *ob, SceneStats *stats, GSet *objects_gset)
+static void stats_object(Object *ob,
+ const View3D *v3d_local,
+ SceneStats *stats,
+ GSet *objects_gset)
{
if ((ob->base_flag & BASE_VISIBLE_VIEWLAYER) == 0) {
return;
}
+ if (v3d_local && !BKE_object_is_visible_in_viewport(v3d_local, ob)) {
+ return;
+ }
+
const bool is_selected = (ob->base_flag & BASE_SELECTED) != 0;
stats->totobj++;
@@ -386,7 +396,7 @@ static void stats_object_sculpt(Object *ob, SceneStats *stats)
}
/* Statistics displayed in info header. Called regularly on scene changes. */
-static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer)
+static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer, View3D *v3d_local)
{
SceneStats stats = {0};
Object *ob = OBACT(view_layer);
@@ -400,6 +410,13 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer)
stats_object_edit(ob_iter, &stats);
stats.totobjsel++;
}
+ else {
+ /* Skip hidden objects in local view that are not in edit-mode,
+ * an exception for edit-mode, in other modes these would be considered hidden. */
+ if ((v3d_local && !BKE_object_is_visible_in_viewport(v3d_local, ob_iter))) {
+ continue;
+ }
+ }
stats.totobj++;
}
}
@@ -417,7 +434,7 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer)
/* Objects */
GSet *objects_gset = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN (depsgraph, ob_iter) {
- stats_object(ob_iter, &stats, objects_gset);
+ stats_object(ob_iter, v3d_local, &stats, objects_gset);
}
DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
BLI_gset_free(objects_gset, NULL);
@@ -429,38 +446,61 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer)
stats_object_sculpt(ob, &stats);
}
- if (!view_layer->stats) {
- view_layer->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
+ if (v3d_local) {
+ BLI_assert(v3d_local->localvd != NULL);
+ if (v3d_local->runtime.local_stats == NULL) {
+ v3d_local->runtime.local_stats = MEM_mallocN(sizeof(SceneStats), "LocalStats");
+ }
+ *v3d_local->runtime.local_stats = stats;
+ }
+ else {
+ if (!view_layer->stats) {
+ view_layer->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
+ }
+ *view_layer->stats = stats;
}
-
- *(view_layer->stats) = stats;
}
-void ED_info_stats_clear(ViewLayer *view_layer)
+void ED_info_stats_clear(wmWindowManager *wm, ViewLayer *view_layer)
{
if (view_layer->stats) {
MEM_freeN(view_layer->stats);
view_layer->stats = NULL;
}
+
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ ViewLayer *view_layer_test = WM_window_get_active_view_layer(win);
+ if (view_layer != view_layer_test) {
+ continue;
+ }
+ const bScreen *screen = WM_window_get_active_screen(win);
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ if (area->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = area->spacedata.first;
+ if (v3d->localvd) {
+ MEM_SAFE_FREE(v3d->runtime.local_stats);
+ }
+ }
+ }
+ }
}
-static bool format_stats(Main *bmain,
- Scene *scene,
- ViewLayer *view_layer,
- SceneStatsFmt *stats_fmt)
+static bool format_stats(
+ Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d_local, SceneStatsFmt *stats_fmt)
{
/* Create stats if they don't already exist. */
- if (!view_layer->stats) {
+ SceneStats **stats_p = (v3d_local) ? &v3d_local->runtime.local_stats : &view_layer->stats;
+ if (*stats_p == NULL) {
/* Do not not access dependency graph if interface is marked as locked. */
wmWindowManager *wm = bmain->wm.first;
if (wm->is_interface_locked) {
return false;
}
Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
- stats_update(depsgraph, view_layer);
+ stats_update(depsgraph, view_layer, v3d_local);
}
- SceneStats *stats = view_layer->stats;
+ SceneStats *stats = *stats_p;
/* Generate formatted numbers. */
#define SCENE_STATS_FMT_INT(_id) BLI_str_format_uint64_grouped(stats_fmt->_id, stats->_id)
@@ -605,7 +645,7 @@ static const char *info_statusbar_string(Main *bmain,
/* Scene statistics. */
if (statusbar_flag & STATUSBAR_SHOW_STATS) {
SceneStatsFmt stats_fmt;
- if (format_stats(bmain, scene, view_layer, &stats_fmt)) {
+ if (format_stats(bmain, scene, view_layer, NULL, &stats_fmt)) {
get_stats_string(info + ofs, len, &ofs, view_layer, &stats_fmt);
}
}
@@ -682,11 +722,17 @@ static void stats_row(int col1,
BLF_draw_default(col2, *y, 0.0f, values, sizeof(values));
}
+/**
+ * \param v3d_local: Pass this argument to calculate view-port local statistics.
+ * Note that this must only be used for local-view, otherwise report specific statistics
+ * will be written into the global scene statistics giving incorrect results.
+ */
void ED_info_draw_stats(
- Main *bmain, Scene *scene, ViewLayer *view_layer, int x, int *y, int height)
+ Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d_local, int x, int *y, int height)
{
+ BLI_assert(v3d_local == NULL || v3d_local->localvd != NULL);
SceneStatsFmt stats_fmt;
- if (!format_stats(bmain, scene, view_layer, &stats_fmt)) {
+ if (!format_stats(bmain, scene, view_layer, v3d_local, &stats_fmt)) {
return;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index b8134095492..42e2a2e5549 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1983,7 +1983,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
seqm->machine = active_seq ? active_seq->machine : channel_max;
strcpy(seqm->name + 2, "MetaStrip");
- SEQ_sequence_base_unique_name_recursive(&ed->seqbase, seqm);
+ SEQ_sequence_base_unique_name_recursive(scene, &ed->seqbase, seqm);
seqm->start = meta_start_frame;
seqm->len = meta_end_frame - meta_start_frame;
SEQ_time_update_sequence(scene, seqm);
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 7d36d4b1b7f..77248254d7b 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -276,11 +276,6 @@ void GeometryDataSource::apply_selection_filter(MutableSpan<bool> rows_included)
}
}
-bool InstancesDataSource::has_selection_filter() const
-{
- return false;
-}
-
void InstancesDataSource::foreach_default_column_ids(
FunctionRef<void(const SpreadsheetColumnID &)> fn) const
{
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 36901141497..d560c1f9978 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -331,6 +331,8 @@ static void view3d_free(SpaceLink *sl)
MEM_freeN(vd->localvd);
}
+ MEM_SAFE_FREE(vd->runtime.local_stats);
+
if (vd->runtime.properties_storage) {
MEM_freeN(vd->runtime.properties_storage);
}
@@ -346,6 +348,18 @@ static void view3d_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
{
}
+static void view3d_exit(wmWindowManager *UNUSED(wm), ScrArea *area)
+{
+ BLI_assert(area->spacetype == SPACE_VIEW3D);
+ View3D *v3d = area->spacedata.first;
+ /* Happens when freeing. */
+ if (v3d == NULL) {
+ return;
+ }
+
+ MEM_SAFE_FREE(v3d->runtime.local_stats);
+}
+
static SpaceLink *view3d_duplicate(SpaceLink *sl)
{
View3D *v3do = (View3D *)sl;
@@ -1581,7 +1595,7 @@ static void space_view3d_listener(const wmSpaceTypeListenerParams *params)
}
}
-static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(area))
+static void space_view3d_refresh(const bContext *C, ScrArea *area)
{
Scene *scene = CTX_data_scene(C);
LightCache *lcache = scene->eevee.light_cache_data;
@@ -1590,6 +1604,9 @@ static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(area))
lcache->flag &= ~LIGHTCACHE_UPDATE_AUTO;
view3d_lightcache_update((bContext *)C);
}
+
+ View3D *v3d = (View3D *)area->spacedata.first;
+ MEM_SAFE_FREE(v3d->runtime.local_stats);
}
const char *view3d_context_dir[] = {
@@ -1697,6 +1714,7 @@ void ED_spacetype_view3d(void)
st->create = view3d_create;
st->free = view3d_free;
st->init = view3d_init;
+ st->exit = view3d_exit;
st->listener = space_view3d_listener;
st->refresh = space_view3d_refresh;
st->duplicate = view3d_duplicate;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 4a595c716b6..0bc19887118 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1537,7 +1537,9 @@ void view3d_draw_region_info(const bContext *C, ARegion *region)
}
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 && (v3d->overlay.flag & V3D_OVERLAY_STATS)) {
- ED_info_draw_stats(bmain, scene, view_layer, xoffset, &yoffset, VIEW3D_OVERLAY_LINEHEIGHT);
+ View3D *v3d_local = v3d->localvd ? v3d : NULL;
+ ED_info_draw_stats(
+ bmain, scene, view_layer, v3d_local, xoffset, &yoffset, VIEW3D_OVERLAY_LINEHEIGHT);
}
BLF_batch_draw_end();
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 21cb8560e9b..f49b94280d6 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1393,6 +1393,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
MEM_freeN(v3d->localvd);
v3d->localvd = NULL;
+ MEM_SAFE_FREE(v3d->runtime.local_stats);
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 7e0bf81457d..fe793875d67 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -45,6 +45,7 @@ struct MovieClip;
struct Scene;
struct VFont;
struct bSound;
+struct SequenceLookup;
/* strlens; 256= FILE_MAXFILE, 768= FILE_MAXDIR */
@@ -257,6 +258,10 @@ typedef struct MetaStack {
int disp_range[2];
} MetaStack;
+typedef struct EditingRuntime {
+ struct SequenceLookup *sequence_lookup;
+} EditingRuntime;
+
typedef struct Editing {
/** Pointer to the current list of seq's being edited (can be within a meta strip). */
ListBase *seqbasep;
@@ -287,6 +292,8 @@ typedef struct Editing {
/* Must be initialized only by seq_cache_create() */
int64_t disk_cache_timestamp;
+
+ EditingRuntime runtime;
} Editing;
/* ************* Effect Variable Structs ********* */
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 2f4e4e57b9f..fa738c647bb 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -258,6 +258,8 @@ typedef struct View3D_Runtime {
int flag;
char _pad1[4];
+ /* Only used for overlay stats while in localview. */
+ struct SceneStats *local_stats;
} View3D_Runtime;
/** 3D ViewPort Struct. */
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);
diff --git a/source/blender/sequencer/CMakeLists.txt b/source/blender/sequencer/CMakeLists.txt
index 2b402b4750f..9340cfbf03d 100644
--- a/source/blender/sequencer/CMakeLists.txt
+++ b/source/blender/sequencer/CMakeLists.txt
@@ -79,6 +79,7 @@ set(SRC
intern/render.h
intern/sequencer.c
intern/sequencer.h
+ intern/sequence_lookup.c
intern/sound.c
intern/strip_add.c
intern/strip_edit.c
diff --git a/source/blender/sequencer/SEQ_edit.h b/source/blender/sequencer/SEQ_edit.h
index 2711e0a7ee3..6d043dffe72 100644
--- a/source/blender/sequencer/SEQ_edit.h
+++ b/source/blender/sequencer/SEQ_edit.h
@@ -58,6 +58,8 @@ bool SEQ_edit_remove_gaps(struct Scene *scene,
struct ListBase *seqbase,
const int initial_frame,
const bool remove_all_gaps);
+void SEQ_edit_sequence_name_set(struct Scene *scene, struct Sequence *seq, const char *new_name);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/sequencer/SEQ_sequencer.h b/source/blender/sequencer/SEQ_sequencer.h
index ad0815892f7..fd4181a5a54 100644
--- a/source/blender/sequencer/SEQ_sequencer.h
+++ b/source/blender/sequencer/SEQ_sequencer.h
@@ -33,6 +33,7 @@ struct Editing;
struct Scene;
struct Sequence;
struct SequencerToolSettings;
+struct SequenceLookup;
/* RNA enums, just to be more readable */
enum {
@@ -79,6 +80,16 @@ void SEQ_sequence_base_dupli_recursive(const struct Scene *scene_src,
int dupe_flag,
const int flag);
+/* Defined in sequence_lookup.c */
+
+typedef enum eSequenceLookupTag {
+ SEQ_LOOKUP_TAG_INVALID = (1 << 0),
+} eSequenceLookupTag;
+
+struct Sequence *SEQ_sequence_lookup_by_name(const struct Scene *scene, const char *key);
+void SEQ_sequence_lookup_free(const struct Scene *scene);
+void SEQ_sequence_lookup_tag(const struct Scene *scene, eSequenceLookupTag tag);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/sequencer/SEQ_utils.h b/source/blender/sequencer/SEQ_utils.h
index a4dc80d75db..432e8fdd0c0 100644
--- a/source/blender/sequencer/SEQ_utils.h
+++ b/source/blender/sequencer/SEQ_utils.h
@@ -36,7 +36,9 @@ struct Sequence;
struct StripElem;
void SEQ_sort(struct ListBase *seqbase);
-void SEQ_sequence_base_unique_name_recursive(struct ListBase *seqbasep, struct Sequence *seq);
+void SEQ_sequence_base_unique_name_recursive(struct Scene *scene,
+ struct ListBase *seqbasep,
+ struct Sequence *seq);
const char *SEQ_sequence_give_name(struct Sequence *seq);
struct ListBase *SEQ_get_seqbase_from_sequence(struct Sequence *seq, int *r_offset);
const struct Sequence *SEQ_get_topmost_sequence(const struct Scene *scene, int frame);
diff --git a/source/blender/sequencer/intern/sequence_lookup.c b/source/blender/sequencer/intern/sequence_lookup.c
new file mode 100644
index 00000000000..72567dc394e
--- /dev/null
+++ b/source/blender/sequencer/intern/sequence_lookup.c
@@ -0,0 +1,161 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup sequencer
+ */
+
+#include "SEQ_sequencer.h"
+
+#include "DNA_listBase.h"
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+
+#include "SEQ_iterator.h"
+
+#include "BLI_ghash.h"
+#include "BLI_string.h"
+#include "BLI_sys_types.h"
+#include "BLI_threads.h"
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+static ThreadMutex lookup_lock = BLI_MUTEX_INITIALIZER;
+
+typedef struct SequenceLookup {
+ GHash *by_name;
+ eSequenceLookupTag tag;
+} SequenceLookup;
+
+static void seq_sequence_lookup_init(struct SequenceLookup *lookup)
+{
+ lookup->by_name = BLI_ghash_str_new(__func__);
+ lookup->tag |= SEQ_LOOKUP_TAG_INVALID;
+}
+
+static void seq_sequence_lookup_build(const struct Scene *scene, struct SequenceLookup *lookup)
+{
+ SeqCollection *all_strips = SEQ_query_all_strips_recursive(&scene->ed->seqbase);
+ Sequence *seq;
+ SEQ_ITERATOR_FOREACH (seq, all_strips) {
+ BLI_ghash_insert(lookup->by_name, seq->name + 2, seq);
+ }
+ SEQ_collection_free(all_strips);
+ lookup->tag &= ~SEQ_LOOKUP_TAG_INVALID;
+}
+
+static SequenceLookup *seq_sequence_lookup_new(void)
+{
+ SequenceLookup *lookup = MEM_callocN(sizeof(SequenceLookup), __func__);
+ seq_sequence_lookup_init(lookup);
+ return lookup;
+}
+
+static void seq_sequence_lookup_free(struct SequenceLookup **lookup)
+{
+ if (*lookup == NULL) {
+ return;
+ }
+
+ BLI_ghash_free((*lookup)->by_name, NULL, NULL);
+ (*lookup)->by_name = NULL;
+ MEM_freeN(*lookup);
+ *lookup = NULL;
+}
+
+static void seq_sequence_lookup_rebuild(const struct Scene *scene, struct SequenceLookup **lookup)
+{
+ seq_sequence_lookup_free(lookup);
+ *lookup = seq_sequence_lookup_new();
+ seq_sequence_lookup_build(scene, *lookup);
+}
+
+static bool seq_sequence_lookup_is_valid(struct SequenceLookup *lookup)
+{
+ return (lookup->tag & SEQ_LOOKUP_TAG_INVALID) == 0;
+}
+
+static void seq_sequence_lookup_update_if_needed(const struct Scene *scene,
+ struct SequenceLookup **lookup)
+{
+ if (!scene->ed) {
+ return;
+ }
+ if (*lookup && seq_sequence_lookup_is_valid(*lookup)) {
+ return;
+ }
+
+ seq_sequence_lookup_rebuild(scene, lookup);
+}
+
+/**
+ * Free lookup hash data.
+ *
+ * \param scene: scene that owns lookup hash
+ */
+void SEQ_sequence_lookup_free(const Scene *scene)
+{
+ BLI_assert(scene->ed);
+ BLI_mutex_lock(&lookup_lock);
+ SequenceLookup *lookup = scene->ed->runtime.sequence_lookup;
+ seq_sequence_lookup_free(&lookup);
+ BLI_mutex_unlock(&lookup_lock);
+}
+
+/**
+ * Find a sequence with a given name.
+ * If lookup hash doesn't exist, it will be created. If hash is tagged as invalid, it will be
+ * rebuilt.
+ *
+ * \param scene: scene that owns lookup hash
+ * \param key: Sequence name without SQ prefix (seq->name + 2)
+ *
+ * \return pointer to Sequence
+ */
+Sequence *SEQ_sequence_lookup_by_name(const Scene *scene, const char *key)
+{
+ BLI_assert(scene->ed);
+ BLI_mutex_lock(&lookup_lock);
+ seq_sequence_lookup_update_if_needed(scene, &scene->ed->runtime.sequence_lookup);
+ SequenceLookup *lookup = scene->ed->runtime.sequence_lookup;
+ Sequence *seq = BLI_ghash_lookup(lookup->by_name, key);
+ BLI_mutex_unlock(&lookup_lock);
+ return seq;
+}
+
+/**
+ * Find a sequence with a given name.
+ *
+ * \param scene: scene that owns lookup hash
+ * \param tag: tag to set
+ */
+void SEQ_sequence_lookup_tag(const Scene *scene, eSequenceLookupTag tag)
+{
+ if (!scene->ed) {
+ return;
+ }
+
+ BLI_mutex_lock(&lookup_lock);
+ SequenceLookup *lookup = scene->ed->runtime.sequence_lookup;
+ if (lookup != NULL) {
+ lookup->tag |= tag;
+ }
+ BLI_mutex_unlock(&lookup_lock);
+}
diff --git a/source/blender/sequencer/intern/sequencer.c b/source/blender/sequencer/intern/sequencer.c
index d0bc41062a1..8cd67195c30 100644
--- a/source/blender/sequencer/intern/sequencer.c
+++ b/source/blender/sequencer/intern/sequencer.c
@@ -271,6 +271,7 @@ void SEQ_editing_free(Scene *scene, const bool do_id_user)
SEQ_ALL_END;
BLI_freelistN(&ed->metastack);
+ SEQ_sequence_lookup_free(scene);
MEM_freeN(ed);
scene->ed = NULL;
@@ -514,7 +515,7 @@ static Sequence *seq_dupli(const Scene *scene_src,
if (scene_src == scene_dst) {
if (dupe_flag & SEQ_DUPE_UNIQUE_NAME) {
- SEQ_sequence_base_unique_name_recursive(&scene_dst->ed->seqbase, seqn);
+ SEQ_sequence_base_unique_name_recursive(scene_dst, &scene_dst->ed->seqbase, seqn);
}
}
diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c
index 888220b7111..142991eeacf 100644
--- a/source/blender/sequencer/intern/strip_add.c
+++ b/source/blender/sequencer/intern/strip_add.c
@@ -56,6 +56,7 @@
#include "IMB_metadata.h"
#include "SEQ_add.h"
+#include "SEQ_edit.h"
#include "SEQ_effects.h"
#include "SEQ_relations.h"
#include "SEQ_render.h"
@@ -98,33 +99,32 @@ void SEQ_add_load_data_init(SeqLoadData *load_data,
static void seq_add_generic_update(Scene *scene, ListBase *seqbase, Sequence *seq)
{
- SEQ_sequence_base_unique_name_recursive(seqbase, seq);
+ SEQ_sequence_base_unique_name_recursive(scene, seqbase, seq);
SEQ_time_update_sequence_bounds(scene, seq);
SEQ_sort(seqbase);
SEQ_relations_invalidate_cache_composite(scene, seq);
}
-static void seq_add_set_name(Sequence *seq, SeqLoadData *load_data)
+static void seq_add_set_name(Scene *scene, Sequence *seq, SeqLoadData *load_data)
{
if (load_data->name[0] != '\0') {
- BLI_strncpy(seq->name + 2, load_data->name, sizeof(seq->name) - 2);
+ SEQ_edit_sequence_name_set(scene, seq, load_data->name);
}
else {
if (seq->type == SEQ_TYPE_SCENE) {
- BLI_strncpy(seq->name + 2, load_data->scene->id.name + 2, sizeof(seq->name) - 2);
+ SEQ_edit_sequence_name_set(scene, seq, load_data->scene->id.name + 2);
}
else if (seq->type == SEQ_TYPE_MOVIECLIP) {
- BLI_strncpy(seq->name + 2, load_data->clip->id.name + 2, sizeof(seq->name) - 2);
+ SEQ_edit_sequence_name_set(scene, seq, load_data->clip->id.name + 2);
}
else if (seq->type == SEQ_TYPE_MASK) {
- BLI_strncpy(seq->name + 2, load_data->mask->id.name + 2, sizeof(seq->name) - 2);
+ SEQ_edit_sequence_name_set(scene, seq, load_data->mask->id.name + 2);
}
else if ((seq->type & SEQ_TYPE_EFFECT) != 0) {
- BLI_strncpy(seq->name + 2, SEQ_sequence_give_name(seq), sizeof(seq->name) - 2);
+ SEQ_edit_sequence_name_set(scene, seq, SEQ_sequence_give_name(seq));
}
else { /* Image, sound and movie. */
- BLI_strncpy_utf8(seq->name + 2, load_data->name, sizeof(seq->name) - 2);
- BLI_utf8_invalid_strip(seq->name + 2, strlen(seq->name + 2));
+ SEQ_edit_sequence_name_set(scene, seq, load_data->name);
}
}
}
@@ -163,7 +163,7 @@ Sequence *SEQ_add_scene_strip(Scene *scene, ListBase *seqbase, struct SeqLoadDat
seq->scene = load_data->scene;
seq->len = load_data->scene->r.efra - load_data->scene->r.sfra + 1;
id_us_ensure_real((ID *)load_data->scene);
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
return seq;
}
@@ -184,7 +184,7 @@ Sequence *SEQ_add_movieclip_strip(Scene *scene, ListBase *seqbase, struct SeqLoa
seq->clip = load_data->clip;
seq->len = BKE_movieclip_get_duration(load_data->clip);
id_us_ensure_real((ID *)load_data->clip);
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
return seq;
}
@@ -205,7 +205,7 @@ Sequence *SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData
seq->mask = load_data->mask;
seq->len = BKE_mask_get_duration(load_data->mask);
id_us_ensure_real((ID *)load_data->mask);
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
return seq;
}
@@ -249,7 +249,7 @@ Sequence *SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, struct SeqLoadDa
}
SEQ_relations_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs SEQ_time_update_sequence. */
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
return seq;
@@ -364,7 +364,7 @@ Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
/* Set Last active directory. */
BLI_strncpy(scene->ed->act_imagedir, seq->strip->dir, sizeof(scene->ed->act_imagedir));
seq_add_set_view_transform(scene, seq, load_data);
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
return seq;
@@ -426,7 +426,7 @@ Sequence *SEQ_add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
/* Set Last active directory. */
BLI_strncpy(scene->ed->act_sounddir, strip->dir, FILE_MAXDIR);
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
return seq;
@@ -458,7 +458,7 @@ Sequence *SEQ_add_meta_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_
seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_META);
/* Set name. */
- seq_add_set_name(seqm, load_data);
+ seq_add_set_name(scene, seqm, load_data);
/* Set frames start and length. */
seqm->start = load_data->start_frame;
@@ -590,7 +590,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
seq_add_set_view_transform(scene, seq, load_data);
- seq_add_set_name(seq, load_data);
+ seq_add_set_name(scene, seq, load_data);
seq_add_generic_update(scene, seqbase, seq);
MEM_freeN(anim_arr);
diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c
index 4de6ec3583c..3e6eb74fcb3 100644
--- a/source/blender/sequencer/intern/strip_edit.c
+++ b/source/blender/sequencer/intern/strip_edit.c
@@ -30,6 +30,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_string_utf8.h"
#include "BLT_translation.h"
@@ -202,6 +203,7 @@ void SEQ_edit_remove_flagged_sequences(Scene *scene, ListBase *seqbase)
}
BLI_remlink(seqbase, seq);
SEQ_sequence_free(scene, seq, true);
+ SEQ_sequence_lookup_tag(scene, SEQ_LOOKUP_TAG_INVALID);
}
}
}
@@ -468,3 +470,10 @@ bool SEQ_edit_remove_gaps(Scene *scene,
}
return true;
}
+
+void SEQ_edit_sequence_name_set(Scene *scene, Sequence *seq, const char *new_name)
+{
+ BLI_strncpy_utf8(seq->name + 2, new_name, MAX_NAME - 2);
+ BLI_utf8_invalid_strip(seq->name + 2, strlen(seq->name + 2));
+ SEQ_sequence_lookup_tag(scene, SEQ_LOOKUP_TAG_INVALID);
+}
diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c
index 9aeb2961751..a287466dfb2 100644
--- a/source/blender/sequencer/intern/utils.c
+++ b/source/blender/sequencer/intern/utils.c
@@ -39,6 +39,7 @@
#include "BKE_main.h"
#include "BKE_scene.h"
+#include "SEQ_edit.h"
#include "SEQ_iterator.h"
#include "SEQ_relations.h"
#include "SEQ_select.h"
@@ -140,7 +141,9 @@ static int seqbase_unique_name_recursive_fn(Sequence *seq, void *arg_pt)
return 1;
}
-void SEQ_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
+void SEQ_sequence_base_unique_name_recursive(struct Scene *scene,
+ ListBase *seqbasep,
+ Sequence *seq)
{
SeqUniqueInfo sui;
char *dot;
@@ -167,7 +170,7 @@ void SEQ_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq)
SEQ_seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui);
}
- BLI_strncpy(seq->name + 2, sui.name_dest, sizeof(seq->name) - 2);
+ SEQ_edit_sequence_name_set(scene, seq, sui.name_dest);
}
static const char *give_seqname_by_type(int type)
@@ -629,7 +632,7 @@ void SEQ_ensure_unique_name(Sequence *seq, Scene *scene)
char name[SEQ_NAME_MAXSTR];
BLI_strncpy_utf8(name, seq->name + 2, sizeof(name));
- SEQ_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
+ SEQ_sequence_base_unique_name_recursive(scene, &scene->ed->seqbase, seq);
SEQ_dupe_animdata(scene, name, seq->name + 2);
if (seq->type == SEQ_TYPE_META) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index a6588c40f0f..43d4859945d 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -520,7 +520,7 @@ void wm_event_do_notifiers(bContext *C)
if (clear_info_stats) {
/* Only do once since adding notifiers is slow when there are many. */
ViewLayer *view_layer = CTX_data_view_layer(C);
- ED_info_stats_clear(view_layer);
+ ED_info_stats_clear(wm, view_layer);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
}