Draw Manager: Combine multiple engines info texts

This join them with \n separators.(right now they clash on top of each
other).

Note: We still need to change "ED_region_info_draw" to accept multi-line strings.
This commit is contained in:
Dalai Felinto 2017-05-04 19:35:53 +02:00
parent 5b70283717
commit b5b9b2d04d
Notes: blender-bot 2023-02-14 08:06:38 +01:00
Referenced by issue #51391, Fix Cycles render stats on render preview
1 changed files with 23 additions and 4 deletions

View File

@ -2061,16 +2061,23 @@ static void DRW_engines_draw_text(void)
*/
int DRW_draw_region_engine_info_offset()
{
int offset = 0;
int lines = 0;
for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
/* Count the number of lines. */
if (data->info[0] != '\0') {
offset += UI_UNIT_Y;
lines++;
char *c = data->info;
while (*c++ != '\0') {
if (*c == '\n') {
lines++;
}
}
}
}
return offset;
return lines * UI_UNIT_Y;
}
/**
@ -2078,6 +2085,9 @@ int DRW_draw_region_engine_info_offset()
*/
void DRW_draw_region_engine_info()
{
char info[GPU_INFO_SIZE * 5] = {0}; /* This should be maxium number of engines running at the same time. */
char *str_start = info;
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};
@ -2090,9 +2100,18 @@ void DRW_draw_region_engine_info()
ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
if (data->info[0] != '\0') {
ED_region_info_draw(ar, data->info, fill_color, true);
BLI_strncpy(str_start, data->info, sizeof(info) - (str_start - info));
str_start += BLI_strnlen(data->info, sizeof(data->info));
*str_start++ = '\n';
}
}
if (info[0] != '\0') {
if (str_start != info) {
*(str_start - 1) = '\0';
}
ED_region_info_draw(ar, info, fill_color, true);
}
}
static void use_drw_engine(DrawEngineType *engine)