From f09c66b3cc9542b0a8f795e34b882c2b8f9f26f7 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 21 Apr 2011 10:51:14 +0200 Subject: [PATCH] egl_dri2: Create wl_buffers for pixmap surfaces Needed since wayland-egl doesnt do this anymore. --- src/egl/drivers/dri2/platform_wayland.c | 33 ++++++++++++++--------- src/egl/wayland/wayland-egl/wayland-egl.c | 2 ++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index c3dee7ff0f7..c0860a73778 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -208,6 +208,19 @@ dri2_wl_egl_pixmap_destroy(struct wl_egl_pixmap *egl_pixmap) egl_pixmap->destroy = NULL; } +static struct wl_buffer * +wayland_create_buffer(struct dri2_egl_surface *dri2_surf, + __DRIbuffer *buffer, + struct wl_visual *visual) +{ + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + + return wl_drm_create_buffer(dri2_dpy->wl_drm, buffer->name, + dri2_surf->base.Width, dri2_surf->base.Height, + buffer->pitch, visual); +} + static void dri2_process_back_buffer(struct dri2_egl_surface *dri2_surf, unsigned format) { @@ -356,6 +369,12 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable, assert(dri2_surf->type == DRI2_PIXMAP_SURFACE || dri2_surf->dri_buffers[__DRI_BUFFER_BACK_LEFT]); + if (dri2_surf->type == DRI2_PIXMAP_SURFACE && !dri2_surf->wl_pix->buffer) + dri2_surf->wl_pix->buffer = + wayland_create_buffer(dri2_surf, + dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT], + dri2_surf->wl_pix->visual); + *out_count = dri2_surf->buffer_count; if (dri2_surf->buffer_count == 0) return NULL; @@ -416,17 +435,6 @@ dri2_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) #endif } -static struct wl_buffer * -wayland_create_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer) -{ - struct dri2_egl_display *dri2_dpy = - dri2_egl_display(dri2_surf->base.Resource.Display); - - return wl_drm_create_buffer(dri2_dpy->wl_drm, buffer->name, - dri2_surf->base.Width, dri2_surf->base.Height, - buffer->pitch, dri2_surf->wl_win->visual); -} - static void wayland_frame_callback(struct wl_surface *surface, void *data, uint32_t time) { @@ -477,7 +485,8 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) if (!dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT]) dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT] = wayland_create_buffer(dri2_surf, - dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT]); + dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT], + dri2_surf->wl_win->visual); wl_surface_attach(dri2_surf->wl_win->surface, dri2_surf->wl_drm_buffer[WL_BUFFER_FRONT], diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c b/src/egl/wayland/wayland-egl/wayland-egl.c index 891a497d1d1..3e1a9c45bdc 100644 --- a/src/egl/wayland/wayland-egl/wayland-egl.c +++ b/src/egl/wayland/wayland-egl/wayland-egl.c @@ -79,6 +79,8 @@ wl_egl_pixmap_create(int width, int height, egl_pixmap->visual = visual; egl_pixmap->destroy = NULL; + egl_pixmap->buffer = NULL; + egl_pixmap->driver_private = NULL; return egl_pixmap; } -- 2.30.2