diff options
author | Marek Olšák <[email protected]> | 2015-08-02 18:11:55 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-08-06 20:44:36 +0200 |
commit | dbfeb0ec12d6550e68de1bcd164e422e79bccf2d (patch) | |
tree | 371bee1ada2058b53320b8bca1616c5e1418d2b6 /src/gallium/auxiliary/hud/hud_context.c | |
parent | 4e2a3e0376ca4fe39ca05e80557edfaa12e93e2b (diff) |
gallium/hud: automatically print % if max_value == 100
Reviewed-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/hud/hud_context.c')
-rw-r--r-- | src/gallium/auxiliary/hud/hud_context.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 275070d1664..95eed2698bc 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -231,8 +231,8 @@ hud_draw_string(struct hud_context *hud, unsigned x, unsigned y, } static void -number_to_human_readable(uint64_t num, enum pipe_driver_query_type type, - char *out) +number_to_human_readable(uint64_t num, uint64_t max_value, + enum pipe_driver_query_type type, char *out) { static const char *byte_units[] = {" 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; break; default: - max_unit = ARRAY_SIZE(metric_units)-1; - units = metric_units; + if (max_value == 100) { + 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) { @@ -330,7 +335,7 @@ hud_pane_accumulate_vertices(struct hud_context *hud, unsigned y = pane->inner_y1 + pane->inner_height * (5 - i) / 5 - 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); 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 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); hud_draw_string(hud, x, y, " %s: %s", gr->name, str); i++; |