summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-08-18 17:54:13 +0200
committerMarek Olšák <[email protected]>2016-08-22 16:01:35 +0200
commit0f1befe926e793040f73b884c9b4f1b8a4bd25a6 (patch)
tree31308c676fc02668fd2e99b00d8e046111bbfc01
parenta33eb48d6111cb679a5ce8b35c5d7e4854f0045d (diff)
gallium/hud: generalize code for drawing numbers next to graphs
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index f7baccd760c..ac971d8665d 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -344,6 +344,7 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
float *line_verts = hud->whitelines.vertices + hud->whitelines.num_vertices*2;
unsigned i, num = 0;
char str[32];
+ const unsigned last_line = 5;
/* draw background */
hud_draw_background_quad(hud,
@@ -351,12 +352,13 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
pane->x2, pane->y2);
/* draw numbers on the right-hand side */
- for (i = 0; i < 6; i++) {
+ for (i = 0; i <= last_line; i++) {
unsigned x = pane->x2 + 2;
- unsigned y = pane->inner_y1 + pane->inner_height * (5 - i) / 5 -
+ unsigned y = pane->inner_y1 +
+ pane->inner_height * (last_line - i) / last_line -
hud->font.glyph_height / 2;
- number_to_human_readable(pane->max_value * i / 5, pane->max_value,
+ number_to_human_readable(pane->max_value * i / last_line, pane->max_value,
pane->type, str);
hud_draw_string(hud, x, y, "%s", str);
}
@@ -396,8 +398,9 @@ hud_pane_accumulate_vertices(struct hud_context *hud,
line_verts[num++] = (float) pane->y2;
/* draw horizontal lines inside the graph */
- for (i = 0; i <= 5; i++) {
- float y = round((pane->max_value * i / 5.0) * pane->yscale + pane->inner_y2);
+ for (i = 0; i <= last_line; i++) {
+ float y = round((pane->max_value * i / (double)last_line) *
+ pane->yscale + pane->inner_y2);
assert(hud->whitelines.num_vertices + num/2 + 2 <= hud->whitelines.max_num_vertices);
line_verts[num++] = pane->x1;