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>2022-04-25 02:21:21 +0300
committerRichard Antalik <richardantalik@gmail.com>2022-04-25 05:34:15 +0300
commit29b9187b327ce09362c3ad369ba24058a76cae45 (patch)
tree4ca953f44fc9a47dbaf247976dcef67d7dfb1102 /source/blender/sequencer
parent17eb8a9cebd57258a33924e02b7bae58bbba5c4a (diff)
VSE: Update first thumbnail when moving handle
When handles are moved, job is created only for strips that need to update first thumbnail. ref T91618
Diffstat (limited to 'source/blender/sequencer')
-rw-r--r--source/blender/sequencer/SEQ_render.h14
-rw-r--r--source/blender/sequencer/intern/render.c41
2 files changed, 46 insertions, 9 deletions
diff --git a/source/blender/sequencer/SEQ_render.h b/source/blender/sequencer/SEQ_render.h
index bfe10d3eae9..a74eba5fc6f 100644
--- a/source/blender/sequencer/SEQ_render.h
+++ b/source/blender/sequencer/SEQ_render.h
@@ -17,6 +17,7 @@ struct ListBase;
struct Main;
struct Scene;
struct Sequence;
+struct rctf;
typedef enum eSeqTaskId {
SEQ_TASK_MAIN_RENDER,
@@ -64,7 +65,6 @@ struct ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context,
void SEQ_render_thumbnails(const struct SeqRenderData *context,
struct Sequence *seq,
struct Sequence *seq_orig,
- float start_frame,
float frame_step,
rctf *view_area,
const short *stop);
@@ -77,6 +77,18 @@ struct ImBuf *SEQ_get_thumbnail(const struct SeqRenderData *context,
rcti *crop,
bool clipped);
/**
+ * Get frame for first thumbnail.
+ */
+float SEQ_render_thumbnail_first_frame_get(struct Sequence *seq,
+ float frame_step,
+ struct rctf *view_area);
+/**
+ * Get frame for first thumbnail.
+ */
+float SEQ_render_thumbnail_next_frame_get(struct Sequence *seq,
+ float last_frame,
+ float frame_step);
+/**
* Get frame step for equally spaced thumbnails. These thumbnails should always be present in
* memory, so they can be used when zooming.
*/
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 18b0794dc72..8d8a13be09e 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -1992,6 +1992,32 @@ ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context,
return ibuf;
}
+float SEQ_render_thumbnail_first_frame_get(Sequence *seq, float frame_step, rctf *view_area)
+{
+ int first_drawable_frame = max_iii(seq->startdisp, seq->start, view_area->xmin);
+
+ /* First frame should correspond to handle position. */
+ if (first_drawable_frame == seq->startdisp) {
+ return seq->startdisp;
+ }
+
+ float aligned_frame_offset = (int)((first_drawable_frame - seq->start) / frame_step) *
+ frame_step;
+ return seq->start + aligned_frame_offset;
+}
+
+float SEQ_render_thumbnail_next_frame_get(Sequence *seq, float last_frame, float frame_step)
+{
+ float next_frame = last_frame + frame_step;
+
+ /* If handle position was displayed, align next frame with `seq->start`. */
+ if (last_frame == seq->startdisp) {
+ next_frame = seq->start + ((int)((last_frame - seq->start) / frame_step) + 1) * frame_step;
+ }
+
+ return next_frame;
+}
+
/* Gets the direct image from source and scales to thumbnail size. */
static ImBuf *seq_get_uncached_thumbnail(const SeqRenderData *context,
SeqRenderState *state,
@@ -2053,7 +2079,6 @@ ImBuf *SEQ_get_thumbnail(
void SEQ_render_thumbnails(const SeqRenderData *context,
Sequence *seq,
Sequence *seq_orig,
- float start_frame,
float frame_step,
rctf *view_area,
const short *stop)
@@ -2063,24 +2088,24 @@ void SEQ_render_thumbnails(const SeqRenderData *context,
/* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not
* affected, but frame loaded affected. */
- start_frame = start_frame - frame_step;
float upper_thumb_bound = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step :
upper_thumb_bound;
- while ((start_frame < upper_thumb_bound) & !*stop) {
+ float timeline_frame = SEQ_render_thumbnail_first_frame_get(seq, frame_step, view_area);
+ while ((timeline_frame < upper_thumb_bound) & !*stop) {
ImBuf *ibuf = seq_cache_get(
- context, seq_orig, round_fl_to_int(start_frame), SEQ_CACHE_STORE_THUMBNAIL);
+ context, seq_orig, round_fl_to_int(timeline_frame), SEQ_CACHE_STORE_THUMBNAIL);
if (ibuf) {
IMB_freeImBuf(ibuf);
- start_frame += frame_step;
+ timeline_frame = SEQ_render_thumbnail_next_frame_get(seq, timeline_frame, frame_step);
continue;
}
- ibuf = seq_get_uncached_thumbnail(context, &state, seq, round_fl_to_int(start_frame));
+ ibuf = seq_get_uncached_thumbnail(context, &state, seq, round_fl_to_int(timeline_frame));
if (ibuf) {
- seq_cache_thumbnail_put(context, seq_orig, round_fl_to_int(start_frame), ibuf, view_area);
+ seq_cache_thumbnail_put(context, seq_orig, round_fl_to_int(timeline_frame), ibuf, view_area);
IMB_freeImBuf(ibuf);
seq_orig->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS;
}
@@ -2090,7 +2115,7 @@ void SEQ_render_thumbnails(const SeqRenderData *context,
return;
}
- start_frame += frame_step;
+ timeline_frame = SEQ_render_thumbnail_next_frame_get(seq, timeline_frame, frame_step);
}
}