[Bf-blender-cvs] [6995fa3ac58] temp-vse-thumbnail-mod: Minor cleanup and tweaks
Richard Antalik
noreply at git.blender.org
Thu Sep 16 06:14:09 CEST 2021
Commit: 6995fa3ac5828849beecad9b4e4650b551599e66
Author: Richard Antalik
Date: Thu Sep 16 06:13:26 2021 +0200
Branches: temp-vse-thumbnail-mod
https://developer.blender.org/rB6995fa3ac5828849beecad9b4e4650b551599e66
Minor cleanup and tweaks
===================================================================
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/sequencer/intern/image_cache.c
M source/blender/sequencer/intern/render.c
===================================================================
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 7d9e424dc20..82b4c478db8 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1499,24 +1499,11 @@ static void sequencer_thumbnail_init_job(const bContext *C, View2D *v2d, Editing
ED_area_tag_redraw(area);
}
-
-/* Don't display thumbnails only when zooming. Panning doesn't cause issues. */
static bool sequencer_thumbnail_v2d_is_navigating(const bContext *C)
{
ARegion *region = CTX_wm_region(C);
View2D *v2d = ®ion->v2d;
- SpaceSeq *sseq = CTX_wm_space_seq(C);
-
- if ((v2d->flag & V2D_IS_NAVIGATING) == 0) {
- return false;
- }
- return true;
-
- double x_diff = fabs(BLI_rctf_size_x(&sseq->runtime.last_thumbnail_area) -
- BLI_rctf_size_x(&v2d->cur));
- double y_diff = fabs(BLI_rctf_size_y(&sseq->runtime.last_thumbnail_area) -
- BLI_rctf_size_y(&v2d->cur));
- return x_diff > 0.01 || y_diff > 0.01;
+ return (v2d->flag & V2D_IS_NAVIGATING) != 0;
}
static void sequencer_thumbnail_start_job_if_necessary(const bContext *C,
@@ -1649,8 +1636,16 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
thumb_x_start = seq_thumbnail_get_start_frame(seq, thumb_width, &v2d->cur);
float thumb_x_end;
- GSet *last_displayed_thumbnails = last_displayed_thumbnails_list_ensure(C, seq);
+ while (thumb_x_start + thumb_width < v2d->cur.xmin) {
+ thumb_x_start += thumb_width;
+ }
+
+ /* Ignore thumbs to the left of strip. */
+ while (thumb_x_start + thumb_width < seq->startdisp) {
+ thumb_x_start += thumb_width;
+ }
+ GSet *last_displayed_thumbnails = last_displayed_thumbnails_list_ensure(C, seq);
/* Cleanup thumbnail list outside of rendered range, which is cleaned up one by one to prevent
* flickering after zooming. */
if (!sequencer_thumbnail_v2d_is_navigating(C)) {
@@ -1665,18 +1660,8 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
/* Checks to make sure that thumbs are loaded only when in view and within the confines of the
* strip. Some may not be required but better to have conditions for safety as x1 here is
* point to start caching from and not drawing. */
- if (thumb_x_start > v2d->cur.xmax)
+ if (thumb_x_start > v2d->cur.xmax) {
break;
-
- if (thumb_x_end < v2d->cur.xmin) {
- thumb_x_start = thumb_x_end;
- continue;
- }
-
- /* Ignore thumbs to the left of strip. */
- if (thumb_x_end < seq->startdisp) {
- thumb_x_start = thumb_x_end;
- continue;
}
/* Set the clipping bound to show the left handle moving over thumbs and not shift thumbs. */
@@ -1689,8 +1674,9 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
if (thumb_x_end > (upper_thumb_bound)) {
thumb_x_end = upper_thumb_bound;
clipped = true;
- if (thumb_x_end - thumb_x_start < 1)
+ if (thumb_x_end - thumb_x_start < 1) {
break;
+ }
}
float zoom_x = thumb_width / image_width;
@@ -1733,8 +1719,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
/* If there is no image still, abort. */
if (!ibuf) {
- last_displayed_thumbnails_list_cleanup(last_displayed_thumbnails, thumb_x_start, FLT_MAX);
- return;
+ break;
}
/* Transparency on overlap. */
@@ -1770,7 +1755,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
cut_off = 0;
thumb_x_start += thumb_width;
}
- last_displayed_thumbnails_list_cleanup(last_displayed_thumbnails, thumb_x_start - thumb_width, FLT_MAX);
+ last_displayed_thumbnails_list_cleanup(last_displayed_thumbnails, thumb_x_start, FLT_MAX);
}
/* Draw visible strips. Bounds check are already made. */
diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c
index 32da1ade617..86c198075e9 100644
--- a/source/blender/sequencer/intern/image_cache.c
+++ b/source/blender/sequencer/intern/image_cache.c
@@ -104,7 +104,7 @@
#define DCACHE_IMAGES_PER_FILE 100
#define DCACHE_CURRENT_VERSION 2
#define COLORSPACE_NAME_MAX 64 /* XXX: defined in imb intern */
-#define THUMB_CACHE_LIMIT 100
+#define THUMB_CACHE_LIMIT 5000
typedef struct DiskCacheHeaderEntry {
unsigned char encoding;
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 82cfdfb123f..258bcf1f594 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -2090,23 +2090,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 - 5 * frame_step;
+ 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 + 5 * frame_step :
+ upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step :
upper_thumb_bound;
while ((start_frame < upper_thumb_bound) & !*stop) {
- ImBuf *ibuf = seq_cache_get(context, seq_orig, roundf(start_frame), SEQ_CACHE_STORE_THUMBNAIL);
+ ImBuf *ibuf = seq_cache_get(
+ context, seq_orig, round_fl_to_int(start_frame), SEQ_CACHE_STORE_THUMBNAIL);
if (ibuf) {
IMB_freeImBuf(ibuf);
start_frame += frame_step;
continue;
}
- ibuf = seq_get_uncached_thumbnail(context, &state, seq, roundf(start_frame));
+ ibuf = seq_get_uncached_thumbnail(context, &state, seq, round_fl_to_int(start_frame));
if (ibuf) {
- seq_cache_thumbnail_put(context, seq_orig, roundf(start_frame), ibuf, view_area);
+ seq_cache_thumbnail_put(context, seq_orig, round_fl_to_int(start_frame), ibuf, view_area);
IMB_freeImBuf(ibuf);
}
@@ -2147,10 +2148,10 @@ void SEQ_render_thumbnails_base_set(
continue;
}
- ibuf = seq_get_uncached_thumbnail(context, &state, seq, roundf(timeline_frame));
+ ibuf = seq_get_uncached_thumbnail(context, &state, seq, timeline_frame);
if (ibuf) {
- seq_cache_thumbnail_put(context, seq_orig, roundf(timeline_frame), ibuf, view_area);
+ seq_cache_thumbnail_put(context, seq_orig, timeline_frame, ibuf, view_area);
IMB_freeImBuf(ibuf);
}
More information about the Bf-blender-cvs
mailing list