aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-01-29 17:13:23 -0500
committerGitHub <noreply@github.com>2018-01-29 17:13:23 -0500
commited5b1fdedd775a7acec3d6814cc2ac007e34fd29 (patch)
tree79192b14d83eae55d63c38223ba60beb020bb6f6 /examples
parent60b2d969e07e24ed1b96ccc9d82bc2f9c1d540f2 (diff)
parentf34a1b75ebd9dbebf4fb9c2cf34d878fce902c03 (diff)
Merge pull request #580 from emersion/screenshooter-renderer-backport
Backport screenshooter fixes from the renderer redesign v1
Diffstat (limited to 'examples')
-rw-r--r--examples/screenshot.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/examples/screenshot.c b/examples/screenshot.c
index 529af38f..ba225023 100644
--- a/examples/screenshot.c
+++ b/examples/screenshot.c
@@ -74,7 +74,7 @@ static void output_handle_mode(void *data, struct wl_output *wl_output,
}
static void output_handle_done(void *data, struct wl_output *wl_output) {
-
+ // No-op
}
static const struct wl_output_listener output_listener = {
@@ -148,16 +148,6 @@ static struct wl_buffer *create_shm_buffer(int width, int height,
return buffer;
}
-static void argb_to_rgba(uint32_t *data, size_t height, size_t stride) {
- size_t n = height*stride/4;
- for (size_t i = 0; i < n; ++i) {
- uint32_t v = data[i];
- uint32_t rgb = v & 0x00ffffff;
- uint32_t a = (v & 0xff000000) >> 24;
- data[i] = (rgb << 8) | a;
- }
-}
-
static void write_image(const char *filename, int width, int height) {
int buffer_stride = width * 4;
@@ -182,8 +172,6 @@ static void write_image(const char *filename, int width, int height) {
free(output);
}
- argb_to_rgba(data, height, buffer_stride);
-
char size[10 + 1 + 10 + 2 + 1]; // int32_t are max 10 digits
sprintf(size, "%dx%d+0", width, height);
@@ -213,7 +201,9 @@ static void write_image(const char *filename, int width, int height) {
exit(EXIT_FAILURE);
}
close(fd[0]);
- execlp("convert", "convert", "-depth", "8", "-size", size, "rgba:-",
+ // We requested WL_SHM_FORMAT_XRGB8888 in little endian, so that's BGRA
+ // in big endian.
+ execlp("convert", "convert", "-depth", "8", "-size", size, "bgra:-",
"-alpha", "opaque", filename, NULL);
fprintf(stderr, "cannot execute convert\n");
exit(EXIT_FAILURE);