gallium-egl: Implement eglQueryWaylandBufferWL
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 19 Jul 2012 12:48:45 +0000 (08:48 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 19 Jul 2012 18:03:17 +0000 (14:03 -0400)
Support this query for gallium EGL too.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
src/gallium/state_trackers/egl/common/egl_g3d_api.c

index 58e772f944e4dc96dd4997e4176e1ff2ce57191d..f2e86de31472cb28d1240fce88f474ec0d1c7e24 100644 (file)
 #include "egl_g3d_st.h"
 #include "native.h"
 
+#ifdef EGL_WL_bind_wayland_display
+#include <wayland-drm.h>
+#endif
+
 /**
  * Return the state tracker for the given context.
  */
@@ -873,6 +877,32 @@ egl_g3d_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *dpy,
    return gdpy->native->wayland_bufmgr->unbind_display(gdpy->native, wl_dpy);
 }
 
+static EGLBoolean
+egl_g3d_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *dpy,
+                                struct wl_buffer *_buffer,
+                                EGLint attribute, EGLint *value)
+{
+   struct wl_drm_buffer *buffer = (struct wl_drm_buffer *) _buffer;
+   struct pipe_resource *resource = buffer->driver_buffer;
+
+   if (!wayland_buffer_is_drm(&buffer->buffer))
+      return EGL_FALSE;
+
+   if (attribute == EGL_WAYLAND_BUFFER_COMPONENTS_WL) {
+      switch (resource->format) {
+      case PIPE_FORMAT_B8G8R8A8_UNORM:
+         *value = EGL_WAYLAND_BUFFER_RGBA_WL;
+         return EGL_TRUE;
+      case PIPE_FORMAT_B8G8R8X8_UNORM:
+         *value = EGL_WAYLAND_BUFFER_RGB_WL;
+         return EGL_TRUE;
+      default:
+         return EGL_FALSE;
+      }
+   }
+
+   return EGL_FALSE;
+}
 #endif /* EGL_WL_bind_wayland_display */
 
 void
@@ -907,7 +937,7 @@ egl_g3d_init_driver_api(_EGLDriver *drv)
 #ifdef EGL_WL_bind_wayland_display
    drv->API.BindWaylandDisplayWL = egl_g3d_bind_wayland_display_wl;
    drv->API.UnbindWaylandDisplayWL = egl_g3d_unbind_wayland_display_wl;
-
+   drv->API.QueryWaylandBufferWL = egl_g3d_query_wayland_buffer_wl;
 #endif
 
    drv->API.CreateSyncKHR = egl_g3d_create_sync;