st/egl: add get_pixmap_format callback to native_display
[mesa.git] / src / gallium / state_trackers / egl / x11 / native_dri2.c
index 70435276f6dafca729097c9a711bbc32091a7882..9a9e6c82406a884c4755f6780bad5f9cea1468a7 100644 (file)
@@ -683,18 +683,30 @@ dri2_display_get_configs(struct native_display *ndpy, int *num_configs)
 }
 
 static boolean
-dri2_display_is_pixmap_supported(struct native_display *ndpy,
-                                 EGLNativePixmapType pix,
-                                 const struct native_config *nconf)
+dri2_display_get_pixmap_format(struct native_display *ndpy,
+                               EGLNativePixmapType pix,
+                               enum pipe_format *format)
 {
    struct dri2_display *dri2dpy = dri2_display(ndpy);
-   uint depth, nconf_depth;
+   boolean ret = EGL_TRUE;
+   uint depth;
 
    depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix);
-   nconf_depth = util_format_get_blocksizebits(nconf->color_format);
+   switch (depth) {
+   case 32:
+   case 24:
+      *format = PIPE_FORMAT_B8G8R8A8_UNORM;
+      break;
+   case 16:
+      *format = PIPE_FORMAT_B5G6R5_UNORM;
+      break;
+   default:
+      *format = PIPE_FORMAT_NONE;
+      ret = EGL_FALSE;
+      break;
+   }
 
-   /* simple depth match for now */
-   return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth));
+   return ret;
 }
 
 static int
@@ -909,7 +921,7 @@ x11_create_dri2_display(Display *dpy,
    dri2dpy->base.destroy = dri2_display_destroy;
    dri2dpy->base.get_param = dri2_display_get_param;
    dri2dpy->base.get_configs = dri2_display_get_configs;
-   dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
+   dri2dpy->base.get_pixmap_format = dri2_display_get_pixmap_format;
    dri2dpy->base.copy_to_pixmap = native_display_copy_to_pixmap;
    dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
    dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;