#define is_power_of_two(x) (((x) & ((x)-1)) == 0)
+#define PAD 10
+#define HALF_PAD 5
+#define SIZE_PAD (PAD + HALF_PAD)
+
const cairo_user_data_key_t overlay_key;
static void overlay_show(cairo_surface_t *surface)
memset(>->cpu, 0, sizeof(gt->cpu));
chart_init(>->cpu, "CPU", 120);
- chart_set_position(>->cpu, 12, 12);
- chart_set_size(>->cpu, ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(>->cpu, PAD, PAD);
+ chart_set_size(>->cpu, ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
chart_set_stroke_rgba(>->cpu, 0.75, 0.25, 0.75, 1.);
chart_set_mode(>->cpu, CHART_STROKE);
chart_set_range(>->cpu, 0, 100);
chart_init(>->busy[n],
gt->gpu_top.ring[n].name,
120);
- chart_set_position(>->busy[n], 12, 12);
- chart_set_size(>->busy[n], ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(>->busy[n], PAD, PAD);
+ chart_set_size(>->busy[n], ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
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_init(>->wait[n],
gt->gpu_top.ring[n].name,
120);
- chart_set_position(>->wait[n], 12, 12);
- chart_set_size(>->wait[n], ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(>->wait[n], PAD, PAD);
+ chart_set_size(>->wait[n], ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
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);
update = gpu_top_update(>->gpu_top);
- cairo_rectangle(ctx->cr, 12-.5, 12-.5, ctx->width/2-18+1, ctx->height/2-18+1);
+ cairo_rectangle(ctx->cr, PAD-.5, PAD-.5, ctx->width/2-SIZE_PAD+1, ctx->height/2-SIZE_PAD+1);
cairo_set_source_rgb(ctx->cr, .15, .15, .15);
cairo_set_line_width(ctx->cr, 1);
cairo_stroke(ctx->cr);
}
chart_draw(>->cpu, ctx->cr);
- y1 = 12 - 2;
+ y1 = PAD - 2;
y2 = y1 + (gt->gpu_top.num_rings+1) * 14 + 4;
- cairo_rectangle(ctx->cr, 12, y1, ctx->width/2-18, y2-y1);
- linear = cairo_pattern_create_linear(12, 0, 12+ctx->width/2-18, 0);
+ cairo_rectangle(ctx->cr, PAD, y1, ctx->width/2-SIZE_PAD, y2-y1);
+ linear = cairo_pattern_create_linear(PAD, 0, PAD+ctx->width/2-SIZE_PAD, 0);
cairo_pattern_add_color_stop_rgba(linear, 0, 0, 0, 0, .5);
cairo_pattern_add_color_stop_rgba(linear, 1, 0, 0, 0, .0);
cairo_set_source(ctx->cr, linear);
cairo_pattern_destroy(linear);
cairo_fill(ctx->cr);
- y = 12 + 12 - 2;
+ y = PAD + 12 - 2;
cairo_set_source_rgba(ctx->cr, 0.75, 0.25, 0.75, 1.);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
sprintf(txt, "CPU: %d%% busy", gt->cpu_top.busy);
cairo_show_text(ctx->cr, txt);
y += 14;
c->stroke_rgb[1],
c->stroke_rgb[2],
c->stroke_rgb[3]);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
cairo_show_text(ctx->cr, txt);
y += 14;
}
cairo_pattern_t *linear;
int x, y, y1, y2, n;
- cairo_rectangle(ctx->cr, ctx->width/2+6-.5, 12-.5, ctx->width/2-18+1, ctx->height/2-18+1);
+ cairo_rectangle(ctx->cr, ctx->width/2+HALF_PAD-.5, PAD-.5, ctx->width/2-SIZE_PAD+1, ctx->height/2-SIZE_PAD+1);
cairo_set_source_rgb(ctx->cr, .15, .15, .15);
cairo_set_line_width(ctx->cr, 1);
cairo_stroke(ctx->cr);
cairo_text_extents_t extents;
cairo_text_extents(ctx->cr, gp->gpu_perf.error, &extents);
cairo_move_to(ctx->cr,
- ctx->width/2+6 + (ctx->width/2-18 - extents.width)/2.,
- 12 + (ctx->height/2-18 + extents.height)/2.);
+ ctx->width/2+HALF_PAD + (ctx->width/2-SIZE_PAD - extents.width)/2.,
+ PAD + (ctx->height/2-SIZE_PAD + extents.height)/2.);
cairo_show_text(ctx->cr, gp->gpu_perf.error);
return;
}
gpu_perf_update(&gp->gpu_perf);
- y = 12 + 12 - 2;
- x = ctx->width/2 + 6;
+ y = PAD + 12 - 2;
+ x = ctx->width/2 + HALF_PAD;
for (comm = gp->gpu_perf.comm; comm; comm = comm->next) {
continue;
chart_init(comm->user_data, comm->name, 120);
- chart_set_position(comm->user_data, ctx->width/2+6, 12);
- chart_set_size(comm->user_data, ctx->width/2-18, ctx->height/2 - 18);
+ chart_set_position(comm->user_data, ctx->width/2+HALF_PAD, PAD);
+ chart_set_size(comm->user_data, ctx->width/2-SIZE_PAD, ctx->height/2 - SIZE_PAD);
chart_set_mode(comm->user_data, CHART_STROKE);
chart_set_stroke_rgba(comm->user_data,
rgba[last_color][0],
y1 += -12 - 2;
y2 += 14 - 14 + 4;
- cairo_rectangle(ctx->cr, x, y1, ctx->width/2-18, y2-y1);
- linear = cairo_pattern_create_linear(x, 0, x + ctx->width/2-18, 0);
+ cairo_rectangle(ctx->cr, x, y1, ctx->width/2-SIZE_PAD, y2-y1);
+ linear = cairo_pattern_create_linear(x, 0, x + ctx->width/2-SIZE_PAD, 0);
cairo_pattern_add_color_stop_rgba(linear, 0, 0, 0, 0, .5);
cairo_pattern_add_color_stop_rgba(linear, 1, 0, 0, 0, .0);
cairo_set_source(ctx->cr, linear);
{
if (gpu_freq_init(&gf->gpu_freq) == 0) {
chart_init(&gf->current, "current", 120);
- chart_set_position(&gf->current, 12, ctx->height/2 + 6);
- chart_set_size(&gf->current, ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(&gf->current, PAD, ctx->height/2 + HALF_PAD);
+ chart_set_size(&gf->current, ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
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);
- chart_set_position(&gf->request, 12, ctx->height/2 + 6);
- chart_set_size(&gf->request, ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(&gf->request, PAD, ctx->height/2 + HALF_PAD);
+ chart_set_size(&gf->request, ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
chart_set_fill_rgba(&gf->request, 0.25, 0.25, 0.50, 1.);
chart_set_mode(&gf->request, CHART_FILL);
chart_set_smooth(&gf->request, CHART_LINE);
if (power_init(&gf->power) == 0) {
chart_init(&gf->power_chart, "power", 120);
- chart_set_position(&gf->power_chart, 12, ctx->height/2 + 6);
- chart_set_size(&gf->power_chart, ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(&gf->power_chart, PAD, ctx->height/2 + HALF_PAD);
+ chart_set_size(&gf->power_chart, ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
chart_set_stroke_rgba(&gf->power_chart, 0.45, 0.55, 0.45, 1.);
gf->power_max = 0;
}
int has_irqs = gem_interrupts_update(&gf->irqs) == 0;
cairo_pattern_t *linear;
- cairo_rectangle(ctx->cr, 12-.5, ctx->height/2+6-.5, ctx->width/2-18+1, ctx->height/2-18+1);
+ cairo_rectangle(ctx->cr, PAD-.5, ctx->height/2+HALF_PAD-.5, ctx->width/2-SIZE_PAD+1, ctx->height/2-SIZE_PAD+1);
cairo_set_source_rgb(ctx->cr, .15, .15, .15);
cairo_set_line_width(ctx->cr, 1);
cairo_stroke(ctx->cr);
cairo_text_extents_t extents;
cairo_text_extents(ctx->cr, txt, &extents);
cairo_move_to(ctx->cr,
- 12 + (ctx->width/2-18 - extents.width)/2.,
- ctx->height/2+6 + (ctx->height/2-18 + extents.height)/2.);
+ PAD + (ctx->width/2-SIZE_PAD - extents.width)/2.,
+ ctx->height/2+HALF_PAD + (ctx->height/2-SIZE_PAD + extents.height)/2.);
cairo_show_text(ctx->cr, txt);
return;
}
chart_draw(&gf->power_chart, ctx->cr);
}
- y = ctx->height/2 + 6 + 12 - 2;
+ y = ctx->height/2 + HALF_PAD + 12 - 2;
y1 = y2 = y;
if (has_freq) {
y1 += -12 - 2;
y2 += -14 + 4;
- cairo_rectangle(ctx->cr, 12, y1, ctx->width/2-18, y2-y1);
- linear = cairo_pattern_create_linear(12, 0, 12+ctx->width/2-18, 0);
+ cairo_rectangle(ctx->cr, PAD, y1, ctx->width/2-SIZE_PAD, y2-y1);
+ linear = cairo_pattern_create_linear(PAD, 0, PAD+ctx->width/2-SIZE_PAD, 0);
cairo_pattern_add_color_stop_rgba(linear, 0, 0, 0, 0, .5);
cairo_pattern_add_color_stop_rgba(linear, 1, 0, 0, 0, .0);
cairo_set_source(ctx->cr, linear);
if (gf->gpu_freq.request)
sprintf(buf + len, " (requested %dMHz)", gf->gpu_freq.request);
cairo_set_source_rgba(ctx->cr, 1, 1, 1, 1);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
cairo_show_text(ctx->cr, buf);
y += 14;
sprintf(buf, "min: %dMHz, max: %dMHz", gf->gpu_freq.min, gf->gpu_freq.max);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
cairo_show_text(ctx->cr, buf);
y += 14;
}
if (has_rc6) {
sprintf(buf, "RC6: %d%%", gf->rc6.rc6_combined);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
cairo_show_text(ctx->cr, buf);
if (gf->rc6.rc6_combined && !is_power_of_two(gf->rc6.enabled)) {
char *txt;
if (has_power) {
sprintf(buf, "Power: %llumW", (long long unsigned)gf->power.power_mW);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
cairo_show_text(ctx->cr, buf);
y += 14;
}
if (has_irqs) {
sprintf(buf, "Interrupts: %llu", (long long unsigned)gf->irqs.delta);
- cairo_move_to(ctx->cr, 12, y);
+ cairo_move_to(ctx->cr, PAD, y);
cairo_show_text(ctx->cr, buf);
y += 14;
}
return;
chart_init(&go->aperture, "aperture", 120);
- chart_set_position(&go->aperture, ctx->width/2+6, ctx->height/2 + 6);
- chart_set_size(&go->aperture, ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(&go->aperture, ctx->width/2+HALF_PAD, ctx->height/2 + HALF_PAD);
+ chart_set_size(&go->aperture, ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
chart_set_stroke_rgba(&go->aperture, 0.75, 0.25, 0.50, 1.);
chart_set_mode(&go->aperture, CHART_STROKE);
chart_set_range(&go->aperture, 0, go->gem_objects.max_gtt);
chart_init(&go->gtt, "gtt", 120);
- chart_set_position(&go->gtt, ctx->width/2+6, ctx->height/2 + 6);
- chart_set_size(&go->gtt, ctx->width/2 - 18, ctx->height/2 - 18);
+ chart_set_position(&go->gtt, ctx->width/2+HALF_PAD, ctx->height/2 + HALF_PAD);
+ chart_set_size(&go->gtt, ctx->width/2 - SIZE_PAD, ctx->height/2 - SIZE_PAD);
chart_set_fill_rgba(&go->gtt, 0.25, 0.5, 0.5, 1.);
chart_set_mode(&go->gtt, CHART_FILL);
chart_set_range(&go->gtt, 0, go->gem_objects.max_gtt);
if (go->error)
return;
- cairo_rectangle(ctx->cr, ctx->width/2+6-.5, ctx->height/2+6-.5, ctx->width/2-18+1, ctx->height/2-18+1);
+ cairo_rectangle(ctx->cr, ctx->width/2+HALF_PAD-.5, ctx->height/2+HALF_PAD-.5, ctx->width/2-SIZE_PAD+1, ctx->height/2-SIZE_PAD+1);
cairo_set_source_rgb(ctx->cr, .15, .15, .15);
cairo_set_line_width(ctx->cr, 1);
cairo_stroke(ctx->cr);
chart_draw(&go->aperture, ctx->cr);
- y = ctx->height/2 + 6 + 12 - 2;
- x = ctx->width/2 + 6;
+ y = ctx->height/2 + HALF_PAD + 12 - 2;
+ x = ctx->width/2 + HALF_PAD;
y2 = y1 = y;
y2 += 14;
y1 += -12 - 2;
y2 += -14 + 4;
- cairo_rectangle(ctx->cr, x, y1, ctx->width/2-18, y2-y1);
- linear = cairo_pattern_create_linear(x, 0, x+ctx->width/2-18, 0);
+ cairo_rectangle(ctx->cr, x, y1, ctx->width/2-SIZE_PAD, y2-y1);
+ linear = cairo_pattern_create_linear(x, 0, x+ctx->width/2-SIZE_PAD, 0);
cairo_pattern_add_color_stop_rgba(linear, 0, 0, 0, 0, .5);
cairo_pattern_add_color_stop_rgba(linear, 1, 0, 0, 0, .0);
cairo_set_source(ctx->cr, linear);
cairo_text_extents_t extents;
gethostname(buf, sizeof(buf));
cairo_set_source_rgb(ctx.cr, .5, .5, .5);
- cairo_set_font_size(ctx.cr, 10);
+ cairo_set_font_size(ctx.cr, PAD-2);
cairo_text_extents(ctx.cr, buf, &extents);
cairo_move_to(ctx.cr,
(ctx.width-extents.width)/2.,