const struct pipe_sampler_state *sampler_states[] =
{ &hud->font_sampler_state };
struct hud_pane *pane;
- struct hud_graph *gr;
+ struct hud_graph *gr, *next;
if (!huds_visible)
return;
gr->query_new_value(gr);
}
+ if (pane->sort_items) {
+ LIST_FOR_EACH_ENTRY_SAFE(gr, next, &pane->graph_list, head) {
+ /* ignore the last one */
+ if (&gr->head == pane->graph_list.prev)
+ continue;
+
+ /* This is an incremental bubble sort, because we only do one pass
+ * per frame. It will eventually reach an equilibrium.
+ */
+ if (gr->current_value <
+ LIST_ENTRY(struct hud_graph, next, head)->current_value) {
+ LIST_DEL(&gr->head);
+ LIST_ADD(&gr->head, &next->head);
+ }
+ }
+ }
+
hud_pane_accumulate_vertices(hud, pane);
}
static struct hud_pane *
hud_pane_create(unsigned x1, unsigned y1, unsigned x2, unsigned y2,
unsigned period, uint64_t max_value, uint64_t ceiling,
- boolean dyn_ceiling)
+ boolean dyn_ceiling, boolean sort_items)
{
struct hud_pane *pane = CALLOC_STRUCT(hud_pane);
pane->ceiling = ceiling;
pane->dyn_ceiling = dyn_ceiling;
pane->dyn_ceil_last_ran = 0;
+ pane->sort_items = sort_items;
pane->initial_max_value = max_value;
hud_pane_set_max_value(pane, max_value);
LIST_INITHEAD(&pane->graph_list);
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,
- boolean *reset_colors)
+ boolean *reset_colors, boolean *sort_items)
{
char *ret = str;
unsigned tmp;
*reset_colors = true;
break;
+ case 's':
+ ++str;
+ ret = str;
+ *sort_items = true;
+ break;
+
default:
fprintf(stderr, "gallium_hud: syntax error: unexpected '%c'\n", *str);
fflush(stderr);
unsigned column_width = 251;
boolean dyn_ceiling = false;
boolean reset_colors = false;
+ boolean sort_items = false;
const char *period_env;
/*
/* check for explicit location, size and etc. settings */
name = read_pane_settings(name_a, &x, &y, &width, &height, &ceiling,
- &dyn_ceiling, &reset_colors);
+ &dyn_ceiling, &reset_colors, &sort_items);
/*
* Keep track of overall column width to avoid pane overlapping in case
if (!pane) {
pane = hud_pane_create(x, y, x + width, y + height, period, 10,
- ceiling, dyn_ceiling);
+ ceiling, dyn_ceiling, sort_items);
if (!pane)
return;
}
width = 251;
ceiling = UINT64_MAX;
dyn_ceiling = false;
+ sort_items = false;
}
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(" 's' sort items below graphs in descending order");
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");