fix case when EGL driver doesn't support EGL_NATIVE_VISUAL_ID

Some EGL drivers, such as the PowerVR simulator (and some proprietary drivers)
return zero when the EGLConfig is queried for the EGL_NATIVE_VISUAL_ID
attribute via eglGetConfigAttrib().

This patch detects and attempts to work around that situation by picking a
visual with the same color depth.

http://bugzilla.openedhand.com/show_bug.cgi?id=2123
This commit is contained in:
Brian Tarricone 2010-03-25 19:44:37 -07:00 committed by Neil Roberts
parent 26b061c3a8
commit c4ae1a55fa

View File

@ -422,25 +422,48 @@ static XVisualInfo *
clutter_backend_egl_get_visual_info (ClutterBackendX11 *backend_x11)
{
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend_x11);
EGLint visualid;
XVisualInfo visinfo_template;
XVisualInfo *visinfo = None;
int template_mask = 0;
XVisualInfo *visinfo = NULL;
int visinfos_count;
EGLint visualid, red_size, green_size, blue_size, alpha_size;
if (!clutter_backend_egl_create_context (CLUTTER_BACKEND (backend_x11), NULL))
return NULL;
visinfo_template.screen = backend_x11->xscreen_num;
template_mask |= VisualScreenMask;
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
EGL_NATIVE_VISUAL_ID, &visualid);
visinfo_template.screen = backend_x11->xscreen_num;
visinfo_template.visualid = visualid;
if (visualid != 0)
{
visinfo_template.visualid = visualid;
template_mask |= VisualIDMask;
}
else
{
/* some EGL drivers don't implement the EGL_NATIVE_VISUAL_ID
* attribute, so attempt to find the closest match. */
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
EGL_RED_SIZE, &red_size);
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
EGL_GREEN_SIZE, &green_size);
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
EGL_BLUE_SIZE, &blue_size);
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
EGL_ALPHA_SIZE, &alpha_size);
visinfo_template.depth = red_size + green_size + blue_size + alpha_size;
template_mask |= VisualDepthMask;
}
visinfo = XGetVisualInfo (backend_x11->xdpy,
VisualScreenMask | VisualIDMask,
template_mask,
&visinfo_template,
&visinfos_count);
if (!visinfo)
return None;
return visinfo;
}