return 0;
}
-void chart_set_rgba(struct chart *chart, float red, float green, float blue, float alpha)
+void chart_set_mode(struct chart *chart, enum chart_mode mode)
{
- chart->rgb[0] = red;
- chart->rgb[1] = green;
- chart->rgb[2] = blue;
- chart->rgb[3] = alpha;
+ chart->mode = mode;
+}
+
+void chart_set_stroke_rgba(struct chart *chart, float red, float green, float blue, float alpha)
+{
+ chart->stroke_rgb[0] = red;
+ chart->stroke_rgb[1] = green;
+ chart->stroke_rgb[2] = blue;
+ chart->stroke_rgb[3] = alpha;
+}
+
+void chart_set_fill_rgba(struct chart *chart, float red, float green, float blue, float alpha)
+{
+ chart->fill_rgb[0] = red;
+ chart->fill_rgb[1] = green;
+ chart->fill_rgb[2] = blue;
+ chart->fill_rgb[3] = alpha;
}
void chart_set_position(struct chart *chart, int x, int y)
cairo_translate(cr, x, -chart->range[0]);
cairo_new_path(cr);
+ if (chart->mode != CHART_STROKE)
+ cairo_move_to(cr, 0, 0);
for (n = 0; n < max; n++) {
cairo_curve_to(cr,
n-2/3., value_at(chart, i + n -1) + gradient_at(chart, i + n - 1)/3.,
n-1/3., value_at(chart, i + n) - gradient_at(chart, i + n)/3.,
n, value_at(chart, i + n));
}
+ if (chart->mode != CHART_STROKE)
+ cairo_line_to(cr, max, 0);
cairo_identity_matrix(cr);
- cairo_set_line_width(cr, 1);
- cairo_set_source_rgba(cr, chart->rgb[0], chart->rgb[1], chart->rgb[2], chart->rgb[3]);
- cairo_stroke(cr);
-
+ cairo_set_line_width(cr, 2);
+ switch (chart->mode) {
+ case CHART_STROKE:
+ cairo_set_source_rgba(cr, chart->stroke_rgb[0], chart->stroke_rgb[1], chart->stroke_rgb[2], chart->stroke_rgb[3]);
+ cairo_stroke(cr);
+ break;
+ case CHART_FILL:
+ cairo_set_source_rgba(cr, chart->fill_rgb[0], chart->fill_rgb[1], chart->fill_rgb[2], chart->fill_rgb[3]);
+ cairo_fill(cr);
+ break;
+ case CHART_FILL_STROKE:
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+ cairo_set_source_rgba(cr, chart->fill_rgb[0], chart->fill_rgb[1], chart->fill_rgb[2], chart->fill_rgb[3]);
+ cairo_fill_preserve(cr);
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
+ cairo_set_source_rgba(cr, chart->stroke_rgb[0], chart->stroke_rgb[1], chart->stroke_rgb[2], chart->stroke_rgb[3]);
+ cairo_stroke(cr);
+ break;
+ }
cairo_restore(cr);
}
int num_samples;
int current_sample;
int range_automatic;
- float rgb[4];
+ float fill_rgb[4];
+ float stroke_rgb[4];
+ enum chart_mode {
+ CHART_STROKE = 0,
+ CHART_FILL,
+ CHART_FILL_STROKE,
+ } mode;
double range[2];
double *samples;
};
int chart_init(struct chart *chart, const char *name, int num_samples);
-void chart_set_rgba(struct chart *chart, float red, float green, float blue, float alpha);
+void chart_set_mode(struct chart *chart, enum chart_mode mode);
+void chart_set_fill_rgba(struct chart *chart, float red, float green, float blue, float alpha);
+void chart_set_stroke_rgba(struct chart *chart, float red, float green, float blue, float alpha);
void chart_set_position(struct chart *chart, int x, int y);
void chart_set_size(struct chart *chart, int w, int h);
void chart_set_range(struct chart *chart, double min, double max);
struct overlay_gpu_top {
struct gpu_top gpu_top;
- struct chart chart[MAX_RINGS];
+ struct chart busy[MAX_RINGS];
+ struct chart wait[MAX_RINGS];
};
static void init_gpu_top(struct overlay_gpu_top *gt,
gpu_top_init(>->gpu_top);
for (n = 0; n < gt->gpu_top.num_rings; n++) {
- chart_init(>->chart[n],
+ chart_init(>->busy[n],
gt->gpu_top.ring[n].name,
120);
- chart_set_position(>->chart[n], 12, 12);
- chart_set_size(>->chart[n],
+ chart_set_position(>->busy[n], 12, 12);
+ chart_set_size(>->busy[n],
cairo_image_surface_get_width(surface)-24,
100);
- chart_set_rgba(>->chart[n],
- rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3]);
- chart_set_range(>->chart[n], 0, 100);
+ chart_set_stroke_rgba(>->busy[n],
+ rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3]);
+ chart_set_mode(>->busy[n], CHART_STROKE);
+ chart_set_range(>->busy[n], 0, 100);
+ }
+
+ for (n = 0; n < gt->gpu_top.num_rings; n++) {
+ chart_init(>->wait[n],
+ gt->gpu_top.ring[n].name,
+ 120);
+ chart_set_position(>->wait[n], 12, 12);
+ chart_set_size(>->wait[n],
+ cairo_image_surface_get_width(surface)-24,
+ 100);
+ chart_set_fill_rgba(>->wait[n],
+ rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3] * 0.70);
+ chart_set_mode(>->wait[n], CHART_FILL);
+ chart_set_range(>->wait[n], 0, 100);
}
}
update = gpu_top_update(>->gpu_top);
for (n = 0; n < gt->gpu_top.num_rings; n++) {
if (update)
- chart_add_sample(>->chart[n],
+ chart_add_sample(>->wait[n],
+ gt->gpu_top.ring[n].u.u.wait + gt->gpu_top.ring[n].u.u.sema);
+ chart_draw(>->wait[n], cr);
+ }
+ for (n = 0; n < gt->gpu_top.num_rings; n++) {
+ if (update)
+ chart_add_sample(>->busy[n],
gt->gpu_top.ring[n].u.u.busy);
- chart_draw(>->chart[n], cr);
+ chart_draw(>->busy[n], cr);
}
cairo_set_source_rgb(cr, 1, 1, 1);