Mesa (master): egl_dri2: Create wl_buffers for pixmap surfaces

Kristian Høgsberg krh at kemper.freedesktop.org
Fri Apr 22 06:01:02 PDT 2011


Module: Mesa
Branch: master
Commit: f09c66b3cc9542b0a8f795e34b882c2b8f9f26f7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f09c66b3cc9542b0a8f795e34b882c2b8f9f26f7

Author: Benjamin Franzke <benjaminfranzke at googlemail.com>
Date:   Thu Apr 21 10:51:14 2011 +0200

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 c3dee7f..c0860a7 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 891a497..3e1a9c4 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;
 }



More information about the mesa-commit mailing list