diff options
author | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-14 12:50:00 -0700 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-21 15:06:26 -0700 |
commit | 2eaf7d78ba1b62cdbddcd811bef96b886c15a94b (patch) | |
tree | 75d0f6735b5902f143c0e5ed80af9be00af1e915 | |
parent | 85e65f5fe51d58b8872a838270432c531dd80b7b (diff) | |
download | weston-2eaf7d78ba1b62cdbddcd811bef96b886c15a94b.tar.gz weston-2eaf7d78ba1b62cdbddcd811bef96b886c15a94b.tar.bz2 weston-2eaf7d78ba1b62cdbddcd811bef96b886c15a94b.zip |
tests: Add create_screenshot_surface()
Refactor out the screenshot shm buffer creation code.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
-rw-r--r-- | tests/internal-screenshot-test.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c index 5ae9b8bf..451ccad7 100644 --- a/tests/internal-screenshot-test.c +++ b/tests/internal-screenshot-test.c @@ -61,6 +61,32 @@ write_surface_as_png(const struct surface* weston_surface, const char *fname) { return true; } +/** create_screenshot_surface() + * + * Allocates and initializes a weston test surface for use in + * storing a screenshot of the client's output. Establishes a + * shm backed wl_buffer for retrieving screenshot image data + * from the server, sized to match the client's output display. + * + * @returns stack allocated surface image, which should be + * free'd when done using it. + */ +static struct surface* +create_screenshot_surface(struct client *client) { + struct surface* screenshot; + screenshot = xzalloc(sizeof *screenshot); + if (screenshot == NULL) + return NULL; + screenshot->wl_buffer = create_shm_buffer(client, + client->output->width, + client->output->height, + &screenshot->data); + screenshot->height = client->output->height; + screenshot->width = client->output->width; + + return screenshot; +} + TEST(internal_screenshot) { struct client *client; @@ -81,17 +107,8 @@ TEST(internal_screenshot) printf("Client created\n"); /* Create a surface to hold the screenshot */ - screenshot = xzalloc(sizeof *screenshot); + screenshot = create_screenshot_surface(client); assert(screenshot); - - /* Create and attach buffer to our surface */ - screenshot->wl_buffer = create_shm_buffer(client, - client->output->width, - client->output->height, - &screenshot->data); - screenshot->height = client->output->height; - screenshot->width = client->output->width; - assert(screenshot->wl_buffer); printf("Screenshot buffer created and attached to surface\n"); /* Take a snapshot. Result will be in screenshot->wl_buffer. */ |