mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 02:20:43 -05:00
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:
parent
26b061c3a8
commit
c4ae1a55fa
@ -422,25 +422,48 @@ static XVisualInfo *
|
|||||||
clutter_backend_egl_get_visual_info (ClutterBackendX11 *backend_x11)
|
clutter_backend_egl_get_visual_info (ClutterBackendX11 *backend_x11)
|
||||||
{
|
{
|
||||||
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend_x11);
|
ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend_x11);
|
||||||
EGLint visualid;
|
|
||||||
XVisualInfo visinfo_template;
|
XVisualInfo visinfo_template;
|
||||||
XVisualInfo *visinfo = None;
|
int template_mask = 0;
|
||||||
|
XVisualInfo *visinfo = NULL;
|
||||||
int visinfos_count;
|
int visinfos_count;
|
||||||
|
EGLint visualid, red_size, green_size, blue_size, alpha_size;
|
||||||
|
|
||||||
if (!clutter_backend_egl_create_context (CLUTTER_BACKEND (backend_x11), NULL))
|
if (!clutter_backend_egl_create_context (CLUTTER_BACKEND (backend_x11), NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
visinfo_template.screen = backend_x11->xscreen_num;
|
||||||
|
template_mask |= VisualScreenMask;
|
||||||
|
|
||||||
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
|
eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config,
|
||||||
EGL_NATIVE_VISUAL_ID, &visualid);
|
EGL_NATIVE_VISUAL_ID, &visualid);
|
||||||
|
|
||||||
visinfo_template.screen = backend_x11->xscreen_num;
|
if (visualid != 0)
|
||||||
visinfo_template.visualid = visualid;
|
{
|
||||||
|
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,
|
visinfo = XGetVisualInfo (backend_x11->xdpy,
|
||||||
VisualScreenMask | VisualIDMask,
|
template_mask,
|
||||||
&visinfo_template,
|
&visinfo_template,
|
||||||
&visinfos_count);
|
&visinfos_count);
|
||||||
if (!visinfo)
|
|
||||||
return None;
|
|
||||||
|
|
||||||
return visinfo;
|
return visinfo;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user