overlay: Take a snapshot on SIGUSR1

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-20 19:24:33 +01:00
parent 57e573ecc1
commit 5cb8c77d69

View File

@ -8,6 +8,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include "overlay.h"
#include "chart.h"
@ -556,6 +557,13 @@ static void show_gem_objects(struct overlay_context *ctx, struct overlay_gem_obj
}
}
static int take_snapshot;
static void signal_snapshot(int sig)
{
take_snapshot = sig;
}
int main(int argc, char **argv)
{
struct overlay_context ctx;
@ -566,6 +574,8 @@ int main(int argc, char **argv)
return 0;
}
signal(SIGUSR1, signal_snapshot);
ctx.width = 640;
ctx.height = 236;
ctx.surface = x11_overlay_create(POS_TOP_RIGHT, &ctx.width, &ctx.height);
@ -609,6 +619,13 @@ int main(int argc, char **argv)
cairo_destroy(ctx.cr);
overlay_show(ctx.surface);
if (take_snapshot) {
char buf[80];
sprintf(buf, "overlay-snapshot-%d.png", i-1);
cairo_surface_write_to_png(ctx.surface, buf);
take_snapshot = 0;
}
}
return 0;