diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-01 16:23:42 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-01 17:15:07 +0300 |
commit | 31b2c4c10a413b93551ba313fd93c77698207216 (patch) | |
tree | 5f0cf3d5d4f139c305dc30b4f6c40f7b53a92989 | |
parent | bbbb5cad319e0e2c853b089cd3e1cbb83b447f67 (diff) |
Fix T60289: changing gizmo properties causes excessive redraws
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_gizmo.c | 42 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/WM_gizmo_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 44 |
3 files changed, 67 insertions, 22 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 41e499471ea..38b6ac9ac52 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -243,6 +243,12 @@ static void rna_Gizmo_bl_idname_set(PointerRNA *ptr, const char *value) } } +static void rna_Gizmo_update_redraw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + wmGizmo *gizmo = ptr->data; + gizmo->do_draw = true; +} + static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) { # if 0 @@ -1123,7 +1129,7 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "Alpha", ""); RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_get", "rna_Gizmo_alpha_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* Color & Alpha (highlight) */ prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR); @@ -1134,28 +1140,28 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_ui_text(prop, "Alpha", ""); RNA_def_property_float_funcs(prop, "rna_Gizmo_alpha_hi_get", "rna_Gizmo_alpha_hi_set", NULL); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); prop = RNA_def_property(srna, "matrix_space", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Space Matrix", ""); RNA_def_property_float_funcs( prop, "rna_Gizmo_matrix_space_get", "rna_Gizmo_matrix_space_set", NULL); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Basis Matrix", ""); RNA_def_property_float_funcs( prop, "rna_Gizmo_matrix_basis_get", "rna_Gizmo_matrix_basis_set", NULL); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Offset Matrix", ""); RNA_def_property_float_funcs( prop, "rna_Gizmo_matrix_offset_get", "rna_Gizmo_matrix_offset_set", NULL); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -1168,13 +1174,13 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_float_funcs( prop, "rna_Gizmo_scale_basis_get", "rna_Gizmo_scale_basis_set", NULL); RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL); RNA_def_property_ui_text(prop, "Line Width", ""); RNA_def_property_float_funcs(prop, "rna_Gizmo_line_width_get", "rna_Gizmo_line_width_set", NULL); RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); prop = RNA_def_property(srna, "select_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "Select Bias", "Depth bias used for selection"); @@ -1187,39 +1193,39 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set"); RNA_def_property_ui_text(prop, "Hide", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_HIDDEN_SELECT */ prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set"); RNA_def_property_ui_text(prop, "Hide Select", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_MOVE_CURSOR */ prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( prop, "rna_Gizmo_flag_use_grab_cursor_get", "rna_Gizmo_flag_use_grab_cursor_set"); RNA_def_property_ui_text(prop, "Grab Cursor", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_DRAW_HOVER */ prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( prop, "rna_Gizmo_flag_use_draw_hover_get", "rna_Gizmo_flag_use_draw_hover_set"); RNA_def_property_ui_text(prop, "Draw Hover", ""); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_DRAW_MODAL */ prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( prop, "rna_Gizmo_flag_use_draw_modal_get", "rna_Gizmo_flag_use_draw_modal_set"); RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_DRAW_VALUE */ prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( prop, "rna_Gizmo_flag_use_draw_value_get", "rna_Gizmo_flag_use_draw_value_set"); RNA_def_property_ui_text( prop, "Draw Value", "Show an indicator for the current value while dragging"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_DRAW_OFFSET_SCALE */ prop = RNA_def_property(srna, "use_draw_offset_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, @@ -1227,20 +1233,20 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) "rna_Gizmo_flag_use_draw_offset_scale_set"); RNA_def_property_ui_text( prop, "Scale Offset", "Scale the offset matrix (use to apply screen-space offset)"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_DRAW_NO_SCALE (negated) */ prop = RNA_def_property(srna, "use_draw_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( prop, "rna_Gizmo_flag_use_draw_scale_get", "rna_Gizmo_flag_use_draw_scale_set"); RNA_def_property_ui_text(prop, "Scale", "Use scale when calculating the matrix"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_SELECT_BACKGROUND */ prop = RNA_def_property(srna, "use_select_background", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Gizmo_flag_use_select_background_get", "rna_Gizmo_flag_use_select_background_set"); RNA_def_property_ui_text(prop, "Select Background", "Don't write into the depth buffer"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_OPERATOR_TOOL_INIT */ prop = RNA_def_property(srna, "use_operator_tool_properties", PROP_BOOLEAN, PROP_NONE); @@ -1251,7 +1257,7 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) prop, "Tool Property Init", "Merge active tool properties on activation (does not overwrite existing)"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* WM_GIZMO_EVENT_HANDLE_ALL */ prop = RNA_def_property(srna, "use_event_handle_all", PROP_BOOLEAN, PROP_NONE); @@ -1261,7 +1267,7 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) "Handle All Events", "When highlighted, " "do not pass events through to be handled by other keymaps"); - RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + RNA_def_property_update(prop, 0, "rna_Gizmo_update_redraw"); /* wmGizmo.state (readonly) */ /* WM_GIZMO_STATE_HIGHLIGHT */ diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index 68ecdeea936..2b74677a1a2 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -248,6 +248,9 @@ struct wmGizmo { struct IDProperty *properties; + /** Redraw tag. */ + bool do_draw; + /** Temporary data (assume dirty). */ union { float f; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 56fc38160f0..fc669c9543e 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -188,6 +188,26 @@ static void wm_area_mark_invalid_backbuf(ScrArea *sa) } } +static void wm_region_test_gizmo_do_draw(ARegion *ar, bool tag_redraw) +{ + if (ar->gizmo_map == NULL) { + return; + } + + wmGizmoMap *gzmap = ar->gizmo_map; + for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; + gzgroup = gzgroup->next) { + for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + if (gz->do_draw) { + if (tag_redraw) { + ED_region_tag_redraw_no_rebuild(ar); + } + gz->do_draw = false; + } + } + } +} + static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph *depsgraph, ScrArea *sa, @@ -817,6 +837,7 @@ static bool wm_draw_update_test_window(wmWindow *win) ED_screen_areas_iter(win, screen, sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { + wm_region_test_gizmo_do_draw(ar, true); wm_region_test_render_do_draw(scene, depsgraph, sa, ar); if (ar->visible && ar->do_draw) { @@ -848,6 +869,24 @@ static bool wm_draw_update_test_window(wmWindow *win) return false; } +/* Clear drawing flags, after drawing is complete so any draw flags set during + * drawing don't cause any additional redraws. */ +static void wm_draw_update_clear_window(wmWindow *win) +{ + bScreen *screen = WM_window_get_active_screen(win); + + ED_screen_areas_iter(win, screen, sa) + { + for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { + wm_region_test_gizmo_do_draw(ar, false); + } + } + + screen->do_draw_gesture = false; + screen->do_draw_paintcursor = false; + screen->do_draw_drag = false; +} + void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(ar)) { if (win) { @@ -893,10 +932,7 @@ void wm_draw_update(bContext *C) ED_screen_ensure_updated(wm, win, screen); wm_draw_window(C, win); - - screen->do_draw_gesture = false; - screen->do_draw_paintcursor = false; - screen->do_draw_drag = false; + wm_draw_update_clear_window(win); wm_window_swap_buffers(win); |