vo_opengl: x11: move RGBA visual test to x11_common.c

So that the EGL code can use it too.

Also print the actual FB config ID, instead of nonsense. (I _think_ once
in the past a certain GLX implementation just used numeric config IDs
casted to EGLConfig - or at least that would explain this nonsense.)
This commit is contained in:
wm4 2016-12-30 19:53:46 +01:00
parent 7033a4334b
commit 58a0c43cf4
3 changed files with 25 additions and 12 deletions

View File

@ -160,17 +160,13 @@ static GLXFBConfig select_fb_config(struct vo *vo, const int *attribs, int flags
if (flags & VOFLAG_ALPHA) {
for (int n = 0; n < fbcount; n++) {
XVisualInfo *v = glXGetVisualFromFBConfig(vo->x11->display, fbc[n]);
if (!v)
continue;
// This is a heuristic at best. Note that normal 8 bit Visuals use
// a depth of 24, even if the pixels are padded to 32 bit. If the
// depth is higher than 24, the remaining bits must be alpha.
// Note: vinfo->bits_per_rgb appears to be useless (is always 8).
unsigned long mask = v->depth == sizeof(unsigned long) * 8 ?
(unsigned long)-1 : (1UL << v->depth) - 1;
if (mask & ~(v->red_mask | v->green_mask | v->blue_mask)) {
fbconfig = fbc[n];
break;
if (v) {
bool is_rgba = vo_x11_is_rgba_visual(v);
XFree(v);
if (is_rgba) {
fbconfig = fbc[n];
break;
}
}
}
}
@ -235,7 +231,10 @@ static int glx_init(struct MPGLContext *ctx, int flags)
MP_ERR(vo, "no GLX support present\n");
goto uninit;
}
MP_VERBOSE(vo, "GLX chose FB config with ID 0x%x\n", (int)(intptr_t)fbc);
int fbid = -1;
if (!glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_FBCONFIG_ID, &fbid))
MP_VERBOSE(vo, "GLX chose FB config with ID 0x%x\n", fbid);
glx_ctx->fbc = fbc;
glx_ctx->vinfo = glXGetVisualFromFBConfig(vo->x11->display, fbc);

View File

@ -2044,3 +2044,15 @@ bool vo_x11_screen_is_composited(struct vo *vo)
Atom NET_WM_CM = XInternAtom(x11->display, buf, False);
return XGetSelectionOwner(x11->display, NET_WM_CM) != None;
}
// Return whether the given visual has alpha (when compositing is used).
bool vo_x11_is_rgba_visual(XVisualInfo *v)
{
// This is a heuristic at best. Note that normal 8 bit Visuals use
// a depth of 24, even if the pixels are padded to 32 bit. If the
// depth is higher than 24, the remaining bits must be alpha.
// Note: vinfo->bits_per_rgb appears to be useless (is always 8).
unsigned long mask = v->depth == sizeof(unsigned long) * 8 ?
(unsigned long)-1 : (1UL << v->depth) - 1;
return mask & ~(v->red_mask | v->green_mask | v->blue_mask);
}

View File

@ -139,4 +139,6 @@ void vo_x11_wait_events(struct vo *vo, int64_t until_time_us);
void vo_x11_silence_xlib(int dir);
bool vo_x11_is_rgba_visual(XVisualInfo *v);
#endif /* MPLAYER_X11_COMMON_H */