From fd19e94d0f8e17473c8ae0f5fbfe752f54afff52 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Mon, 10 Feb 2014 14:26:48 +0100 Subject: [PATCH] egl_dri2: Allow both 24 and 32 bit X visuals for RGBA configs When using RGBA EGLConfigs allow both RGB and RGBA X visuals, such that application can decide whether they want to use RGBA (and have the compositor blend their windows). On my system with this change EGLConfigs with a 24 bit visual comes up first, as such applications blindly picking the first EGLConfig will still get an RGB X visual. --- src/egl/drivers/dri2/egl_dri2.c | 5 +++++ src/egl/drivers/dri2/platform_x11.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 892f1f4..508bc9f 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -107,6 +107,11 @@ EGLint dri2_to_egl_attribute_map[] = { static EGLBoolean dri2_match_config(const _EGLConfig *conf, const _EGLConfig *criteria) { + + if (criteria->NativeVisualID != EGL_DONT_CARE && + conf->NativeVisualID != criteria->NativeVisualID) + return EGL_FALSE; + if (_eglCompareConfigs(conf, criteria, NULL, EGL_FALSE) != 0) return EGL_FALSE; diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index d878b77..c0fc249 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -665,14 +665,15 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, dri2_add_config(disp, dri2_dpy->driver_configs[j], id++, surface_type, config_attrs, rgba_masks); - /* Allow a 24-bit RGB visual to match a 32-bit RGBA EGLConfig. - * Otherwise it will only match a 32-bit RGBA visual. On a - * composited window manager on X11, this will make all of the - * EGLConfigs with destination alpha get blended by the - * compositor. This is probably not what the application - * wants... especially on drivers that only have 32-bit RGBA - * EGLConfigs! */ - if (d.data->depth == 24) { + /* Allow both 24-bit RGB visual and 32 bit RGBA to match a 32-bit + * RGBA EGLConfig. Otherwise it will only match a 32-bit RGBA + * visual. On a composited window manager on X11, this will make + * all of the EGLConfigs with destination alpha get blended by the + * compositor. This is probably not what the application wants... + * especially on drivers that only have 32-bit RGBA EGLConfigs! + * Allowing both allows applications to make the decision whether + * 32 bit visuals are intended */ + if (d.data->depth == 24 || d.data->depth == 32) { rgba_masks[3] = ~(rgba_masks[0] | rgba_masks[1] | rgba_masks[2]); dri2_add_config(disp, dri2_dpy->driver_configs[j], id++, -- 1.9.0.rc3