diff options
Diffstat (limited to 'src/gallium/state_trackers/egl/x11/native_dri2.c')
-rw-r--r-- | src/gallium/state_trackers/egl/x11/native_dri2.c | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 8108ce4586..adcc3b39d6 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -40,11 +40,6 @@ #ifdef GLX_DIRECT_RENDERING -enum dri2_surface_type { - DRI2_SURFACE_TYPE_WINDOW, - DRI2_SURFACE_TYPE_PIXMAP, -}; - struct dri2_display { struct native_display base; Display *dpy; @@ -66,7 +61,6 @@ struct dri2_display { struct dri2_surface { struct native_surface base; Drawable drawable; - enum dri2_surface_type type; enum pipe_format color_format; struct dri2_display *dri2dpy; @@ -439,12 +433,10 @@ dri2_surface_destroy(struct native_surface *nsurf) static struct dri2_surface * dri2_display_create_surface(struct native_display *ndpy, - enum dri2_surface_type type, Drawable drawable, - const struct native_config *nconf) + enum pipe_format color_format) { struct dri2_display *dri2dpy = dri2_display(ndpy); - struct dri2_config *dri2conf = dri2_config(nconf); struct dri2_surface *dri2surf; dri2surf = CALLOC_STRUCT(dri2_surface); @@ -452,9 +444,8 @@ dri2_display_create_surface(struct native_display *ndpy, return NULL; dri2surf->dri2dpy = dri2dpy; - dri2surf->type = type; dri2surf->drawable = drawable; - dri2surf->color_format = dri2conf->base.color_format; + dri2surf->color_format = color_format; dri2surf->base.destroy = dri2_surface_destroy; dri2surf->base.present = dri2_surface_present; @@ -480,8 +471,8 @@ dri2_display_create_window_surface(struct native_display *ndpy, { struct dri2_surface *dri2surf; - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_WINDOW, - (Drawable) win, nconf); + dri2surf = dri2_display_create_surface(ndpy, + (Drawable) win, nconf->color_format); return (dri2surf) ? &dri2surf->base : NULL; } @@ -492,8 +483,29 @@ dri2_display_create_pixmap_surface(struct native_display *ndpy, { struct dri2_surface *dri2surf; - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PIXMAP, - (Drawable) pix, nconf); + if (!nconf) { + struct dri2_display *dri2dpy = dri2_display(ndpy); + uint depth, nconf_depth; + int i; + + depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix); + for (i = 0; i < dri2dpy->num_configs; i++) { + nconf_depth = util_format_get_blocksizebits( + dri2dpy->configs[i].base.color_format); + /* simple depth match for now */ + if (depth == nconf_depth || + (depth == 24 && depth + 8 == nconf_depth)) { + nconf = &dri2dpy->configs[i].base; + break; + } + } + + if (!nconf) + return NULL; + } + + dri2surf = dri2_display_create_surface(ndpy, + (Drawable) pix, nconf->color_format); return (dri2surf) ? &dri2surf->base : NULL; } @@ -548,6 +560,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,17 +584,33 @@ 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; - - nconf->slow_config = (mode->visualRating == GLX_SLOW_CONFIG); if (mode->transparentPixel == GLX_TRANSPARENT_RGB) { nconf->transparent_rgb = TRUE; @@ -614,8 +646,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; } |