overlay: Don't smooth gpu freq

This is supposed to be discrete jumps, so use straight lines to emphasis
this nature.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-18 19:16:29 +01:00
parent 90ef68859c
commit 1391ae08eb
3 changed files with 25 additions and 4 deletions

View File

@ -18,6 +18,7 @@ int chart_init(struct chart *chart, const char *name, int num_samples)
chart->num_samples = num_samples;
chart->range_automatic = 1;
chart->stroke_width = 2;
chart->smooth = CHART_CURVE;
return 0;
}
@ -26,6 +27,11 @@ void chart_set_mode(struct chart *chart, enum chart_mode mode)
chart->mode = mode;
}
void chart_set_smooth(struct chart *chart, enum chart_smooth smooth)
{
chart->smooth = smooth;
}
void chart_set_stroke_width(struct chart *chart, float width)
{
chart->stroke_width = width;
@ -159,10 +165,18 @@ void chart_draw(struct chart *chart, cairo_t *cr)
if (chart->mode != CHART_STROKE)
cairo_move_to(cr, 0, 0);
for (n = 0; n < max; n++) {
switch (chart->smooth) {
case CHART_LINE:
cairo_line_to(cr,
n, value_at(chart, i + n));
break;
case CHART_CURVE:
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));
break;
}
}
if (chart->mode != CHART_STROKE)
cairo_line_to(cr, n-1, 0);

View File

@ -9,6 +9,10 @@ struct chart {
CHART_FILL,
CHART_FILL_STROKE,
} mode;
enum chart_smooth {
CHART_LINE = 0,
CHART_CURVE,
} smooth;
float fill_rgb[4];
float stroke_rgb[4];
double stroke_width;
@ -18,6 +22,7 @@ struct chart {
int chart_init(struct chart *chart, const char *name, int num_samples);
void chart_set_mode(struct chart *chart, enum chart_mode mode);
void chart_set_smooth(struct chart *chart, enum chart_smooth smooth);
void chart_set_fill_rgba(struct chart *chart, float red, float green, float blue, float alpha);
void chart_set_stroke_width(struct chart *chart, float width);
void chart_set_stroke_rgba(struct chart *chart, float red, float green, float blue, float alpha);

View File

@ -391,6 +391,7 @@ static void init_gpu_freq(struct overlay_context *ctx,
chart_set_size(&gf->current, ctx->width/2 - 18, ctx->height/2 - 18);
chart_set_stroke_rgba(&gf->current, 0.75, 0.25, 0.50, 1.);
chart_set_mode(&gf->current, CHART_STROKE);
chart_set_smooth(&gf->current, CHART_LINE);
chart_set_range(&gf->current, 0, gf->gpu_freq.max);
chart_init(&gf->request, "request", 120);
@ -398,6 +399,7 @@ static void init_gpu_freq(struct overlay_context *ctx,
chart_set_size(&gf->request, ctx->width/2 - 18, ctx->height/2 - 18);
chart_set_fill_rgba(&gf->request, 0.25, 0.75, 0.50, 1.);
chart_set_mode(&gf->request, CHART_FILL);
chart_set_smooth(&gf->request, CHART_LINE);
chart_set_range(&gf->request, 0, gf->gpu_freq.max);
}