diff options
author | Benjamin Franzke <[email protected]> | 2011-04-30 11:17:01 +0200 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2011-05-06 10:33:50 -0400 |
commit | 834b84149d99526e4e7a3cfa6ba9fe81e5fb9eda (patch) | |
tree | 8f55be2305cf4fa8727c7aec72d30333916e2dcf /src/egl/drivers/dri2 | |
parent | a3e2c8f31f0c5d8d5c1c76e33a572c7be8938573 (diff) |
egl/wayland-drm: Generalize interface
Do not depend on _EGLDisplay and _EGLImage.
Diffstat (limited to 'src/egl/drivers/dri2')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 71 |
1 files changed, 54 insertions, 17 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 5e47fbe126a..b03ffc3cf9b 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -922,14 +922,11 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx, return &dri2_img->base; } -static EGLBoolean -dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, - EGLint *name, EGLint *handle, EGLint *stride); - static _EGLImage * dri2_reference_drm_image(_EGLDisplay *disp, _EGLContext *ctx, - _EGLImage *image, EGLint width, EGLint height) + __DRIimage *dri_image, EGLint width, EGLint height) { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); EGLint attr_list[] = { EGL_WIDTH, 0, EGL_HEIGHT, 0, @@ -939,8 +936,8 @@ dri2_reference_drm_image(_EGLDisplay *disp, _EGLContext *ctx, }; EGLint name, stride; - dri2_export_drm_image_mesa(disp->Driver, disp, image, - &name, NULL, &stride); + dri2_dpy->image->queryImage(dri_image, __DRI_IMAGE_ATTRIB_NAME, &name); + dri2_dpy->image->queryImage(dri_image, __DRI_IMAGE_ATTRIB_STRIDE, &stride); attr_list[1] = width; attr_list[3] = height; @@ -954,16 +951,19 @@ dri2_reference_drm_image(_EGLDisplay *disp, _EGLContext *ctx, #ifdef HAVE_WAYLAND_PLATFORM static _EGLImage * dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx, - EGLClientBuffer buffer, + EGLClientBuffer _buffer, const EGLint *attr_list) { - struct wl_drm_buffer *wl_drm_buffer = (struct wl_drm_buffer *) buffer; + struct wl_buffer *buffer = (struct wl_buffer *) _buffer; + (void) attr_list; - (void) attr_list; + if (!wayland_buffer_is_drm(buffer)) + return NULL; - return dri2_reference_drm_image(disp, ctx, wl_drm_buffer->image, - wl_drm_buffer->buffer.width, - wl_drm_buffer->buffer.height); + return dri2_reference_drm_image(disp, ctx, + wayland_drm_buffer_get_buffer(buffer), + buffer->width, + buffer->height); } #endif @@ -1112,6 +1112,41 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, } #ifdef HAVE_WAYLAND_PLATFORM + +static void * +dri2_wl_reference_buffer(void *user_data, uint32_t name, + int32_t width, int32_t height, + uint32_t stride, struct wl_visual *visual) +{ + _EGLDisplay *disp = user_data; + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + __DRIimage *image; + + image = dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen, + width, height, + __DRI_IMAGE_FORMAT_ARGB8888, + name, stride / 4, + NULL); + + return image; +} + +static void +dri2_wl_release_buffer(void *user_data, void *buffer) +{ + _EGLDisplay *disp = user_data; + __DRIimage *image = buffer; + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + + dri2_dpy->image->destroyImage(image); +} + +static struct wayland_drm_callbacks wl_drm_callbacks = { + .authenticate = NULL, + .reference_buffer = dri2_wl_reference_buffer, + .release_buffer = dri2_wl_release_buffer +}; + static EGLBoolean dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *wl_dpy) @@ -1123,10 +1158,12 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, if (dri2_dpy->wl_server_drm) return EGL_FALSE; + wl_drm_callbacks.authenticate = + (int(*)(void *, uint32_t)) dri2_dpy->authenticate; + dri2_dpy->wl_server_drm = - wayland_drm_init(wl_dpy, disp, - dri2_dpy->authenticate, - dri2_dpy->device_name); + wayland_drm_init(wl_dpy, dri2_dpy->device_name, + &wl_drm_callbacks, disp); if (!dri2_dpy->wl_server_drm) return EGL_FALSE; @@ -1145,7 +1182,7 @@ dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp, if (!dri2_dpy->wl_server_drm) return EGL_FALSE; - wayland_drm_destroy(dri2_dpy->wl_server_drm); + wayland_drm_uninit(dri2_dpy->wl_server_drm); dri2_dpy->wl_server_drm = NULL; return EGL_TRUE; |