android: add support for ICS
[mesa.git] / src / gallium / state_trackers / egl / common / egl_g3d_image.c
index 4f5bdba3011f392364557323e181bdbc7d257f09..cf8ec98dbba47da4126b049432f3caf4937de660 100644 (file)
@@ -37,9 +37,6 @@
 #include "egl_g3d.h"
 #include "egl_g3d_image.h"
 
-/* for struct winsys_handle */
-#include "state_tracker/drm_driver.h"
-
 /**
  * Reference and return the front left buffer of the native pixmap.
  */
@@ -205,6 +202,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,
@@ -241,6 +256,12 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
       ptex = egl_g3d_reference_wl_buffer(dpy,
             (struct wl_buffer *) 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:
       ptex = NULL;