summaryrefslogtreecommitdiffstats
path: root/video/out/x11_common.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-12-30 19:53:46 +0100
committerwm4 <wm4@nowhere>2016-12-30 20:04:32 +0100
commit58a0c43cf45bab993e842b13d89d70335457a5a0 (patch)
tree5ab0bbab7d1abae82f18f91cb4722fac736ba6cf /video/out/x11_common.c
parent7033a4334bcf457b0cadaca7f4b0ce8099469632 (diff)
downloadmpv-58a0c43cf45bab993e842b13d89d70335457a5a0.tar.bz2
mpv-58a0c43cf45bab993e842b13d89d70335457a5a0.tar.xz
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.)
Diffstat (limited to 'video/out/x11_common.c')
-rw-r--r--video/out/x11_common.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 46e68d6e71..d42eb70dde 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -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);
+}