Submitted By:            Armin K. <krejzi at email dot com>
Date:                    2013-02-13
Initial Package Version: 1.16.0
Upstream Status:         Committed
Origin:                  Gnome
URL1:                    https://git.gnome.org/browse/cogl/commit/?h=cogl-1.16&id=b331ea7ec6c2180725f82e4b611587f8366fcb41
URL2                     https://git.gnome.org/browse/cogl/commit/?h=cogl-1.16&id=7c7de71f6af974c73f756e91832a27867d967152
Description:             wayland-server: Use wl_resource instead of wl_buffer.

diff -Naur cogl-1.16.0.orig/cogl/cogl-texture-2d.c cogl-1.16.0/cogl/cogl-texture-2d.c
--- cogl-1.16.0.orig/cogl/cogl-texture-2d.c	2013-08-19 18:23:00.000000000 -0300
+++ cogl-1.16.0/cogl/cogl-texture-2d.c	2013-12-13 15:12:53.050639510 -0300
@@ -294,12 +294,12 @@
 #ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
 CoglTexture2D *
 cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
-                                         struct wl_resource *buffer_resource,
+                                         struct wl_resource *buffer,
                                          CoglError **error)
 {
   struct wl_shm_buffer *shm_buffer;
 
-  shm_buffer = wl_shm_buffer_get (buffer_resource);
+  shm_buffer = wl_shm_buffer_get (buffer);
 
   if (shm_buffer)
     {
@@ -343,7 +343,6 @@
     }
   else
     {
-      struct wl_buffer *buffer = (struct wl_buffer *) buffer_resource;
       int format, width, height;
 
       if (_cogl_egl_query_wayland_buffer (ctx,
diff -Naur cogl-1.16.0.orig/cogl/winsys/cogl-winsys-egl.c cogl-1.16.0/cogl/winsys/cogl-winsys-egl.c
--- cogl-1.16.0.orig/cogl/winsys/cogl-winsys-egl.c	2013-09-23 11:02:30.000000000 -0300
+++ cogl-1.16.0/cogl/winsys/cogl-winsys-egl.c	2013-12-13 15:12:53.054639603 -0300
@@ -1046,7 +1046,7 @@
 #ifdef EGL_WL_bind_wayland_display
 CoglBool
 _cogl_egl_query_wayland_buffer (CoglContext *ctx,
-                                struct wl_buffer *buffer,
+                                struct wl_resource *buffer,
                                 int attribute,
                                 int *value)
 {
diff -Naur cogl-1.16.0.orig/cogl/winsys/cogl-winsys-egl-feature-functions.h cogl-1.16.0/cogl/winsys/cogl-winsys-egl-feature-functions.h
--- cogl-1.16.0.orig/cogl/winsys/cogl-winsys-egl-feature-functions.h	2013-07-09 12:20:23.000000000 -0300
+++ cogl-1.16.0/cogl/winsys/cogl-winsys-egl-feature-functions.h	2013-12-13 15:12:53.051639538 -0300
@@ -88,7 +88,7 @@
                                struct wl_display *wayland_display))
 COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglQueryWaylandBuffer,
                               (EGLDisplay dpy,
-                               struct wl_buffer *buffer,
+                               struct wl_resource *buffer,
                                EGLint attribute, EGLint *value))
 COGL_WINSYS_FEATURE_END ()
 
diff -Naur cogl-1.16.0.orig/cogl/winsys/cogl-winsys-egl-private.h cogl-1.16.0/cogl/winsys/cogl-winsys-egl-private.h
--- cogl-1.16.0.orig/cogl/winsys/cogl-winsys-egl-private.h	2013-07-09 12:20:23.000000000 -0300
+++ cogl-1.16.0/cogl/winsys/cogl-winsys-egl-private.h	2013-12-13 15:13:09.584619217 -0300
@@ -30,6 +30,27 @@
 #include "cogl-context-private.h"
 #include "cogl-framebuffer-private.h"
 
+/* XXX: depending on what version of Mesa you have then
+ * eglQueryWaylandBuffer may take a wl_buffer or wl_resource argument
+ * and the EGL header will only forward declare the corresponding
+ * type.
+ *
+ * The use of wl_buffer has been deprecated and so internally we
+ * assume that eglQueryWaylandBuffer takes a wl_resource but for
+ * compatibility we forward declare wl_resource in case we are
+ * building with EGL headers that still use wl_buffer.
+ *
+ * Placing the forward declaration here means it comes before we
+ * #include cogl-winsys-egl-feature-functions.h bellow which
+ * declares lots of function pointers for accessing EGL extensions
+ * and cogl-winsys-egl.c will include this header before it also
+ * includes cogl-winsys-egl-feature-functions.h that may depend
+ * on this type.
+ */
+#ifdef EGL_WL_bind_wayland_display
+struct wl_resource;
+#endif
+
 typedef struct _CoglWinsysEGLVtable
 {
   CoglBool
@@ -162,7 +183,7 @@
 #ifdef EGL_WL_bind_wayland_display
 CoglBool
 _cogl_egl_query_wayland_buffer (CoglContext *ctx,
-                                struct wl_buffer *buffer,
+                                struct wl_resource *buffer,
                                 int attribute,
                                 int *value);
 #endif
