wayland-drm: Drop the non-premul formats, use format codes from drm_fourcc.h
[mesa.git] / src / gallium / state_trackers / egl / common / native_wayland_drm_bufmgr_helper.c
index bc2cee4c386b808b31b4b58abf5ee507655434b5..80b3f227d0b1c1310f62a3af4fed20e584706b8c 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_ARGB8888:
+      pf = PIPE_FORMAT_B8G8R8A8_UNORM;
+      break;
+   case WL_DRM_FORMAT_XRGB8888:
+      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;