egl: Update to Wayland 1.2 server API
[mesa.git] / src / gallium / state_trackers / egl / common / egl_g3d_image.c
index 7e9a29b02843056547fcb07359d3af6c5e624353..c459dc32320f85dc1d14f36354cd69fe63e8439e 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.8
  *
  * Copyright (C) 2010 LunarG Inc.
  *
@@ -184,7 +183,7 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
 #ifdef EGL_WL_bind_wayland_display
 
 static struct pipe_resource *
-egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_buffer *buffer,
+egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_resource *buffer,
                             _EGLImage *img, const EGLint *attribs)
 {
    struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
@@ -202,6 +201,24 @@ egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_buffer *buffer,
 
 #endif /* EGL_WL_bind_wayland_display */
 
+#ifdef EGL_ANDROID_image_native_buffer
+
+static struct pipe_resource *
+egl_g3d_reference_android_native_buffer(_EGLDisplay *dpy,
+                                        struct ANativeWindowBuffer *buf)
+{
+   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+   struct native_buffer nbuf;
+
+   memset(&nbuf, 0, sizeof(nbuf));
+   nbuf.type = NATIVE_BUFFER_ANDROID;
+   nbuf.u.android = buf;
+    
+   return gdpy->native->buffer->import_buffer(gdpy->native, &nbuf);
+}
+
+#endif /* EGL_ANDROID_image_native_buffer */
+
 _EGLImage *
 egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
                      EGLenum target, EGLClientBuffer buffer,
@@ -230,13 +247,19 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
 #ifdef EGL_MESA_drm_image
    case EGL_DRM_BUFFER_MESA:
       ptex = egl_g3d_reference_drm_buffer(dpy,
-            (EGLint) buffer, &gimg->base, attribs);
+            (EGLint) pointer_to_intptr(buffer), &gimg->base, attribs);
       break;
 #endif
 #ifdef EGL_WL_bind_wayland_display
    case EGL_WAYLAND_BUFFER_WL:
       ptex = egl_g3d_reference_wl_buffer(dpy,
-            (struct wl_buffer *) buffer, &gimg->base, attribs);
+            (struct wl_resource *) buffer, &gimg->base, attribs);
+      break;
+#endif
+#ifdef EGL_ANDROID_image_native_buffer
+   case EGL_NATIVE_BUFFER_ANDROID:
+      ptex = egl_g3d_reference_android_native_buffer(dpy,
+            (struct ANativeWindowBuffer *) buffer);
       break;
 #endif
    default: