ChromaKeyExample : Adapting to new shm protocol of wayland 0.95
authorMichael Schuldt <michael.schuldt@bmw.de>
Fri, 24 Aug 2012 13:51:24 +0000 (15:51 +0200)
committerMichael Schuldt <michael.schuldt@bmw.de>
Wed, 12 Sep 2012 09:34:35 +0000 (11:34 +0200)
- the shm interfaces has changed in wayland 0.95
- this patch correct the behaviour.

LayerManagerExamples/WLChromakeyExample/src/chromakey.c

index 2b78b20..695a7ad 100644 (file)
 #define LAYER_CHROMAKEY   3500
 #define SURFACE_CHROMAKEY 6789
 
-#define CHECK_ILM_ERROR(S)             \
-       if ((S) != ILM_SUCCESS){        \
-               printf("%s (%d): ilm command failed.\n", __FILE__, __LINE__); \
-               break;                                  \
-       }                                                       \
+#define CHECK_ILM_ERROR(S)      \
+    if ((S) != ILM_SUCCESS){    \
+        printf("%s (%d): ilm command failed.\n", __FILE__, __LINE__); \
+        break;                  \
+    }                           \
 
 /*****************************************************************************
  *  structure
@@ -135,6 +135,8 @@ event_mask_update(uint32_t mask, void* data)
  ****************************************************************************/
 static void createShmBuffer()
 {
+    struct wl_shm_pool *pool;
+
     char filename[] = "/tmp/wayland-shm-XXXXXX";
     int fd = -1;
     int size = 0;
@@ -160,12 +162,12 @@ static void createShmBuffer()
         return;
     }
 
-    g_wlContextStruct.wlBuffer = wl_shm_create_buffer(g_wlContextStruct.wlShm,
-                                                      fd,
-                                                      g_wlContextStruct.ctx_bmp->width,
-                                                      g_wlContextStruct.ctx_bmp->height,
-                                                      g_wlContextStruct.ctx_bmp->stride,
-                                                      WL_SHM_FORMAT_XRGB8888);
+    pool = wl_shm_create_pool(g_wlContextStruct.wlShm, fd, size);
+    g_wlContextStruct.wlBuffer = wl_shm_pool_create_buffer(pool, 0, g_wlContextStruct.ctx_bmp->width,
+                                                g_wlContextStruct.ctx_bmp->height,
+                                                g_wlContextStruct.ctx_bmp->stride,
+                                                WL_SHM_FORMAT_XRGB8888);
+
     if (NULL == g_wlContextStruct.wlBuffer)
     {
         fprintf(stderr, "wl_shm_create_buffer failed: %m\n");
@@ -173,7 +175,7 @@ static void createShmBuffer()
         return;
     }
     wl_surface_attach(g_wlContextStruct.wlSurface, g_wlContextStruct.wlBuffer, 0, 0);
-
+    wl_shm_pool_destroy(pool);
     close(fd);
 
     return;
@@ -236,10 +238,6 @@ static void drawImage(void)
            g_wlContextStruct.ctx_bmp->data,
            g_wlContextStruct.ctx_bmp->stride * g_wlContextStruct.ctx_bmp->height);
 
-    wl_buffer_damage(g_wlContextStruct.wlBuffer,
-                     0, 0,
-                     g_wlContextStruct.ctx_bmp->width,
-                     g_wlContextStruct.ctx_bmp->height);
     wl_surface_attach(g_wlContextStruct.wlSurface,
                       g_wlContextStruct.wlBuffer,
                       0, 0);