summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-12-25 20:21:21 +0100
committerMarek Olšák <[email protected]>2017-01-05 18:30:00 +0100
commit80b8b9c8a4557f178d01d98bc88c9b2f944af305 (patch)
tree1a370220a81a2f1c3410336e45fec67b661fe436
parenta57e071e9ec341d094df0cdc36d18326b61ffd21 (diff)
gallium/hud: add an option to reset the color counter
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c21
-rw-r--r--src/gallium/auxiliary/hud/hud_private.h1
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 3299b90bb31..4e2c789d19c 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 5132b3d2c4f..479ece51dbc 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;
};