mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 09:00:10 +01:00
gallium/hud: automatically print % if max_value == 100
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
parent
4e2a3e0376
commit
dbfeb0ec12
1 changed files with 11 additions and 6 deletions
|
|
@ -231,8 +231,8 @@ hud_draw_string(struct hud_context *hud, unsigned x, unsigned y,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
number_to_human_readable(uint64_t num, enum pipe_driver_query_type type,
|
number_to_human_readable(uint64_t num, uint64_t max_value,
|
||||||
char *out)
|
enum pipe_driver_query_type type, char *out)
|
||||||
{
|
{
|
||||||
static const char *byte_units[] =
|
static const char *byte_units[] =
|
||||||
{" B", " KB", " MB", " GB", " TB", " PB", " EB"};
|
{" B", " KB", " MB", " GB", " TB", " PB", " EB"};
|
||||||
|
|
@ -268,8 +268,13 @@ number_to_human_readable(uint64_t num, enum pipe_driver_query_type type,
|
||||||
units = hz_units;
|
units = hz_units;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
max_unit = ARRAY_SIZE(metric_units)-1;
|
if (max_value == 100) {
|
||||||
units = metric_units;
|
max_unit = ARRAY_SIZE(percent_units)-1;
|
||||||
|
units = percent_units;
|
||||||
|
} else {
|
||||||
|
max_unit = ARRAY_SIZE(metric_units)-1;
|
||||||
|
units = metric_units;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (d > divisor && unit < max_unit) {
|
while (d > divisor && unit < max_unit) {
|
||||||
|
|
@ -330,7 +335,7 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
|
||||||
unsigned y = pane->inner_y1 + pane->inner_height * (5 - i) / 5 -
|
unsigned y = pane->inner_y1 + pane->inner_height * (5 - i) / 5 -
|
||||||
hud->font.glyph_height / 2;
|
hud->font.glyph_height / 2;
|
||||||
|
|
||||||
number_to_human_readable(pane->max_value * i / 5,
|
number_to_human_readable(pane->max_value * i / 5, pane->max_value,
|
||||||
pane->type, str);
|
pane->type, str);
|
||||||
hud_draw_string(hud, x, y, "%s", str);
|
hud_draw_string(hud, x, y, "%s", str);
|
||||||
}
|
}
|
||||||
|
|
@ -341,7 +346,7 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
|
||||||
unsigned x = pane->x1 + 2;
|
unsigned x = pane->x1 + 2;
|
||||||
unsigned y = pane->y2 + 2 + i*hud->font.glyph_height;
|
unsigned y = pane->y2 + 2 + i*hud->font.glyph_height;
|
||||||
|
|
||||||
number_to_human_readable(gr->current_value,
|
number_to_human_readable(gr->current_value, pane->max_value,
|
||||||
pane->type, str);
|
pane->type, str);
|
||||||
hud_draw_string(hud, x, y, " %s: %s", gr->name, str);
|
hud_draw_string(hud, x, y, " %s: %s", gr->name, str);
|
||||||
i++;
|
i++;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue