st/egl: track changes to drop wl_visual in wayland
authorChia-I Wu <olv@lunarg.com>
Wed, 7 Sep 2011 13:41:30 +0000 (21:41 +0800)
committerChia-I Wu <olv@lunarg.com>
Wed, 7 Sep 2011 17:26:24 +0000 (01:26 +0800)
Follow a subset of changes in 7b1d94e5d1f53ac5f59000176aea1d02fc9a1181.
There are known issues, but it works to a certain degree.  Non-working
demos also fail gracefully.  More importantly, it fixes the build.

src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.c
src/gallium/state_trackers/egl/common/native_wayland_drm_bufmgr_helper.h
src/gallium/state_trackers/egl/wayland/native_drm.c
src/gallium/state_trackers/egl/wayland/native_shm.c

index bc2cee4c386b808b31b4b58abf5ee507655434b5..50b6efd6102194b48e30696475239f267e8ad1bc 100644 (file)
 void *
 egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name,
                                        int32_t width, int32_t height,
-                                       uint32_t stride,
-                                       struct wl_visual *visual)
+                                       uint32_t stride, uint32_t format)
 {
    struct native_display *ndpy = user_data;
    struct pipe_resource templ;
    struct winsys_handle wsh;
-   enum pipe_format format = PIPE_FORMAT_B8G8R8A8_UNORM;
+   enum pipe_format pf;
+
+   switch (format) {
+   case WL_DRM_FORMAT_ARGB32:
+   case WL_DRM_FORMAT_PREMULTIPLIED_ARGB32:
+      pf = PIPE_FORMAT_B8G8R8A8_UNORM;
+      break;
+   case WL_DRM_FORMAT_XRGB32:
+      pf = PIPE_FORMAT_B8G8R8X8_UNORM;
+      break;
+   default:
+      pf = PIPE_FORMAT_NONE;
+      break;
+   }
+
+   if (pf == PIPE_FORMAT_NONE)
+      return NULL;
 
    memset(&templ, 0, sizeof(templ));
    templ.target = PIPE_TEXTURE_2D;
-   templ.format = format;
+   templ.format = pf;
    templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
    templ.width0 = width;
    templ.height0 = height;
index 71cb6c52b26c33b0286a3f5eb0f4ce83a1abca2e..6085875f0980e0c3c4ba61d86a14907561ac42ce 100644 (file)
@@ -31,8 +31,7 @@
 void *
 egl_g3d_wl_drm_helper_reference_buffer(void *user_data, uint32_t name,
                                        int32_t width, int32_t height,
-                                       uint32_t stride,
-                                       struct wl_visual *visual);
+                                       uint32_t stride, uint32_t format);
 
 void
 egl_g3d_wl_drm_helper_unreference_buffer(void *user_data, void *buffer);
index 7a5b33affd854901dea6d54702c2f8e8181f1708..05c32f4773423e4f6a9aeecd3db8c1e024c77acd 100644 (file)
@@ -97,7 +97,7 @@ wayland_create_drm_buffer(struct wayland_display *display,
    struct pipe_resource *resource;
    struct winsys_handle wsh;
    uint width, height;
-   struct wl_visual *visual;
+   uint32_t format;
 
    resource = resource_surface_get_single_resource(surface->rsurf, attachment);
    resource_surface_get_size(surface->rsurf, &width, &height);
@@ -107,19 +107,21 @@ wayland_create_drm_buffer(struct wayland_display *display,
 
    pipe_resource_reference(&resource, NULL);
 
-   switch (surface->type) {
-   case WL_WINDOW_SURFACE:
-      visual = surface->win->visual;
+   switch (surface->color_format) {
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
+      /* assume premultiplied */
+      format = WL_DRM_FORMAT_PREMULTIPLIED_ARGB32;
       break;
-   case WL_PIXMAP_SURFACE:
-      visual = surface->pix->visual;
+   case PIPE_FORMAT_B8G8R8X8_UNORM:
+      format = WL_DRM_FORMAT_XRGB32;
       break;
    default:
       return NULL;
+      break;
    }
 
    return wl_drm_create_buffer(drmdpy->wl_drm, wsh.handle,
-                               width, height, wsh.stride, visual);
+                               width, height, wsh.stride, format);
 }
 
 static void
@@ -143,6 +145,12 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
    wl_drm_authenticate(drmdpy->wl_drm, magic);
 }
 
+static void
+drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
+{
+   /* TODO */
+}
+
 static void
 drm_handle_authenticated(void *data, struct wl_drm *drm)
 {
@@ -153,6 +161,7 @@ drm_handle_authenticated(void *data, struct wl_drm *drm)
 
 static const struct wl_drm_listener drm_listener = {
    drm_handle_device,
+   drm_handle_format,
    drm_handle_authenticated
 };
 
index 018fbe8e0efadec77381e55f4679df22711b865f..598df9fe2ced20aa7ccca0290d7efa02c185c489 100644 (file)
@@ -84,7 +84,7 @@ wayland_create_shm_buffer(struct wayland_display *display,
    struct pipe_resource *resource;
    struct winsys_handle wsh;
    uint width, height;
-   struct wl_visual *visual;
+   uint32_t format;
 
    resource = resource_surface_get_single_resource(surface->rsurf, attachment);
    resource_surface_get_size(surface->rsurf, &width, &height);
@@ -93,20 +93,21 @@ wayland_create_shm_buffer(struct wayland_display *display,
 
    pipe_resource_reference(&resource, NULL);
 
-   switch (surface->type) {
-   case WL_WINDOW_SURFACE:
-      visual = surface->win->visual;
+   switch (surface->color_format) {
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
+      format = WL_SHM_FORMAT_PREMULTIPLIED_ARGB32;
       break;
-   case WL_PIXMAP_SURFACE:
-      visual = surface->pix->visual;
+   case PIPE_FORMAT_B8G8R8X8_UNORM:
+      format = WL_SHM_FORMAT_XRGB32;
       break;
    default:
       return NULL;
+      break;
    }
 
    return wl_shm_create_buffer(shmdpy->wl_shm, wsh.fd,
                                width, height,
-                               wsh.stride, visual);
+                               wsh.stride, format);
 }
 
 static boolean