gallium/hud: add an option to reset the color counter

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
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 @@
       {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 @@
    gr->pane = pane;
    LIST_ADDTAIL(&gr->head, &pane->graph_list);
    pane->num_graphs++;
+   pane->next_color++;
 }
 
 void
@@ -926,7 +927,8 @@
 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 @@
          *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 @@
    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 @@
 
       /* 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 @@
             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 @@
    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 list_head graph_list;
    unsigned num_graphs;
+   unsigned next_color;
 };