diff options
author | Kristian Høgsberg <[email protected]> | 2012-07-19 16:07:55 -0400 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2012-07-19 16:11:06 -0400 |
commit | a8c092266e9885f3370bbeae15bd80ebf035d05d (patch) | |
tree | 081cc1f9719bc31a92570ef9d6a7656b37b8b0bc /src/gallium | |
parent | fbe3fa74e5cdaf02f3738da7d6052e1f1fd7bbf2 (diff) |
gallium-egl: Move wayland query_buffer implementation
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 <[email protected]>
Diffstat (limited to 'src/gallium')
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 <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 */ 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 */ |