mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 02:16:17 +00:00
overlay: Rearrange GUI state
Planning a new layout... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
7d950fa6f2
commit
74032f4b45
@ -54,11 +54,6 @@ static void overlay_hide(cairo_surface_t *surface)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct overlay_context {
|
|
||||||
cairo_t *cr;
|
|
||||||
int last_y;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct overlay_gpu_top {
|
struct overlay_gpu_top {
|
||||||
struct gpu_top gpu_top;
|
struct gpu_top gpu_top;
|
||||||
struct cpu_top cpu_top;
|
struct cpu_top cpu_top;
|
||||||
@ -67,8 +62,38 @@ struct overlay_gpu_top {
|
|||||||
struct chart cpu;
|
struct chart cpu;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_gpu_top(struct overlay_gpu_top *gt,
|
struct overlay_gpu_perf {
|
||||||
cairo_surface_t *surface)
|
struct gpu_perf gpu_perf;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct overlay_gpu_freq {
|
||||||
|
struct gpu_freq gpu_freq;
|
||||||
|
struct chart current;
|
||||||
|
struct chart request;
|
||||||
|
int error;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct overlay_gem_objects {
|
||||||
|
struct gem_objects gem_objects;
|
||||||
|
struct chart aperture;
|
||||||
|
struct chart gtt;
|
||||||
|
int error;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct overlay_context {
|
||||||
|
cairo_surface_t *surface;
|
||||||
|
cairo_t *cr;
|
||||||
|
int width, height;
|
||||||
|
int last_y;
|
||||||
|
|
||||||
|
struct overlay_gpu_top gpu_top;
|
||||||
|
struct overlay_gpu_perf gpu_perf;
|
||||||
|
struct overlay_gpu_freq gpu_freq;
|
||||||
|
struct overlay_gem_objects gem_objects;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void init_gpu_top(struct overlay_context *ctx,
|
||||||
|
struct overlay_gpu_top *gt)
|
||||||
{
|
{
|
||||||
const double rgba[][4] = {
|
const double rgba[][4] = {
|
||||||
{ 1, 0.25, 0.25, 1 },
|
{ 1, 0.25, 0.25, 1 },
|
||||||
@ -83,9 +108,7 @@ static void init_gpu_top(struct overlay_gpu_top *gt,
|
|||||||
|
|
||||||
chart_init(>->cpu, "CPU", 120);
|
chart_init(>->cpu, "CPU", 120);
|
||||||
chart_set_position(>->cpu, 12, 12);
|
chart_set_position(>->cpu, 12, 12);
|
||||||
chart_set_size(>->cpu,
|
chart_set_size(>->cpu, ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_stroke_rgba(>->cpu, 0.75, 0.25, 0.75, 1.);
|
chart_set_stroke_rgba(>->cpu, 0.75, 0.25, 0.75, 1.);
|
||||||
chart_set_mode(>->cpu, CHART_STROKE);
|
chart_set_mode(>->cpu, CHART_STROKE);
|
||||||
chart_set_range(>->cpu, 0, 100);
|
chart_set_range(>->cpu, 0, 100);
|
||||||
@ -95,9 +118,7 @@ static void init_gpu_top(struct overlay_gpu_top *gt,
|
|||||||
gt->gpu_top.ring[n].name,
|
gt->gpu_top.ring[n].name,
|
||||||
120);
|
120);
|
||||||
chart_set_position(>->busy[n], 12, 12);
|
chart_set_position(>->busy[n], 12, 12);
|
||||||
chart_set_size(>->busy[n],
|
chart_set_size(>->busy[n], ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_stroke_rgba(>->busy[n],
|
chart_set_stroke_rgba(>->busy[n],
|
||||||
rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3]);
|
rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3]);
|
||||||
chart_set_mode(>->busy[n], CHART_STROKE);
|
chart_set_mode(>->busy[n], CHART_STROKE);
|
||||||
@ -109,9 +130,7 @@ static void init_gpu_top(struct overlay_gpu_top *gt,
|
|||||||
gt->gpu_top.ring[n].name,
|
gt->gpu_top.ring[n].name,
|
||||||
120);
|
120);
|
||||||
chart_set_position(>->wait[n], 12, 12);
|
chart_set_position(>->wait[n], 12, 12);
|
||||||
chart_set_size(>->wait[n],
|
chart_set_size(>->wait[n], ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_fill_rgba(>->wait[n],
|
chart_set_fill_rgba(>->wait[n],
|
||||||
rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3] * 0.70);
|
rgba[n][0], rgba[n][1], rgba[n][2], rgba[n][3] * 0.70);
|
||||||
chart_set_mode(>->wait[n], CHART_FILL);
|
chart_set_mode(>->wait[n], CHART_FILL);
|
||||||
@ -178,12 +197,8 @@ static void show_gpu_top(struct overlay_context *ctx, struct overlay_gpu_top *gt
|
|||||||
ctx->last_y = 112;
|
ctx->last_y = 112;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct overlay_gpu_perf {
|
static void init_gpu_perf(struct overlay_context *ctx,
|
||||||
struct gpu_perf gpu_perf;
|
struct overlay_gpu_perf *gp)
|
||||||
};
|
|
||||||
|
|
||||||
static void init_gpu_perf(struct overlay_gpu_perf *gp,
|
|
||||||
cairo_surface_t *surface)
|
|
||||||
{
|
{
|
||||||
gpu_perf_init(&gp->gpu_perf, 0);
|
gpu_perf_init(&gp->gpu_perf, 0);
|
||||||
}
|
}
|
||||||
@ -370,32 +385,21 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
|
|||||||
ctx->last_y += 118;
|
ctx->last_y += 118;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct overlay_gpu_freq {
|
static void init_gpu_freq(struct overlay_context *ctx,
|
||||||
struct gpu_freq gpu_freq;
|
struct overlay_gpu_freq *gf)
|
||||||
struct chart current;
|
|
||||||
struct chart request;
|
|
||||||
int error;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void init_gpu_freq(struct overlay_gpu_freq *gf,
|
|
||||||
cairo_surface_t *surface)
|
|
||||||
{
|
{
|
||||||
gf->error = gpu_freq_init(&gf->gpu_freq);
|
gf->error = gpu_freq_init(&gf->gpu_freq);
|
||||||
if (gf->error)
|
if (gf->error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chart_init(&gf->current, "current", 120);
|
chart_init(&gf->current, "current", 120);
|
||||||
chart_set_size(&gf->current,
|
chart_set_size(&gf->current, ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_stroke_rgba(&gf->current, 0.75, 0.25, 0.50, 1.);
|
chart_set_stroke_rgba(&gf->current, 0.75, 0.25, 0.50, 1.);
|
||||||
chart_set_mode(&gf->current, CHART_STROKE);
|
chart_set_mode(&gf->current, CHART_STROKE);
|
||||||
chart_set_range(&gf->current, 0, gf->gpu_freq.max);
|
chart_set_range(&gf->current, 0, gf->gpu_freq.max);
|
||||||
|
|
||||||
chart_init(&gf->request, "request", 120);
|
chart_init(&gf->request, "request", 120);
|
||||||
chart_set_size(&gf->request,
|
chart_set_size(&gf->request, ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_fill_rgba(&gf->request, 0.25, 0.75, 0.50, 1.);
|
chart_set_fill_rgba(&gf->request, 0.25, 0.75, 0.50, 1.);
|
||||||
chart_set_mode(&gf->request, CHART_FILL);
|
chart_set_mode(&gf->request, CHART_FILL);
|
||||||
chart_set_range(&gf->request, 0, gf->gpu_freq.max);
|
chart_set_range(&gf->request, 0, gf->gpu_freq.max);
|
||||||
@ -440,32 +444,21 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *
|
|||||||
ctx->last_y += 112;
|
ctx->last_y += 112;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct overlay_gem_objects {
|
static void init_gem_objects(struct overlay_context *ctx,
|
||||||
struct gem_objects gem_objects;
|
struct overlay_gem_objects *go)
|
||||||
struct chart aperture;
|
|
||||||
struct chart gtt;
|
|
||||||
int error;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void init_gem_objects(struct overlay_gem_objects *go,
|
|
||||||
cairo_surface_t *surface)
|
|
||||||
{
|
{
|
||||||
go->error = gem_objects_init(&go->gem_objects);
|
go->error = gem_objects_init(&go->gem_objects);
|
||||||
if (go->error)
|
if (go->error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chart_init(&go->aperture, "aperture", 120);
|
chart_init(&go->aperture, "aperture", 120);
|
||||||
chart_set_size(&go->aperture,
|
chart_set_size(&go->aperture, ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_stroke_rgba(&go->aperture, 0.75, 0.25, 0.50, 1.);
|
chart_set_stroke_rgba(&go->aperture, 0.75, 0.25, 0.50, 1.);
|
||||||
chart_set_mode(&go->aperture, CHART_STROKE);
|
chart_set_mode(&go->aperture, CHART_STROKE);
|
||||||
chart_set_range(&go->aperture, 0, go->gem_objects.max_gtt);
|
chart_set_range(&go->aperture, 0, go->gem_objects.max_gtt);
|
||||||
|
|
||||||
chart_init(&go->gtt, "gtt", 120);
|
chart_init(&go->gtt, "gtt", 120);
|
||||||
chart_set_size(&go->gtt,
|
chart_set_size(&go->gtt, ctx->width - 24, 100);
|
||||||
cairo_image_surface_get_width(surface)-24,
|
|
||||||
100);
|
|
||||||
chart_set_fill_rgba(&go->gtt, 0.25, 0.75, 0.50, 1.);
|
chart_set_fill_rgba(&go->gtt, 0.25, 0.75, 0.50, 1.);
|
||||||
chart_set_mode(&go->gtt, CHART_FILL);
|
chart_set_mode(&go->gtt, CHART_FILL);
|
||||||
chart_set_range(&go->gtt, 0, go->gem_objects.max_gtt);
|
chart_set_range(&go->gtt, 0, go->gem_objects.max_gtt);
|
||||||
@ -517,11 +510,7 @@ static void show_gem_objects(struct overlay_context *ctx, struct overlay_gem_obj
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
cairo_surface_t *surface;
|
struct overlay_context ctx;
|
||||||
struct overlay_gpu_top gpu_top;
|
|
||||||
struct overlay_gpu_perf gpu_perf;
|
|
||||||
struct overlay_gpu_freq gpu_freq;
|
|
||||||
struct overlay_gem_objects gem_objects;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
@ -529,21 +518,21 @@ int main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = x11_overlay_create(POS_TOP_RIGHT, 640, 480);
|
ctx.width = 640;
|
||||||
if (surface == NULL)
|
ctx.height = 480;
|
||||||
|
ctx.surface = x11_overlay_create(POS_TOP_RIGHT, &ctx.width, &ctx.height);
|
||||||
|
if (ctx.surface == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
init_gpu_top(&gpu_top, surface);
|
init_gpu_top(&ctx, &ctx.gpu_top);
|
||||||
init_gpu_perf(&gpu_perf, surface);
|
init_gpu_perf(&ctx, &ctx.gpu_perf);
|
||||||
init_gpu_freq(&gpu_freq, surface);
|
init_gpu_freq(&ctx, &ctx.gpu_freq);
|
||||||
init_gem_objects(&gem_objects, surface);
|
init_gem_objects(&ctx, &ctx.gem_objects);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
struct overlay_context ctx;
|
|
||||||
|
|
||||||
usleep(500*1000);
|
usleep(500*1000);
|
||||||
|
|
||||||
ctx.cr = cairo_create(surface);
|
ctx.cr = cairo_create(ctx.surface);
|
||||||
cairo_set_operator(ctx.cr, CAIRO_OPERATOR_CLEAR);
|
cairo_set_operator(ctx.cr, CAIRO_OPERATOR_CLEAR);
|
||||||
cairo_paint(ctx.cr);
|
cairo_paint(ctx.cr);
|
||||||
cairo_set_operator(ctx.cr, CAIRO_OPERATOR_OVER);
|
cairo_set_operator(ctx.cr, CAIRO_OPERATOR_OVER);
|
||||||
@ -556,19 +545,19 @@ int main(int argc, char **argv)
|
|||||||
cairo_set_source_rgb(ctx.cr, .5, .5, .5);
|
cairo_set_source_rgb(ctx.cr, .5, .5, .5);
|
||||||
cairo_text_extents(ctx.cr, buf, &extents);
|
cairo_text_extents(ctx.cr, buf, &extents);
|
||||||
cairo_move_to(ctx.cr,
|
cairo_move_to(ctx.cr,
|
||||||
cairo_image_surface_get_width(surface)-extents.width-6,
|
ctx.width-extents.width-6,
|
||||||
6+extents.height);
|
6+extents.height);
|
||||||
cairo_show_text(ctx.cr, buf);
|
cairo_show_text(ctx.cr, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_gpu_top(&ctx, &gpu_top);
|
show_gpu_top(&ctx, &ctx.gpu_top);
|
||||||
show_gpu_perf(&ctx, &gpu_perf);
|
show_gpu_perf(&ctx, &ctx.gpu_perf);
|
||||||
show_gpu_freq(&ctx, &gpu_freq);
|
show_gpu_freq(&ctx, &ctx.gpu_freq);
|
||||||
show_gem_objects(&ctx, &gem_objects);
|
show_gem_objects(&ctx, &ctx.gem_objects);
|
||||||
|
|
||||||
cairo_destroy(ctx.cr);
|
cairo_destroy(ctx.cr);
|
||||||
|
|
||||||
overlay_show(surface);
|
overlay_show(ctx.surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -33,5 +33,5 @@ struct overlay {
|
|||||||
|
|
||||||
extern const cairo_user_data_key_t overlay_key;
|
extern const cairo_user_data_key_t overlay_key;
|
||||||
|
|
||||||
cairo_surface_t *x11_overlay_create(enum position pos, int max_width, int max_height);
|
cairo_surface_t *x11_overlay_create(enum position pos, int *width, int *height);
|
||||||
void x11_overlay_stop(void);
|
void x11_overlay_stop(void);
|
||||||
|
@ -118,7 +118,7 @@ static void x11_overlay_destroy(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_t *
|
cairo_surface_t *
|
||||||
x11_overlay_create(enum position position, int max_width, int max_height)
|
x11_overlay_create(enum position position, int *width, int *height)
|
||||||
{
|
{
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
Screen *scr;
|
Screen *scr;
|
||||||
@ -171,23 +171,29 @@ x11_overlay_create(enum position position, int max_width, int max_height)
|
|||||||
|
|
||||||
XSetErrorHandler(noop);
|
XSetErrorHandler(noop);
|
||||||
|
|
||||||
w = scr->width;
|
if (*width == -1) {
|
||||||
switch (position & 7) {
|
w = scr->width;
|
||||||
default:
|
switch (position & 7) {
|
||||||
case 0:
|
default:
|
||||||
case 2: w >>= 1; break;
|
case 0:
|
||||||
}
|
case 2: w >>= 1; break;
|
||||||
if (max_width > 0 && w > max_width)
|
}
|
||||||
w = max_width;
|
} else if (*width > scr->width) {
|
||||||
|
w = scr->width;
|
||||||
|
} else
|
||||||
|
w = *width;
|
||||||
|
|
||||||
h = scr->height;
|
if (*height == -1) {
|
||||||
switch ((position >> 4) & 7) {
|
h = scr->height;
|
||||||
default:
|
switch ((position >> 4) & 7) {
|
||||||
case 0:
|
default:
|
||||||
case 2: h >>= 1; break;
|
case 0:
|
||||||
}
|
case 2: h >>= 1; break;
|
||||||
if (max_height > 0 && h > max_height)
|
}
|
||||||
h = max_height;
|
} else if (*height > scr->height)
|
||||||
|
h = scr->height;
|
||||||
|
else
|
||||||
|
h = *height;
|
||||||
|
|
||||||
image = XvCreateImage(dpy, port, FOURCC_RGB565, NULL, w, h);
|
image = XvCreateImage(dpy, port, FOURCC_RGB565, NULL, w, h);
|
||||||
if (image == NULL)
|
if (image == NULL)
|
||||||
@ -301,6 +307,9 @@ x11_overlay_create(enum position position, int max_width, int max_height)
|
|||||||
XvSetPortAttribute(dpy, port, XInternAtom(dpy, "XV_ALWAYS_ON_TOP", True), 1);
|
XvSetPortAttribute(dpy, port, XInternAtom(dpy, "XV_ALWAYS_ON_TOP", True), 1);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
*width = image->width;
|
||||||
|
*height = image->height;
|
||||||
return surface;
|
return surface;
|
||||||
|
|
||||||
err_surface:
|
err_surface:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user