screenshooter: Grab pixel data directly before buffer swap

This commit is contained in:
Scott Moreau
2012-04-20 13:37:33 -06:00
committed by Kristian Høgsberg
parent 9074db5d62
commit 062be7ec93
8 changed files with 117 additions and 78 deletions
+17 -2
View File
@@ -41,6 +41,7 @@
static struct wl_shm *shm;
static struct screenshooter *screenshooter;
static struct wl_list output_list;
int buffer_copy_done;
struct screenshooter_output {
struct wl_output *output;
@@ -93,6 +94,16 @@ static const struct wl_output_listener output_listener = {
display_handle_mode
};
static void
screenshot_done(void *data, struct screenshooter *screenshooter)
{
buffer_copy_done = 1;
}
static const struct screenshooter_listener screenshooter_listener = {
screenshot_done
};
static void
handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
@@ -188,6 +199,9 @@ int main(int argc, char *argv[])
return -1;
}
screenshooter_add_listener(screenshooter, &screenshooter_listener, screenshooter);
wl_list_for_each(output, &output_list, link) {
width = MAX(width, output->offset_x + output->width);
height = MAX(height, output->offset_y + output->height);
@@ -197,11 +211,12 @@ int main(int argc, char *argv[])
wl_list_for_each_safe(output, next, &output_list, link) {
screenshooter_shoot(screenshooter, output->output, buffer);
buffer_copy_done = 0;
while (!buffer_copy_done)
wl_display_roundtrip(display);
free(output);
}
wl_display_roundtrip(display);
write_png(width, height, data);
return 0;