diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-20 19:24:33 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-20 21:30:56 +0100 |
commit | 5cb8c77d69ffda7fed784cd194844b4efecedf52 (patch) | |
tree | 53ca2cf711c9894ee696a826b9ed096cdc877655 /overlay/overlay.c | |
parent | 57e573ecc1c53b3aafe6ac4784069d79bd73107d (diff) |
overlay: Take a snapshot on SIGUSR1
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/overlay.c')
-rw-r--r-- | overlay/overlay.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/overlay/overlay.c b/overlay/overlay.c index 0968fd71..92123601 100644 --- a/overlay/overlay.c +++ b/overlay/overlay.c @@ -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; |