From a8c092266e9885f3370bbeae15bd80ebf035d05d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 19 Jul 2012 16:07:55 -0400 Subject: [PATCH] gallium-egl: Move wayland query_buffer implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../state_trackers/egl/common/egl_g3d_api.c | 34 +++---------------- .../egl/common/native_wayland_bufmgr.h | 4 +++ .../common/native_wayland_drm_bufmgr_helper.c | 34 +++++++++++++++++++ .../common/native_wayland_drm_bufmgr_helper.h | 5 +++ .../state_trackers/egl/drm/native_drm.c | 3 +- .../state_trackers/egl/wayland/native_drm.c | 3 +- .../state_trackers/egl/x11/native_dri2.c | 3 +- 7 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c index a73859c0b9d..aaf7b10b1c7 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c @@ -39,10 +39,6 @@ #include "egl_g3d_st.h" #include "native.h" -#ifdef EGL_WL_bind_wayland_display -#include -#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 */ diff --git a/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h b/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h index b29fd15c1ae..3d9bda935c8 100644 --- a/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h +++ b/src/gallium/state_trackers/egl/common/native_wayland_bufmgr.h @@ -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_ */ diff --git a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c index c520b536483..43655530d84 100644 --- a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c +++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c @@ -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 diff --git a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h index e7a21717aeb..40c46e94d1f 100644 --- a/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h +++ b/src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h @@ -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_ */ diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c index 3c4c19f1c17..feb1dc045bf 100644 --- a/src/gallium/state_trackers/egl/drm/native_drm.c +++ b/src/gallium/state_trackers/egl/drm/native_drm.c @@ -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 */ diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c index e3bd628675e..006b3d507af 100644 --- a/src/gallium/state_trackers/egl/wayland/native_drm.c +++ b/src/gallium/state_trackers/egl/wayland/native_drm.c @@ -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 }; diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 5d7d3796e2b..70ae0f98443 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -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 */ -- 2.30.2