[Bf-blender-cvs] [6b8a5e78ded] soc-2021-vse-strip-thumbnails: Add changes requested in D12266
Aditya Y Jeppu
noreply at git.blender.org
Fri Sep 3 10:08:08 CEST 2021
Commit: 6b8a5e78ded37fa025df9e5b0d4f8758dda2b3a8
Author: Aditya Y Jeppu
Date: Thu Sep 2 21:58:33 2021 +0530
Branches: soc-2021-vse-strip-thumbnails
https://developer.blender.org/rB6b8a5e78ded37fa025df9e5b0d4f8758dda2b3a8
Add changes requested in D12266
===================================================================
M source/blender/blenkernel/BKE_blender_version.h
M source/blender/blenloader/intern/versioning_300.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/space_sequencer/sequencer_edit.c
M source/blender/editors/space_sequencer/space_sequencer.c
M source/blender/makesdna/DNA_space_types.h
M source/blender/sequencer/SEQ_render.h
M source/blender/sequencer/intern/image_cache.c
M source/blender/sequencer/intern/image_cache.h
M source/blender/sequencer/intern/render.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 5dc4ebaa7a4..e2788020628 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 20
+#define BLENDER_FILE_SUBVERSION 21
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 91c00abb9ce..e72bbf7aad2 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -958,7 +958,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
- sseq->flag |= SEQ_SHOW_GRID | SEQ_SHOW_THUMBNAILS;
+ sseq->flag |= SEQ_SHOW_GRID;
}
}
}
@@ -1111,6 +1111,32 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 20)) {
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ sseq->flag |= SEQ_SHOW_THUMBNAILS;
+ }
+ }
+ }
+ }
+ }
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 21)) {
+ LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ if (sl->spacetype == SPACE_SEQ) {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ sseq->flag |= SEQ_SHOW_THUMBNAILS;
+ }
+ }
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 47bb7ead93f..ef2f6fe7178 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1280,7 +1280,7 @@ static void draw_seq_fcurve_overlay(
typedef struct ThumbnailDrawJob {
SeqRenderData context;
- GHash *seqs;
+ GHash *sequences_ghash;
Scene *scene;
rctf *view_area;
float pixelx;
@@ -1302,7 +1302,7 @@ static void thumbnail_hash_data_free(void *val)
static void thumbnail_freejob(void *data)
{
ThumbnailDrawJob *tj = data;
- BLI_ghash_free(tj->seqs, NULL, thumbnail_hash_data_free);
+ BLI_ghash_free(tj->sequences_ghash, NULL, thumbnail_hash_data_free);
MEM_freeN(tj->view_area);
MEM_freeN(tj);
}
@@ -1334,13 +1334,13 @@ static bool check_seq_need_thumbnails(Sequence *seq, rctf *view_area)
return true;
}
-static void seq_thumbnail_get_frame_step(Sequence *seq,
- float pixelx,
- float pixely,
- float *r_thumb_w,
- float *r_thumb_h,
- float *r_image_x,
- float *r_image_y)
+static void seq_get_thumb_image_dimensions(Sequence *seq,
+ float pixelx,
+ float pixely,
+ float *r_thumb_width,
+ float *r_thumb_height,
+ float *r_image_width,
+ float *r_image_height)
{
float image_width = seq->strip->stripdata->orig_width;
float image_height = seq->strip->stripdata->orig_height;
@@ -1362,51 +1362,45 @@ static void seq_thumbnail_get_frame_step(Sequence *seq,
float thumb_h_px = thumb_height / pixely;
float thumb_width = aspect_ratio * thumb_h_px * pixelx;
- if (r_thumb_h == NULL) {
- *r_thumb_w = thumb_width;
+ if (r_thumb_height == NULL) {
+ *r_thumb_width = thumb_width;
return;
}
- *r_thumb_h = thumb_height;
- *r_image_x = image_width;
- *r_image_y = image_height;
- *r_thumb_w = thumb_width;
+ *r_thumb_height = thumb_height;
+ *r_image_width = image_width;
+ *r_image_height = image_height;
+ *r_thumb_width = thumb_width;
}
-static void seq_thumbnail_get_start_frame(Sequence *seq,
- float frame_step,
- rctf *view_area,
- float *r_start_frame)
+static float seq_thumbnail_get_start_frame(Sequence *seq, float frame_step, rctf *view_area)
{
if (seq->start > view_area->xmin && seq->start < view_area->xmax) {
- *r_start_frame = seq->start;
- return;
+ return seq->start;
}
/* Drawing and caching both check to see if strip is in view area or not before calling this
* function so assuming strip/part of strip in view. */
int no_invisible_thumbs = (view_area->xmin - seq->start) / frame_step;
- *r_start_frame = ((no_invisible_thumbs - 1) * frame_step) + seq->start;
+ return ((no_invisible_thumbs - 1) * frame_step) + seq->start;
}
-static void thumbnail_startjob(void *data, short *stop, short *do_update, float *progress)
+static void thumbnail_start_job(void *data, short *stop, short *do_update, float *progress)
{
ThumbnailDrawJob *tj = data;
- ThumbDataItem *val;
- Sequence *seq_orig;
float start_frame, frame_step;
GHashIterator gh_iter;
- BLI_ghashIterator_init(&gh_iter, tj->seqs);
+ BLI_ghashIterator_init(&gh_iter, tj->sequences_ghash);
while (!BLI_ghashIterator_done(&gh_iter) & !*stop) {
- seq_orig = BLI_ghashIterator_getKey(&gh_iter);
- val = BLI_ghash_lookup(tj->seqs, seq_orig);
+ Sequence *seq_orig = BLI_ghashIterator_getKey(&gh_iter);
+ ThumbDataItem *val = BLI_ghash_lookup(tj->sequences_ghash, seq_orig);
if (check_seq_need_thumbnails(seq_orig, tj->view_area)) {
- seq_thumbnail_get_frame_step(
+ seq_get_thumb_image_dimensions(
val->seq_dupli, tj->pixelx, tj->pixely, &frame_step, NULL, NULL, NULL);
- seq_thumbnail_get_start_frame(seq_orig, frame_step, tj->view_area, &start_frame);
+ start_frame = seq_thumbnail_get_start_frame(seq_orig, frame_step, tj->view_area);
SEQ_render_thumbnails(
&tj->context, val->seq_dupli, seq_orig, start_frame, frame_step, tj->view_area, stop);
}
@@ -1415,10 +1409,50 @@ static void thumbnail_startjob(void *data, short *stop, short *do_update, float
UNUSED_VARS(do_update, progress);
}
-static void sequencer_thumbnail_get_job(const bContext *C,
- View2D *v2d,
- SeqRenderData context,
- GHash *seqs)
+static SeqRenderData sequencer_thumbnail_context_init(const bContext *C)
+{
+ struct Main *bmain = CTX_data_main(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ Scene *scene = CTX_data_scene(C);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+ SeqRenderData context = {0};
+
+ /* Taking rectx and recty as 0 as dimensions not known here, and context is used to calculate
+ * hash key but not necessary as other variables of SeqRenderData are unique enough. */
+ SEQ_render_new_render_data(bmain, depsgraph, scene, 0, 0, sseq->render_size, false, &context);
+ context.view_id = BKE_scene_multiview_view_id_get(&scene->r, STEREO_LEFT_NAME);
+ context.use_proxies = false;
+
+ return context;
+}
+
+static GHash *sequencer_thumbnail_ghash_init(const bContext *C, View2D *v2d, Editing *ed)
+{
+ Scene *scene = CTX_data_scene(C);
+
+ /* Set the data for thumbnail caching job. */
+ GHash *thumb_data_hash = BLI_ghash_ptr_new("seq_duplicates_and_origs");
+
+ LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
+ ThumbDataItem *val_need_update = BLI_ghash_lookup(thumb_data_hash, seq);
+ if (val_need_update == NULL && check_seq_need_thumbnails(seq, &v2d->cur)) {
+ ThumbDataItem *val = MEM_callocN(sizeof(ThumbDataItem), "Thumbnail Hash Values");
+ val->seq_dupli = SEQ_sequence_dupli_recursive(scene, scene, NULL, seq, 0);
+ val->scene = scene;
+ BLI_ghash_insert(thumb_data_hash, seq, val);
+ }
+ else {
+ if (val_need_update != NULL) {
+ val_need_update->seq_dupli->start = seq->start;
+ val_need_update->seq_dupli->startdisp = seq->startdisp;
+ }
+ }
+ }
+
+ return thumb_data_hash;
+}
+
+static void sequencer_thumbnail_init_job(const bContext *C, View2D *v2d, Editing *ed)
{
wmJob *wm_job;
ThumbnailDrawJob *tj = NULL;
@@ -1427,7 +1461,7 @@ static void sequencer_thumbnail_get_job(const bContext *C,
CTX_wm_window(C),
CTX_data_scene(C),
"Draw Thumbnails",
- 1 << 3,
+ WM_JOB_PROGRESS, // TODO(AYJ): change this and use SEQ_RENDER_THUMB_SIZE
WM_JOB_TYPE_SEQ_DRAW_THUMBNAIL);
/* Get the thumbnail job if it exists. */
@@ -1444,17 +1478,13 @@ static void sequencer_thumbnail_get_job(const bContext *C,
tj->scene = CTX_data_scene(C);
tj->view_area = view_area;
- tj->context = context;
- tj->seqs = seqs;
+ tj->context = sequencer_thumbnail_context_init(C);
+ tj->sequences_ghash = sequencer_thumbnail_ghash_init(C, v2d, ed);
tj->pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
tj->pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
WM_jobs_customdata_set(wm_job, tj, thumbnail_freejob);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER);
- WM_jobs_callbacks(wm_job, thumbnail
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list