From 80b8b9c8a4557f178d01d98bc88c9b2f944af305 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 25 Dec 2016 20:21:21 +0100 Subject: [PATCH] gallium/hud: add an option to reset the color counter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/gallium/auxiliary/hud/hud_context.c | 21 ++++++++++++++++++--- src/gallium/auxiliary/hud/hud_private.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 3299b90..4e2c789 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -824,7 +824,7 @@ hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr) {0.5, 0, 0.5}, {0.5, 0.5, 0}, }; - unsigned color = pane->num_graphs % ARRAY_SIZE(colors); + unsigned color = pane->next_color % ARRAY_SIZE(colors); strip_hyphens(gr->name); @@ -835,6 +835,7 @@ hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr) gr->pane = pane; LIST_ADDTAIL(&gr->head, &pane->graph_list); pane->num_graphs++; + pane->next_color++; } void @@ -926,7 +927,8 @@ parse_string(const char *s, char *out) static char * read_pane_settings(char *str, unsigned * const x, unsigned * const y, unsigned * const width, unsigned * const height, - uint64_t * const ceiling, boolean * const dyn_ceiling) + uint64_t * const ceiling, boolean * const dyn_ceiling, + boolean *reset_colors) { char *ret = str; unsigned tmp; @@ -977,6 +979,12 @@ read_pane_settings(char *str, unsigned * const x, unsigned * const y, *dyn_ceiling = true; break; + case 'r': + ++str; + ret = str; + *reset_colors = true; + break; + default: fprintf(stderr, "gallium_hud: syntax error: unexpected '%c'\n", *str); fflush(stderr); @@ -1018,6 +1026,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) uint64_t ceiling = UINT64_MAX; unsigned column_width = 251; boolean dyn_ceiling = false; + boolean reset_colors = false; const char *period_env; /* @@ -1038,7 +1047,7 @@ hud_parse_env_var(struct hud_context *hud, const char *env) /* check for explicit location, size and etc. settings */ name = read_pane_settings(name_a, &x, &y, &width, &height, &ceiling, - &dyn_ceiling); + &dyn_ceiling, &reset_colors); /* * Keep track of overall column width to avoid pane overlapping in case @@ -1054,6 +1063,11 @@ hud_parse_env_var(struct hud_context *hud, const char *env) return; } + if (reset_colors) { + pane->next_color = 0; + reset_colors = false; + } + /* Add a graph. */ #if HAVE_GALLIUM_EXTRA_HUD || HAVE_LIBSENSORS char arg_name[64]; @@ -1329,6 +1343,7 @@ print_help(struct pipe_screen *screen) puts(" the ceiling allows, the value is clamped."); puts(" 'd' activates dynamic Y axis readjustment to set the value of"); puts(" the Y axis to match the highest value still visible in the graph."); + puts(" 'r' resets the color counter (the next color will be green)"); puts(""); puts(" If 'c' and 'd' modifiers are used simultaneously, both are in effect:"); puts(" the Y axis does not go above the restriction imposed by 'c' while"); diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 5132b3d..479ece5 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -73,6 +73,7 @@ struct hud_pane { struct list_head graph_list; unsigned num_graphs; + unsigned next_color; }; -- 2.7.4