Mesa (7.10): st/egl: Assorted fixes for dri2_display_get_configs.

Chia-I Wu olv at kemper.freedesktop.org
Wed Dec 22 08:36:24 UTC 2010


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

Author: Chia-I Wu <olv at lunarg.com>
Date:   Wed Dec 22 15:13:52 2010 +0800

st/egl: Assorted fixes for dri2_display_get_configs.

Set window_bit only when the visual id is greater than zero.  Correct
visual types.  Skip slow configs as they are not relevant.  Finally, do
not return duplicated configs.
(cherry picked from commit 445cb9e53b1a98eb8af6ec499912a52b03fb1ce3)

---

 src/gallium/state_trackers/egl/x11/native_dri2.c |   40 +++++++++++++++++++--
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 8108ce4..0d19163 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -548,6 +548,10 @@ dri2_display_convert_config(struct native_display *ndpy,
    if (!mode->xRenderable || !mode->drawableType)
       return FALSE;
 
+   /* fast/slow configs are probably not relevant */
+   if (mode->visualRating == GLX_SLOW_CONFIG)
+      return FALSE;
+
    nconf->buffer_mask = 1 << NATIVE_ATTACHMENT_FRONT_LEFT;
    if (mode->doubleBufferMode)
       nconf->buffer_mask |= 1 << NATIVE_ATTACHMENT_BACK_LEFT;
@@ -568,13 +572,32 @@ dri2_display_convert_config(struct native_display *ndpy,
    if (nconf->color_format == PIPE_FORMAT_NONE)
       return FALSE;
 
-   if (mode->drawableType & GLX_WINDOW_BIT)
+   if ((mode->drawableType & GLX_WINDOW_BIT) && mode->visualID)
       nconf->window_bit = TRUE;
    if (mode->drawableType & GLX_PIXMAP_BIT)
       nconf->pixmap_bit = TRUE;
 
    nconf->native_visual_id = mode->visualID;
-   nconf->native_visual_type = mode->visualType;
+   switch (mode->visualType) {
+   case GLX_TRUE_COLOR:
+      nconf->native_visual_type = TrueColor;
+      break;
+   case GLX_DIRECT_COLOR:
+      nconf->native_visual_type = DirectColor;
+      break;
+   case GLX_PSEUDO_COLOR:
+      nconf->native_visual_type = PseudoColor;
+      break;
+   case GLX_STATIC_COLOR:
+      nconf->native_visual_type = StaticColor;
+      break;
+   case GLX_GRAY_SCALE:
+      nconf->native_visual_type = GrayScale;
+      break;
+   case GLX_STATIC_GRAY:
+      nconf->native_visual_type = StaticGray;
+      break;
+   }
    nconf->level = mode->level;
    nconf->samples = mode->samples;
 
@@ -614,8 +637,17 @@ dri2_display_get_configs(struct native_display *ndpy, int *num_configs)
       count = 0;
       for (i = 0; i < num_modes; i++) {
          struct native_config *nconf = &dri2dpy->configs[count].base;
-         if (dri2_display_convert_config(&dri2dpy->base, modes, nconf))
-            count++;
+
+         if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) {
+            int j;
+            /* look for duplicates */
+            for (j = 0; j < count; j++) {
+               if (memcmp(&dri2dpy->configs[j], nconf, sizeof(*nconf)) == 0)
+                  break;
+            }
+            if (j == count)
+               count++;
+         }
          modes = modes->next;
       }
 




More information about the mesa-commit mailing list