gallium-egl: Move wayland query_buffer implementation
authorKristian Høgsberg <krh@bitplanet.net>
Thu, 19 Jul 2012 20:07:55 +0000 (16:07 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 19 Jul 2012 20:11:06 +0000 (16:11 -0400)
Move it to native_wayland_drm_bufmgr_helper.c which only gets compiled when
wayland is enabled and which already includes the right headers.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
src/gallium/state_trackers/egl/common/egl_g3d_api.c
src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h
src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c
src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h
src/gallium/state_trackers/egl/drm/native_drm.c
src/gallium/state_trackers/egl/wayland/native_drm.c
src/gallium/state_trackers/egl/x11/native_dri2.c

index a73859c0b9da44a8304a2b5cccb2899fc77a8b45..aaf7b10b1c7836a4be3d61de2942b83346e76dcb 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.
  */
@@ -879,36 +875,16 @@ egl_g3d_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *dpy,
 
 static EGLBoolean
 egl_g3d_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *dpy,
-                                struct wl_buffer *_buffer,
+                                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;
+   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
 
-   if (!wayland_buffer_is_drm(&buffer->buffer))
+   if (!gdpy->native->wayland_bufmgr)
       return EGL_FALSE;
 
-   switch (attribute) {
-   case EGL_TEXTURE_FORMAT:
-      switch (resource->format) {
-      case PIPE_FORMAT_B8G8R8A8_UNORM:
-         *value = EGL_TEXTURE_RGBA;
-         return EGL_TRUE;
-      case PIPE_FORMAT_B8G8R8X8_UNORM:
-         *value = EGL_TEXTURE_RGB;
-         return EGL_TRUE;
-      default:
-         return EGL_FALSE;
-      }
-   case EGL_WIDTH:
-      *value = buffer->buffer.width;
-      return EGL_TRUE;
-   case EGL_HEIGHT:
-      *value = buffer->buffer.height;
-      return EGL_TRUE;
-   default:
-      return EGL_FALSE;
-   }
+   return gdpy->native->wayland_bufmgr->query_buffer(gdpy->native,
+                                                     buffer, attribute, value);
 }
 #endif /* EGL_WL_bind_wayland_display */
 
index b29fd15c1aeb7928bf112c7ad41cc41438b4a1e4..3d9bda935c87a323a75ed7264beda90cf22491d4 100644 (file)
@@ -41,6 +41,10 @@ struct native_display_wayland_bufmgr {
    struct pipe_resource *(*buffer_get_resource)(struct native_display *ndpy,
                                                 struct wl_buffer *buffer);
                              
+
+   boolean (*query_buffer)(struct native_display *ndpy,
+                           struct wl_buffer *buffer,
+                           int attribute, int *value);
 };
 
 #endif /* _NATIVE_WAYLAND_BUFMGR_H_ */
index c520b536483b0c8f8ca2c94f9af1b02cc8e1fef7..43655530d842a6cf9b92a177c620daa18fc77878 100644 (file)
@@ -69,4 +69,38 @@ egl_g3d_wl_drm_common_wl_buffer_get_resource(struct native_display *ndpy,
    return wayland_drm_buffer_get_buffer(buffer);
 }
 
+EGLBoolean
+egl_g3d_wl_drm_common_query_buffer(struct native_display *ndpy,
+                                   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;
+
+   switch (attribute) {
+   case EGL_TEXTURE_FORMAT:
+      switch (resource->format) {
+      case PIPE_FORMAT_B8G8R8A8_UNORM:
+         *value = EGL_TEXTURE_RGBA;
+         return EGL_TRUE;
+      case PIPE_FORMAT_B8G8R8X8_UNORM:
+         *value = EGL_TEXTURE_RGB;
+         return EGL_TRUE;
+      default:
+         return EGL_FALSE;
+      }
+   case EGL_WIDTH:
+      *value = buffer->buffer.width;
+      return EGL_TRUE;
+   case EGL_HEIGHT:
+      *value = buffer->buffer.height;
+      return EGL_TRUE;
+   default:
+      return EGL_FALSE;
+   }
+}
+
 #endif
index e7a21717aebfc011326fe5a8c1604d7782792709..40c46e94d1f32241a0a51e74fe32b205fb1ba9f9 100644 (file)
@@ -40,4 +40,9 @@ struct pipe_resource *
 egl_g3d_wl_drm_common_wl_buffer_get_resource(struct native_display *ndpy,
                                              struct wl_buffer *buffer);
 
+EGLBoolean
+egl_g3d_wl_drm_common_query_buffer(struct native_display *ndpy,
+                                   struct wl_buffer *buffer,
+                                   EGLint attribute, EGLint *value);
+
 #endif /* _NATIVE_WAYLAND_DRM_BUFMGR_HELPER_H_ */
index 3c4c19f1c17d76dc511d45d528021bb0063854bf..feb1dc045bf1e8be8fca146dc5f8606d841062d4 100644 (file)
@@ -240,7 +240,8 @@ drm_display_unbind_wayland_display(struct native_display *ndpy,
 static struct native_display_wayland_bufmgr drm_display_wayland_bufmgr = {
    drm_display_bind_wayland_display,
    drm_display_unbind_wayland_display,
-   egl_g3d_wl_drm_common_wl_buffer_get_resource
+   egl_g3d_wl_drm_common_wl_buffer_get_resource,
+   egl_g3d_wl_drm_common_query_buffer
 };
 
 #endif /* HAVE_WAYLAND_BACKEND */
index e3bd628675e062d20c215d0b90d3b26ed028994b..006b3d507afb510a051800d9885cca550edf3536 100644 (file)
@@ -290,7 +290,8 @@ wayland_drm_display_unbind_wayland_display(struct native_display *ndpy,
 static struct native_display_wayland_bufmgr wayland_drm_display_wayland_bufmgr = {
    wayland_drm_display_bind_wayland_display,
    wayland_drm_display_unbind_wayland_display,
-   egl_g3d_wl_drm_common_wl_buffer_get_resource
+   egl_g3d_wl_drm_common_wl_buffer_get_resource,
+   egl_g3d_wl_drm_common_query_buffer
 };
 
 
index 5d7d3796e2b71a47cd27e7fdd60414ab7f03374d..70ae0f984431ba3c7821535b0708d013b9b6c47d 100644 (file)
@@ -890,7 +890,8 @@ dri2_display_unbind_wayland_display(struct native_display *ndpy,
 static struct native_display_wayland_bufmgr dri2_display_wayland_bufmgr = {
    dri2_display_bind_wayland_display,
    dri2_display_unbind_wayland_display,
-   egl_g3d_wl_drm_common_wl_buffer_get_resource
+   egl_g3d_wl_drm_common_wl_buffer_get_resource,
+   egl_g3d_wl_drm_common_query_buffer
 };
 
 #endif /* HAVE_WAYLAND_BACKEND */