From e012c829afb29b5b2e75e4a7b8ef88a205424ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 25 May 2012 17:50:42 -0400 Subject: [PATCH] wcap: Discard first frame since it doesn't have a full frame of damage --- src/screenshooter.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/screenshooter.c b/src/screenshooter.c index d368cfde..d9f26ba3 100644 --- a/src/screenshooter.c +++ b/src/screenshooter.c @@ -216,6 +216,7 @@ struct weston_recorder { uint32_t total; int fd; struct wl_listener frame_listener; + int count; }; static uint32_t * @@ -261,6 +262,11 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data) r = pixman_region32_rectangles(&damage, &n); if (n == 0) return; + if (recorder->count++ == 0) + /* The first callback gives us the frame immediately + * before the weston_output_damage() call, and + * typically doesn't give us a full frame of damage.*/ + return; header.msecs = msecs; header.nrects = n; @@ -339,6 +345,7 @@ weston_recorder_create(struct weston_output *output, const char *filename) recorder->frame = malloc(size); recorder->rect = malloc(size); recorder->total = 0; + recorder->count = 0; memset(recorder->frame, 0, size); recorder->fd = open(filename, @@ -394,8 +401,9 @@ recorder_binding(struct wl_seat *seat, uint32_t time, recorder = container_of(listener, struct weston_recorder, frame_listener); - fprintf(stderr, "stopping recorder, total file size %dM\n", - recorder->total / (1024 * 1024)); + fprintf(stderr, + "stopping recorder, total file size %dM, %d frames\n", + recorder->total / (1024 * 1024), recorder->count); weston_recorder_destroy(recorder); } else {