[Bf-blender-cvs] [c4b9cb0af0a] master: UI: Allow gizmo-only redraw tagging

Julian Eisel noreply at git.blender.org
Fri Feb 14 16:04:21 CET 2020


Commit: c4b9cb0af0ae50c5bdb4246b30aceadb12ec97d9
Author: Julian Eisel
Date:   Fri Feb 14 15:36:12 2020 +0100
Branches: master
https://developer.blender.org/rBc4b9cb0af0ae50c5bdb4246b30aceadb12ec97d9

UI: Allow gizmo-only redraw tagging

NOTE: This change shouldn't have any visible effect. It's just the
first (easiest) step towards decoupling gizmo redraws from viewport
redraws.

We currently redraw the entire region whenever a gizmo needs redrawing,
which would be nice to avoid in the future, see T73198. The first step
towards this would be having a separate tag for them, which is what
this patch implements.
The term "editor-overlays" was chosen because for the forseeable future,
we'll also have to redraw non-gizmo overlays in-between drawing 3D and
2D gizmos. Namely annotations.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6838

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

M	source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
M	source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
M	source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
M	source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
M	source/blender/editors/space_view3d/view3d_gizmo_ruler.c
M	source/blender/editors/transform/transform_gizmo_2d.c
M	source/blender/editors/transform/transform_gizmo_3d.c
M	source/blender/makesdna/DNA_screen_types.h
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.c
M	source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c

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

diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
index f1a8bc62cd3..a2b654dfa68 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
@@ -353,7 +353,7 @@ static int gizmo_arrow_modal(bContext *C,
   }
 
   /* tag the region for redraw */
-  ED_region_tag_redraw(ar);
+  ED_region_tag_redraw_editor_overlays(ar);
   WM_event_add_mousemove(C);
 
   return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 2e4284d357a..5ff76d886c2 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -1086,7 +1086,7 @@ static int gizmo_cage2d_modal(bContext *C,
   }
 
   /* tag the region for redraw */
-  ED_region_tag_redraw(CTX_wm_region(C));
+  ED_region_tag_redraw_editor_overlays(CTX_wm_region(C));
   WM_event_add_mousemove(C);
 
   return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index 05b58903e04..393568e8382 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -585,7 +585,7 @@ static int gizmo_cage3d_modal(bContext *C,
   }
 
   /* tag the region for redraw */
-  ED_region_tag_redraw(CTX_wm_region(C));
+  ED_region_tag_redraw_editor_overlays(CTX_wm_region(C));
   WM_event_add_mousemove(C);
 
   return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index f040e67ae44..e7264d2c9bd 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -303,7 +303,7 @@ static int gizmo_move_modal(bContext *C,
     zero_v3(move->prop_co);
   }
 
-  ED_region_tag_redraw(ar);
+  ED_region_tag_redraw_editor_overlays(ar);
 
   inter->prev.tweak_flag = tweak_flag;
 
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 9e0272d1402..3149a111b74 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -75,6 +75,7 @@ void ED_region_tag_redraw_partial(struct ARegion *ar, const struct rcti *rct, bo
 void ED_region_tag_redraw_overlay(struct ARegion *ar);
 void ED_region_tag_redraw_no_rebuild(struct ARegion *ar);
 void ED_region_tag_refresh_ui(struct ARegion *ar);
+void ED_region_tag_redraw_editor_overlays(struct ARegion *ar);
 
 void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar);
 void ED_region_panels_ex(const struct bContext *C,
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 26c48dda4f4..01e0ae812cc 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -629,7 +629,7 @@ void ED_region_tag_redraw(ARegion *ar)
    * but python scripts can cause this to happen indirectly */
   if (ar && !(ar->do_draw & RGN_DRAWING)) {
     /* zero region means full region redraw */
-    ar->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD);
+    ar->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD | RGN_DRAW_EDITOR_OVERLAYS);
     ar->do_draw |= RGN_DRAW;
     memset(&ar->drawrct, 0, sizeof(ar->drawrct));
   }
@@ -645,7 +645,7 @@ void ED_region_tag_redraw_overlay(ARegion *ar)
 void ED_region_tag_redraw_no_rebuild(ARegion *ar)
 {
   if (ar && !(ar->do_draw & (RGN_DRAWING | RGN_DRAW))) {
-    ar->do_draw &= ~RGN_DRAW_PARTIAL;
+    ar->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_EDITOR_OVERLAYS);
     ar->do_draw |= RGN_DRAW_NO_REBUILD;
     memset(&ar->drawrct, 0, sizeof(ar->drawrct));
   }
@@ -658,6 +658,22 @@ void ED_region_tag_refresh_ui(ARegion *ar)
   }
 }
 
