[Bf-blender-cvs] [3e6336ac30f] temp-vse-thumbnail-mod: Include changes from P2373

Richard Antalik noreply at git.blender.org
Wed Sep 8 17:55:15 CEST 2021


Commit: 3e6336ac30f4ba96314b6b02b4cac36dc4be7bd7
Author: Richard Antalik
Date:   Wed Sep 8 17:54:18 2021 +0200
Branches: temp-vse-thumbnail-mod
https://developer.blender.org/rB3e6336ac30f4ba96314b6b02b4cac36dc4be7bd7

Include changes from P2373

===================================================================

M	source/blender/editors/interface/view2d_ops.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/makesdna/DNA_view2d_types.h

===================================================================

diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 1fd1b6c984d..3afbcf78851 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -147,6 +147,8 @@ static void view_pan_init(bContext *C, wmOperator *op)
   const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
   vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx;
   vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy;
+
+  vpd->v2d->flag |= V2D_IS_NAVIGATING;
 }
 
 /* apply transform to view (i.e. adjust 'cur' rect) */
@@ -190,6 +192,8 @@ static void view_pan_apply(bContext *C, wmOperator *op)
 /* Cleanup temp custom-data. */
 static void view_pan_exit(wmOperator *op)
 {
+  v2dViewPanData *vpd = op->customdata;
+  vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
   MEM_SAFE_FREE(op->customdata);
 }
 
@@ -305,7 +309,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
   return OPERATOR_RUNNING_MODAL;
 }
 
-static void view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
+static void view_pan_cancel(bContext *C, wmOperator *op)
 {
   view_pan_exit(op);
 }
@@ -358,6 +362,7 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
   View2DEdgePanData *vpd = op->customdata;
 
   if (event->val == KM_RELEASE || event->type == EVT_ESCKEY) {
+    vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
     MEM_SAFE_FREE(op->customdata);
     return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
   }
@@ -371,6 +376,8 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
 
 static void view_edge_pan_cancel(bContext *UNUSED(C), wmOperator *op)
 {
+  v2dViewPanData *vpd = op->customdata;
+  vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
   MEM_SAFE_FREE(op->customdata);
 }
 
@@ -680,6 +687,8 @@ static void view_zoomdrag_init(bContext *C, wmOperator *op)
   vzd->v2d = &vzd->region->v2d;
   /* False by default. Interactive callbacks (ie invoke()) can set it to true. */
   vzd->zoom_to_mouse_pos = false;
+
+  vzd->v2d->flag |= V2D_IS_NAVIGATING;
 }
 
 /* apply transform to view (i.e. adjust 'cur' rect) */
@@ -809,7 +818,8 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
 static void view_zoomstep_exit(wmOperator *op)
 {
   UI_view2d_zoom_cache_reset();
-
+  v2dViewZoomData *vzd = op->customdata;
+  vzd->v2d->flag &= ~V2D_IS_NAVIGATING;
   MEM_SAFE_FREE(op->customdata);
 }
 
@@ -1041,6 +1051,7 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
 
   if (op->customdata) {
     v2dViewZoomData *vzd = op->customdata;
+    vzd->v2d->flag &= ~V2D_IS_NAVIGATING;
 
     if (vzd->timer) {
       WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 1ec6d9dc4a7..94c9f8565b5 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1505,6 +1505,11 @@ static void sequencer_thumbnail_start_job_if_necessary(const bContext *C,
 {
   SpaceSeq *sseq = CTX_wm_space_seq(C);
 
+  if ((v2d->flag & V2D_IS_NAVIGATING) != 0) {
+    WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL);
+    return;
+  }
+
   /* Leftover is set to true if missing image in strip. False when normal call to all strips done.
    */
   if (v2d->cur.xmax != sseq->runtime.last_thumbnail_area.xmax ||
@@ -1521,6 +1526,24 @@ static void sequencer_thumbnail_start_job_if_necessary(const bContext *C,
   }
 }
 
+/* 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 = &region->v2d;
+  SpaceSeq *sseq = CTX_wm_space_seq(C);
+
+  if ((v2d->flag & V2D_IS_NAVIGATING) == 0) {
+    return false;
+  }
+
+  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;
+}
+
 static void draw_seq_strip_thumbnail(View2D *v2d,
                                      const bContext *C,
                                      Scene *scene,
@@ -1538,6 +1561,11 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
   if ((y2 - y1) / pixely <= 40 * U.dpi_fac)
     return;
 
+  if (sequencer_thumbnail_v2d_is_navigating(C)) {
+    WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, NULL);
+    return;
+  }
+
   SeqRenderData context = sequencer_thumbnail_context_init(C);
   seq_get_thumb_image_dimensions(
       seq, pixelx, pixely, &thumb_width, &thumb_height, &image_width, &image_height);
@@ -1603,32 +1631,32 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
     /* Get the image. */
     ImBuf *ibuf = SEQ_get_thumbnail(&context, seq, roundf(thumb_x_start), &crop, clipped);
 
-    if (ibuf) {
-      /* Transparency on overlap. */
-      if (seq->flag & SEQ_OVERLAP) {
-        GPU_blend(GPU_BLEND_ALPHA);
-        unsigned char *buf = (unsigned char *)ibuf->rect;
-        for (int pixel = ibuf->x * ibuf->y; pixel--; buf += 4) {
-          buf[3] = OVERLAP_ALPHA;
-        }
-      }
-
-      ED_draw_imbuf_ctx_clipping(C,
-                                 ibuf,
-                                 thumb_x_start + cut_off,
-                                 y1,
-                                 true,
-                                 thumb_x_start + cut_off,
-                                 y1,
-                                 thumb_x_end,
-                                 thumb_y_end,
-                                 zoom_x,
-                                 zoom_y);
-      IMB_freeImBuf(ibuf);
-    }
-    else {
+    if (!ibuf) {
       sequencer_thumbnail_start_job_if_necessary(C, scene->ed, v2d, true);
+      break;
     }
+
+    /* Transparency on overlap. */
+    if (seq->flag & SEQ_OVERLAP) {
+      GPU_blend(GPU_BLEND_ALPHA);
+      unsigned char *buf = (unsigned char *)ibuf->rect;
+      for (int pixel = ibuf->x * ibuf->y; pixel--; buf += 4) {
+        buf[3] = OVERLAP_ALPHA;
+      }
+    }
+
+    ED_draw_imbuf_ctx_clipping(C,
+                               ibuf,
+                               thumb_x_start + cut_off,
+                               y1,
+                               true,
+                               thumb_x_start + cut_off,
+                               y1,
+                               thumb_x_end,
+                               thumb_y_end,
+                               zoom_x,
+                               zoom_y);
+    IMB_freeImBuf(ibuf);
     GPU_blend(GPU_BLEND_NONE);
     cut_off = 0;
     thumb_x_start = thumb_x_end;
diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h
index c385ac04bd3..f8166305fd9 100644
--- a/source/blender/makesdna/DNA_view2d_types.h
+++ b/source/blender/makesdna/DNA_view2d_types.h
@@ -132,6 +132,8 @@ enum {
   V2D_PIXELOFS_X = (1 << 2),
   /* apply pixel offsets on y-axis when setting view matrices */
   V2D_PIXELOFS_Y = (1 << 3),
+  /* zoom, pan or similar action is in progress */
+  V2D_IS_NAVIGATING = (1 << 9),
   /* view settings need to be set still... */
   V2D_IS_INIT = (1 << 10),
 };



More information about the Bf-blender-cvs mailing list