summaryrefslogtreecommitdiff
path: root/overlay/overlay.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-28 12:37:14 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-28 14:04:27 +0100
commit9bebbbc49b2f828adea3cffb58907fb493813803 (patch)
treebec101a52439a311467483a71866f8ce42edd1c0 /overlay/overlay.c
parenta18023f67864841fbeee6c93e9c504768e652281 (diff)
overlay: Generate unique name for snapshots
Since we no longer increment the counter every frame, we need to use a timestamp instead. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/overlay.c')
-rw-r--r--overlay/overlay.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/overlay/overlay.c b/overlay/overlay.c
index 38c597e9..55c2aa34 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include <signal.h>
#include <getopt.h>
+#include <time.h>
#include "overlay.h"
#include "chart.h"
@@ -754,6 +755,13 @@ static int get_sample_period(struct config *config)
return 500000;
}
+static void overlay_snapshot(struct overlay_context *ctx)
+{
+ char buf[1024];
+ sprintf(buf, "/tmp/overlay-snapshot-%ld.png", (long)time(NULL));
+ cairo_surface_write_to_png(ctx->surface, buf);
+}
+
int main(int argc, char **argv)
{
static struct option long_options[] = {
@@ -853,9 +861,7 @@ int main(int argc, char **argv)
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);
+ overlay_snapshot(&ctx);
take_snapshot = 0;
}