+/**
+ * Tag editor overlays to be redrawn. If in doubt about which parts need to be redrawn (partial
+ * clipping rectangle set), redraw everything.
+ */
+void ED_region_tag_redraw_editor_overlays(struct ARegion *ar)
+{
+  if (ar && !(ar->do_draw & (RGN_DRAWING | RGN_DRAW))) {
+    if (ar->do_draw & RGN_DRAW_PARTIAL) {
+      ED_region_tag_redraw(ar);
+    }
+    else {
+      ar->do_draw |= RGN_DRAW_EDITOR_OVERLAYS;
+    }
+  }
+}
+
 void ED_region_tag_redraw_partial(ARegion *ar, const rcti *rct, bool rebuild)
 {
   if (ar && !(ar->do_draw & RGN_DRAWING)) {
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
index 68159e2d684..eec5ec3da34 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
@@ -227,7 +227,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int
 
   if (best.ele) {
     ARegion *ar = CTX_wm_region(C);
-    ED_region_tag_redraw(ar);
+    ED_region_tag_redraw_editor_overlays(ar);
   }
 
   // return best.eed ? 0 : -1;
@@ -383,7 +383,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const
     RNA_int_set(gz->ptr, "edge_index", gz_ring->edge_index);
 
     ARegion *ar = CTX_wm_region(C);
-    ED_region_tag_redraw(ar);
+    ED_region_tag_redraw_editor_overlays(ar);
   }
 
   // return best.eed ? 0 : -1;
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index e53957b054d..db120b246c7 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -933,7 +933,7 @@ static int gizmo_ruler_modal(bContext *C,
   ruler_info->drag_state_prev.do_thickness = do_thickness;
 
   if (do_draw) {
-    ED_region_tag_redraw(ar);
+    ED_region_tag_redraw_editor_overlays(ar);
   }
   return exit_code;
 }
@@ -1187,7 +1187,7 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent
       /* Update the annotation layer. */
       view3d_ruler_to_gpencil(C, gzgroup);
 
-      ED_region_tag_redraw(ar);
+      ED_region_tag_redraw_editor_overlays(ar);
       return OPERATOR_FINISHED;
     }
   }
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index 793552865a6..558e14750d6 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -276,7 +276,7 @@ static int gizmo2d_modal(bContext *C,
   gizmo2d_origin_to_region(ar, origin);
   WM_gizmo_set_matrix_location(widget, origin);
 
-  ED_region_tag_redraw(ar);
+  ED_region_tag_redraw_editor_overlays(ar);
 
   return OPERATOR_RUNNING_MODAL;
 }
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 3d3aa58a0de..46add93b2e1 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1567,7 +1567,7 @@ static int gizmo_modal(bContext *C,
     WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]);
   }
 
-  ED_region_tag_redraw(ar);
+  ED_region_tag_redraw_editor_overlays(ar);
 
   return OPERATOR_RUNNING_MODAL;
 }
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index a52767834a4..cded709b0d6 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -678,6 +678,9 @@ enum {
   RGN_DRAWING = 8,
   /* For popups, to refresh UI layout along with drawing. */
   RGN_REFRESH_UI = 16,
+
+  /* Only editor overlays (currently gizmos only!) should be redrawn. */
+  RGN_DRAW_EDITOR_OVERLAYS = 32,
 };
 
 #endif /* __DNA_SCREEN_TYPES_H__ */
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index ab38b850ada..5ef77090ea0 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -310,7 +310,7 @@ void WM_gizmo_group_remove_by_tool(bContext *C,
               if (gzgroup->type == gzgt) {
                 BLI_assert(gzgroup->parent_gzmap == gzmap);
                 wm_gizmogroup_free(C, gzgroup);
-                ED_region_tag_redraw(ar);
+                ED_region_tag_redraw_editor_overlays(ar);
               }
             }
           }
@@ -391,7 +391,7 @@ static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
     }
 
     if (redraw) {
-      ED_region_tag_redraw(ar);
+      ED_region_tag_redraw_editor_overlays(ar);
     }
 
     return OPERATOR_FINISHED;
@@ -941,7 +941,7 @@ wmGizmoGroup *WM_gizmomaptype_group_init_runtime_with_region(wmGizmoMapType *gzm
 
   wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0);
 
-  ED_region_tag_redraw(ar);
+  ED_region_tag_redraw_editor_overlays(ar);
 
   return gzgroup;
 }
@@ -973,7 +973,7 @@ void WM_gizmomaptype_group_unlink(bContext *C,
               if (gzgroup->type == gzgt) {
                 BLI_assert(gzgroup->parent_gzmap == gzmap);
                 wm_gizmogroup_free(C, gzgroup);
-                ED_region_tag_redraw(ar);
+                ED_region_tag_redraw_editor_overlays(ar);
               }
             }
           }
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index 383ca806d35..98669afdd08 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -1047,7 +1047,7 @@ bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz
     /* tag the region for redraw */
     if (C) {
       ARegion *ar = CTX_wm_region(C);
-      ED_region_tag_redraw(ar);
+      ED_region_tag_redraw_editor_overlays(ar);
     }
 
     return true;
@@ -1135,7 +1135,7 @@ void wm_gizmomap_modal_set(


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list