diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-25 12:47:37 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-11-08 20:31:33 +0300 |
commit | c39f34def9791213d1f4439f6830ccc8f72bc1a7 (patch) | |
tree | 8cf7b8dede1481c0fba2c7f672d68d1cdd0d5054 /source/blender | |
parent | c81ddc97ef7e6aed227f8893d387849ee8390404 (diff) |
Fix Cycles viewport render info overlapping other text.
Now it shows more compact info below the view/object name. Render time and
memory usage is left out, as in most cases this is not so important. These
could be added back optionally if needed.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/DRW_engine.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 3 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 77 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_view.c | 11 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/space_sequencer.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 35 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw_legacy.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 2 |
9 files changed, 59 insertions, 90 deletions
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index f99ce1be894..e192a7efa51 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -98,6 +98,7 @@ typedef bool (*DRW_ObjectFilterFn)( struct Object *ob, void *user_data); void DRW_draw_view(const struct bContext *C); +void DRW_draw_region_engine_info(int xoffset, int yoffset); void DRW_draw_render_loop_ex( struct Depsgraph *depsgraph, diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 629c5013c03..9bf3ce15166 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -524,9 +524,6 @@ void DRW_draw_text_cache_queue(struct DRWTextStore *dt); void DRW_draw_callbacks_pre_scene(void); void DRW_draw_callbacks_post_scene(void); -int DRW_draw_region_engine_info_offset(void); -void DRW_draw_region_engine_info(void); - void DRW_state_reset_ex(DRWState state); void DRW_state_reset(void); void DRW_state_lock(DRWState state); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index cbd2c7719b0..3cff67b5284 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1057,49 +1057,9 @@ static void drw_engines_draw_text(void) } } -#define MAX_INFO_LINES 10 - -/** - * Returns the offset required for the drawing of engines info. - */ -int DRW_draw_region_engine_info_offset(void) +/* Draw render engine info. */ +void DRW_draw_region_engine_info(int xoffset, int yoffset) { - int lines = 0; - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { - DrawEngineType *engine = link->data; - ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); - - /* Count the number of lines. */ - if (data->info[0] != '\0') { - lines++; - char *c = data->info; - while (*c++ != '\0') { - if (*c == '\n') { - lines++; - } - } - } - } - return MIN2(MAX_INFO_LINES, lines) * UI_UNIT_Y; -} - -/** - * Actual drawing; - */ -void DRW_draw_region_engine_info(void) -{ - const char *info_array_final[MAX_INFO_LINES + 1]; - /* This should be maximum number of engines running at the same time. */ - char info_array[MAX_INFO_LINES][GPU_INFO_SIZE]; - int i = 0; - - const DRWContextState *draw_ctx = DRW_context_state_get(); - ARegion *ar = draw_ctx->ar; - float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; - - UI_GetThemeColor3fv(TH_HIGH_GRAD, fill_color); - mul_v3_fl(fill_color, fill_color[3]); - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); @@ -1109,36 +1069,37 @@ void DRW_draw_region_engine_info(void) char *chr_start = chr_current; int line_len = 0; + const int font_id = BLF_default(); + UI_FontThemeColor(font_id, TH_TEXT_HI); + + BLF_enable(font_id, BLF_SHADOW); + BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f}); + BLF_shadow_offset(font_id, 1, -1); + while (*chr_current++ != '\0') { line_len++; if (*chr_current == '\n') { - BLI_strncpy(info_array[i++], chr_start, line_len + 1); + char info[GPU_INFO_SIZE]; + BLI_strncpy(info, chr_start, line_len + 1); + yoffset -= U.widget_unit; + BLF_draw_default(xoffset, yoffset, 0.0f, info, sizeof(info)); + /* Re-start counting. */ chr_start = chr_current + 1; line_len = -1; } } - BLI_strncpy(info_array[i++], chr_start, line_len + 1); + char info[GPU_INFO_SIZE]; + BLI_strncpy(info, chr_start, line_len + 1); + yoffset -= U.widget_unit; + BLF_draw_default(xoffset, yoffset, 0.0f, info, sizeof(info)); - if (i >= MAX_INFO_LINES) { - break; - } + BLF_disable(font_id, BLF_SHADOW); } } - - for (int j = 0; j < i; j++) { - info_array_final[j] = info_array[j]; - } - info_array_final[i] = NULL; - - if (info_array[0] != NULL) { - ED_region_info_draw_multiline(ar, info_array_final, fill_color, true); - } } -#undef MAX_INFO_LINES - static void use_drw_engine(DrawEngineType *engine) { LinkData *ld = MEM_callocN(sizeof(LinkData), "enabled engine link data"); diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 545c4af878c..70049a5c345 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -62,19 +62,10 @@ void DRW_draw_region_info(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); ARegion *ar = draw_ctx->ar; - int offset = 0; DRW_draw_cursor(); - if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) { - offset = DRW_draw_region_engine_info_offset(); - } - - view3d_draw_region_info(draw_ctx->evil_C, ar, offset); - - if (offset > 0) { - DRW_draw_region_engine_info(); - } + view3d_draw_region_info(draw_ctx->evil_C, ar); } /* ************************* Background ************************** */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 2a54d24b412..35c92c3561b 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -525,7 +525,7 @@ float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char * float ED_view3d_grid_view_scale( struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d, const char **grid_unit); -void ED_scene_draw_fps(struct Scene *scene, const struct rcti *rect); +void ED_scene_draw_fps(struct Scene *scene, int xoffset, int *yoffset); /* view matrix properties utilities */ /* unused */ diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 0dd7848699a..092911cb7c2 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -653,7 +653,9 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *ar) if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) { rcti rect; ED_region_visible_rect(ar, &rect); - ED_scene_draw_fps(scene, &rect); + int xoffset = rect.xmin + U.widget_unit; + int yoffset = rect.xmax; + ED_scene_draw_fps(scene, xoffset, &yoffset); } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 93354914390..98f5aab88ed 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1077,7 +1077,7 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) return name; } -static void draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect) +static void draw_viewport_name(ARegion *ar, View3D *v3d, int xoffset, int *yoffset) { RegionView3D *rv3d = ar->regiondata; const char *name = view3d_get_name(v3d, rv3d); @@ -1100,10 +1100,13 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect) } UI_FontThemeColor(BLF_default(), TH_TEXT_HI); + + *yoffset -= U.widget_unit; + #ifdef WITH_INTERNATIONAL - BLF_draw_default(U.widget_unit + rect->xmin, rect->ymax - U.widget_unit, 0.0f, name, sizeof(tmpstr)); + BLF_draw_default(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr)); #else - BLF_draw_default_ascii(U.widget_unit + rect->xmin, rect->ymax - U.widget_unit, 0.0f, name, sizeof(tmpstr)); + BLF_draw_default_ascii(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr)); #endif BLF_disable(font_id, BLF_SHADOW); @@ -1114,7 +1117,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, const rcti *rect) * framenum, object name, bone name (if available), marker name (if available) */ -static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) +static void draw_selected_name(Scene *scene, Object *ob, int xoffset, int *yoffset) { const int cfra = CFRA; const char *msg_pin = " (Pinned)"; @@ -1218,7 +1221,8 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f}); BLF_shadow_offset(font_id, 1, -1); - BLF_draw_default(rect->xmin + UI_UNIT_X, rect->ymax - (2 * U.widget_unit), 0.0f, info, sizeof(info)); + *yoffset -= U.widget_unit; + BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info)); BLF_disable(font_id, BLF_SHADOW); } @@ -1228,7 +1232,7 @@ static void draw_selected_name(Scene *scene, Object *ob, rcti *rect) /** * Information drawn on top of the solid plates and composed data */ -void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(offset)) +void view3d_draw_region_info(const bContext *C, ARegion *ar) { RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); @@ -1259,20 +1263,23 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(of draw_view_axis(rv3d, &rect); } + int xoffset = rect.xmin + U.widget_unit; + int yoffset = rect.ymax; + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 && (v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) { if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) { - ED_scene_draw_fps(scene, &rect); + ED_scene_draw_fps(scene, xoffset, &yoffset); } else if (U.uiflag & USER_SHOW_VIEWPORTNAME) { - draw_viewport_name(ar, v3d, &rect); + draw_viewport_name(ar, v3d, xoffset, &yoffset); } if (U.uiflag & USER_DRAWVIEWINFO) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - draw_selected_name(scene, ob, &rect); + draw_selected_name(scene, ob, xoffset, &yoffset); } #if 0 /* TODO */ @@ -1284,14 +1291,16 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar, const int UNUSED(of BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); } - BLF_draw_default_ascii( - rect.xmin + U.widget_unit, - rect.ymax - (USER_SHOW_VIEWPORTNAME ? 2 * U.widget_unit : U.widget_unit), 0.0f, - numstr[0] ? numstr : grid_unit, sizeof(numstr)); + *yoffset -= U.widget_unit; + BLF_draw_default_ascii(xoffset, *yoffset, numstr[0] ? numstr : grid_unit, sizeof(numstr)); } #endif } + if ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) { + DRW_draw_region_engine_info(xoffset, yoffset); + } + BLF_batch_draw_end(); } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 5fec606d4e3..f51a46cd95f 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -965,7 +965,7 @@ void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixSto * \note The info that this uses is updated in #ED_refresh_viewport_fps, * which currently gets called during #SCREEN_OT_animation_step. */ -void ED_scene_draw_fps(Scene *scene, const rcti *rect) +void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset) { ScreenFrameRateInfo *fpsi = scene->fps_info; char printable[16]; @@ -1012,11 +1012,19 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect) BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), (int)(fps + 0.5f)); } + BLF_enable(font_id, BLF_SHADOW); + BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f}); + BLF_shadow_offset(font_id, 1, -1); + + *yoffset -= U.widget_unit; + #ifdef WITH_INTERNATIONAL - BLF_draw_default(rect->xmin + U.widget_unit, rect->ymax - U.widget_unit, 0.0f, printable, sizeof(printable)); + BLF_draw_default(xoffset, *yoffset, 0.0f, printable, sizeof(printable)); #else - BLF_draw_default_ascii(rect->xmin + U.widget_unit, rect->ymax - U.widget_unit, 0.0f, printable, sizeof(printable)); + BLF_draw_default_ascii(xoffset, *yoffset, 0.0f, printable, sizeof(printable)); #endif + + BLF_disable(font_id, BLF_SHADOW); } static bool view3d_main_region_do_render_draw(const Scene *scene) diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index a7e3aaa7324..b3e77927024 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -142,7 +142,7 @@ int view3d_effective_drawtype(const struct View3D *v3d); /* view3d_draw.c */ void view3d_main_region_draw(const struct bContext *C, struct ARegion *ar); -void view3d_draw_region_info(const struct bContext *C, struct ARegion *ar, const int offset); +void view3d_draw_region_info(const struct bContext *C, struct ARegion *ar); void ED_view3d_draw_depth( struct Depsgraph *depsgraph, |