wcap: Add a file format magic number and add the pixel format to the header
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 25 May 2012 21:45:39 +0000 (17:45 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 25 May 2012 21:45:39 +0000 (17:45 -0400)
src/screenshooter.c
src/wcap-decode.c

index 77d34ea..d368cfd 100644 (file)
@@ -318,12 +318,18 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data)
        pixman_region32_fini(&damage);
 }
 
+#define WCAP_HEADER_MAGIC      0x57434150
+#define WCAP_FORMAT_XRGB8888   0x34325258
+#define WCAP_FORMAT_XBGR8888   0x34324258
+#define WCAP_FORMAT_RGBX8888   0x34325852
+#define WCAP_FORMAT_BGRX8888   0x34325842
+
 static void
 weston_recorder_create(struct weston_output *output, const char *filename)
 {
        struct weston_recorder *recorder;
        int stride, size;
-       struct { uint32_t width, height; } header;
+       struct { uint32_t magic, format, width, height; } header;
 
        recorder = malloc(sizeof *recorder);
        recorder->output = output;
@@ -338,6 +344,17 @@ weston_recorder_create(struct weston_output *output, const char *filename)
        recorder->fd = open(filename,
                            O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
 
+       header.magic = WCAP_HEADER_MAGIC;
+
+       switch (output->compositor->read_format) {
+       case GL_BGRA_EXT:
+               header.format = WCAP_FORMAT_XRGB8888;
+               break;
+       case GL_RGBA:
+               header.format = WCAP_FORMAT_XBGR8888;
+               break;
+       }
+
        header.width = output->current->width;
        header.height = output->current->height;
        recorder->total += write(recorder->fd, &header, sizeof header);
index 9ff7ddb..8382bfb 100644 (file)
 
 #include <cairo.h>
 
+#define WCAP_HEADER_MAGIC      0x57434150
+
+#define WCAP_FORMAT_XRGB8888   0x34325258
+#define WCAP_FORMAT_XBGR8888   0x34324258
+#define WCAP_FORMAT_RGBX8888   0x34325852
+#define WCAP_FORMAT_BGRX8888   0x34325842
+
 struct wcap_header {
+       uint32_t magic;
+       uint32_t format;
        uint32_t width, height;
 };