summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2013-09-14 23:06:36 -0700
committerKristian Høgsberg <[email protected]>2013-10-15 22:06:46 -0700
commite3d0a0eac7a742de9ef427b86d2ca0051a957bf7 (patch)
tree414e1a3b9f6de194b9ac05106de87d9df0ef4948 /src
parente2620c1a745a02c75a45ebe0725c500f441f4ac4 (diff)
egl_dri2: Match X11 visuals using rgba masks instead of depth
Matching on visual depth to buffer size makes 8 bpc RGBA look similar to 10 bit RGB with 2 bit alphs - both have buffer size 32. Instead, build the rgba masks from the visual data and use that for finding matching DRI configs. We need to keep the special case that allows us to match 24 bit visuals to DRI configs with buffer size 32. We do that by creating an alpha mask of "all the non-rgb bits" for 24 bit visuals and matching a second time with that. Signed-off-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/egl/drivers/dri2/platform_x11.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index ec76aecfdd7..d1ceb6238ef 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -630,6 +630,7 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
xcb_depth_iterator_t d;
xcb_visualtype_t *visuals;
int i, j, id;
+ unsigned int rgba_masks[4];
EGLint surface_type;
EGLint config_attrs[] = {
EGL_NATIVE_VISUAL_ID, 0,
@@ -660,8 +661,26 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
config_attrs[1] = visuals[i].visual_id;
config_attrs[3] = visuals[i]._class;
+ rgba_masks[0] = visuals[i].red_mask;
+ rgba_masks[1] = visuals[i].green_mask;
+ rgba_masks[2] = visuals[i].blue_mask;
+ rgba_masks[3] = 0;
dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
- d.data->depth, surface_type, config_attrs, NULL);
+ 0, 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) {
+ rgba_masks[3] =
+ ~(rgba_masks[0] | rgba_masks[1] | rgba_masks[2]);
+ dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
+ 0, surface_type, config_attrs, rgba_masks);
+ }
}
}