summaryrefslogtreecommitdiff
path: root/overlay
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-18 19:16:29 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-18 19:21:02 +0100
commit1391ae08eb007205ad79d4201c3bf499239f8697 (patch)
tree1f4960adfe61d7b0fe7e6f39c5afa5c1d964c99d /overlay
parent90ef68859c3e5edf2a6cd6b274f0443b936c9e0d (diff)
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>
Diffstat (limited to 'overlay')
-rw-r--r--overlay/chart.c22
-rw-r--r--overlay/chart.h5
-rw-r--r--overlay/overlay.c2
3 files changed, 25 insertions, 4 deletions
diff --git a/overlay/chart.c b/overlay/chart.c
index bc0489cd..d72fe758 100644
--- a/overlay/chart.c
+++ b/overlay/chart.c
@@ -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++) {
- 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));
+ 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);
diff --git a/overlay/chart.h b/overlay/chart.h
index 9ede8de2..2ff4f440 100644
--- a/overlay/chart.h
+++ b/overlay/chart.h
@@ -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);
diff --git a/overlay/overlay.c b/overlay/overlay.c
index 65197a0f..aaf0f0cd 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -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);
}