Commit: 8f565f5a6ffa4f6170caca2de50a733e8c72367a Author: Campbell Barton Date: Fri Aug 16 05:41:43 2019 +1000 Branches: master https://developer.blender.org/rB8f565f5a6ffa4f6170caca2de50a733e8c72367a
WM: reuse visible region calculation Avoids calculating the visible part of a region whenever on-screen overlays are drawn. =================================================================== M source/blender/draw/engines/eevee/eevee_lookdev.c M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_manager_profiling.c M source/blender/draw/intern/draw_manager_profiling.h M source/blender/editors/gpencil/annotate_draw.c M source/blender/editors/gpencil/annotate_paint.c M source/blender/editors/gpencil/drawgpencil.c M source/blender/editors/gpencil/gpencil_paint.c M source/blender/editors/include/ED_screen.h M source/blender/editors/interface/view2d_gizmo_navigate.c M source/blender/editors/screen/area.c M source/blender/editors/space_image/image_draw.c M source/blender/editors/space_image/space_image.c M source/blender/editors/space_sequencer/space_sequencer.c M source/blender/editors/space_view3d/view3d_draw.c M source/blender/editors/space_view3d/view3d_gizmo_navigate.c M source/blender/editors/transform/transform.c M source/blender/makesdna/DNA_screen_types.h =================================================================== diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index e6e699bef10..f52fcf31267 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -75,22 +75,21 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, if (LOOK_DEV_OVERLAY_ENABLED(v3d)) { /* Viewport / Spheres size. */ - rcti rect; - ED_region_visible_rect(draw_ctx->ar, &rect); + const rcti *rect = ED_region_visible_rect(draw_ctx->ar); /* Make the viewport width scale the lookdev spheres a bit. * Scale between 1000px and 2000px. */ const float viewport_scale = clamp_f( - BLI_rcti_size_x(&rect) / (2000.0f * U.dpi_fac), 0.5f, 1.0f); + BLI_rcti_size_x(rect) / (2000.0f * U.dpi_fac), 0.5f, 1.0f); const int sphere_size = U.lookdev_sphere_size * U.dpi_fac * viewport_scale; - if (sphere_size != effects->sphere_size || rect.xmax != effects->anchor[0] || - rect.ymin != effects->anchor[1]) { + if (sphere_size != effects->sphere_size || rect->xmax != effects->anchor[0] || + rect->ymin != effects->anchor[1]) { /* If sphere size or anchor point moves, reset TAA to avoid ghosting issue. * This needs to happen early because we are changing taa_current_sample. */ effects->sphere_size = sphere_size; - effects->anchor[0] = rect.xmax; - effects->anchor[1] = rect.ymin; + effects->anchor[0] = rect->xmax; + effects->anchor[1] = rect->ymin; EEVEE_temporal_sampling_reset(vedata); } } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1046e0422c1..a2bbb368caa 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1725,9 +1725,9 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, if (G.debug_value > 20 && G.debug_value < 30) { GPU_depth_test(false); - rcti rect; /* local coordinate visible rect inside region, to accommodate overlapping ui */ - ED_region_visible_rect(DST.draw_ctx.ar, &rect); - DRW_stats_draw(&rect); + /* local coordinate visible rect inside region, to accommodate overlapping ui */ + const rcti *rect = ED_region_visible_rect(DST.draw_ctx.ar); + DRW_stats_draw(rect); GPU_depth_test(true); } diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index 5e21e5e576c..bab69cf7a57 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -200,7 +200,7 @@ void DRW_stats_reset(void) } } -static void draw_stat_5row(rcti *rect, int u, int v, const char *txt, const int size) +static void draw_stat_5row(const rcti *rect, int u, int v, const char *txt, const int size) { BLF_draw_default_ascii(rect->xmin + (1 + u * 5) * U.widget_unit, rect->ymax - (3 + v) * U.widget_unit, @@ -209,13 +209,13 @@ static void draw_stat_5row(rcti *rect, int u, int v, const char *txt, const int size); } -static void draw_stat(rcti *rect, int u, int v, const char *txt, const int size) +static void draw_stat(const rcti *rect, int u, int v, const char *txt, const int size) { BLF_draw_default_ascii( rect->xmin + (1 + u) * U.widget_unit, rect->ymax - (3 + v) * U.widget_unit, 0.0f, txt, size); } -void DRW_stats_draw(rcti *rect) +void DRW_stats_draw(const rcti *rect) { char stat_string[64]; int lvl_index[MAX_NESTED_TIMER]; diff --git a/source/blender/draw/intern/draw_manager_profiling.h b/source/blender/draw/intern/draw_manager_profiling.h index 7fe2280f9b2..3da6a4c8b1c 100644 --- a/source/blender/draw/intern/draw_manager_profiling.h +++ b/source/blender/draw/intern/draw_manager_profiling.h @@ -35,6 +35,6 @@ void DRW_stats_group_end(void); void DRW_stats_query_start(const char *name); void DRW_stats_query_end(void); -void DRW_stats_draw(rcti *rect); +void DRW_stats_draw(const rcti *rect); #endif /* __DRAW_MANAGER_PROFILING_H__ */ diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index dce6ed29c05..697d06aa098 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -936,7 +936,6 @@ static void annotation_draw_data_layers( /* draw a short status message in the top-right corner */ static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar) { - rcti rect; /* Cannot draw any status text when drawing OpenGL Renders */ if (G.f & G_FLAG_RENDER_VIEWPORT) { @@ -944,7 +943,7 @@ static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar) } /* Get bounds of region - Necessary to avoid problems with region overlap */ - ED_region_visible_rect(ar, &rect); + const rcti *rect = ED_region_visible_rect(ar); /* for now, this should only be used to indicate when we are in stroke editmode */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { @@ -956,8 +955,8 @@ static void annotation_draw_status_text(const bGPdata *gpd, ARegion *ar) BLF_width_and_height( font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]); - int xco = (rect.xmax - U.widget_unit) - (int)printable_size[0]; - int yco = (rect.ymax - U.widget_unit); + int xco = (rect->xmax - U.widget_unit) - (int)printable_size[0]; + int yco = (rect->ymax - U.widget_unit); /* text label */ UI_FontThemeColor(font_id, TH_TEXT_HI); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index c9c4a67644e..07b61751b22 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -2242,11 +2242,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (p->ar) { - rcti region_rect; - - /* Perform bounds check using */ - ED_region_visible_rect(p->ar, ®ion_rect); - in_bounds = BLI_rcti_isect_pt_v(®ion_rect, event->mval); + /* Perform bounds check. */ + const rcti *region_rect = ED_region_visible_rect(p->ar); + in_bounds = BLI_rcti_isect_pt_v(region_rect, event->mval); } else { /* No region */ diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 2b31af5ff1f..7c76f3aeab6 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1173,15 +1173,14 @@ void ED_gp_draw_fill(tGPDdraw *tgpw) /* draw a short status message in the top-right corner */ static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar) { - rcti rect; /* Cannot draw any status text when drawing OpenGL Renders */ if (G.f & G_FLAG_RENDER_VIEWPORT) { return; } - /* Get bounds of region - Necessary to avoid problems with region overlap */ - ED_region_visible_rect(ar, &rect); + /* Get bounds of region - Necessary to avoid problems with region overlap. */ + const rcti *rect = ED_region_visible_rect(ar); /* for now, this should only be used to indicate when we are in stroke editmode */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { @@ -1193,8 +1192,8 @@ static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar BLF_width_and_height( font_id, printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]); - int xco = (rect.xmax - U.widget_unit) - (int)printable_size[0]; - int yco = (rect.ymax - U.widget_unit); + int xco = (rect->xmax - U.widget_unit) - (int)printable_size[0]; + int yco = (rect->ymax - U.widget_unit); /* text label */ UI_FontThemeColor(font_id, TH_TEXT_HI); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 894fb6eced4..a5425d64c2e 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -3629,11 +3629,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (p->ar) { - rcti region_rect; - /* Perform bounds check using */ - ED_region_visible_rect(p->ar, ®ion_rect); - in_bounds = BLI_rcti_isect_pt_v(®ion_rect, event->mval); + const rcti *region_rect = ED_region_visible_rect(p->ar); + in_bounds = BLI_rcti_isect_pt_v(region_rect, event->mval); } else { /* No region */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index e67a3b003fc..c7ee7be49b5 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -124,7 +124,8 @@ void ED_region_image_metadata_draw( void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout); void ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy); float ED_region_blend_alpha(struct ARegion *ar); -void ED_region_visible_rect(struct ARegion *ar, struct rcti *rect); +void ED_region_visible_rect_calc(struct ARegion *ar, struct rcti *rect); +const rcti *ED_region_visible_rect(ARegion *ar); bool ED_region_is_overlap(int spacetype, int regiontype); int ED_region_snap_size_test(const struct ARegion *ar); diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.c b/source/blender/editors/interface/view2d_gizmo_navigate.c index 883f16c63f2..9b15f2309a1 100644 --- a/source/blender/editors/interface/view2d_gizmo_navigate.c +++ b/source/blender/editors/interface/view2d_gizmo_navigate.c @@ -201,21 +201,20 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g struct NavigateWidgetGroup *navgroup = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); - rcti rect_visible; - ED_region_visible_rect(ar, &rect_visible); + const rcti *rect_visible = ED_region_visible_rect(ar); - if ((navgroup->state.rect_visible.xmax == rect_visible.xmax) && - (navgroup->s @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs