#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.
*/
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 */
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_ */
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
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_ */
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 */
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
};
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 */