diff options
author | Martin Herkt <lachs0r@srsfckn.biz> | 2017-02-12 01:01:56 +0100 |
---|---|---|
committer | Martin Herkt <lachs0r@srsfckn.biz> | 2017-02-12 01:01:56 +0100 |
commit | 35aa705c3ece8293652ffcf449c71fe80b96e722 (patch) | |
tree | 7c0fb34ec96204cbcd867a973b2476689919a5b4 /video/out/opengl/context_x11egl.c | |
parent | 10a005df0c981050afc35184a42173bea7ea2527 (diff) | |
parent | 3739d1318fdb658bb6037bfe06bb6cefb3b50a09 (diff) | |
download | mpv-35aa705c3ece8293652ffcf449c71fe80b96e722.tar.bz2 mpv-35aa705c3ece8293652ffcf449c71fe80b96e722.tar.xz |
Merge branch 'master' into release/current
Diffstat (limited to 'video/out/opengl/context_x11egl.c')
-rw-r--r-- | video/out/opengl/context_x11egl.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/video/out/opengl/context_x11egl.c b/video/out/opengl/context_x11egl.c index 7a9e4d31fc..2cf249fe1a 100644 --- a/video/out/opengl/context_x11egl.c +++ b/video/out/opengl/context_x11egl.c @@ -49,6 +49,29 @@ static void mpegl_uninit(MPGLContext *ctx) vo_x11_uninit(ctx->vo); } +static int pick_xrgba_config(void *user_data, EGLConfig *configs, int num_configs) +{ + struct MPGLContext *ctx = user_data; + struct priv *p = ctx->priv; + struct vo *vo = ctx->vo; + + for (int n = 0; n < num_configs; n++) { + int vID = 0, num; + eglGetConfigAttrib(p->egl_display, configs[n], EGL_NATIVE_VISUAL_ID, &vID); + XVisualInfo template = {.visualid = vID}; + XVisualInfo *vi = XGetVisualInfo(vo->x11->display, VisualIDMask, + &template, &num); + if (vi) { + bool is_rgba = vo_x11_is_rgba_visual(vi); + XFree(vi); + if (is_rgba) + return n; + } + } + + return 0; +} + static int mpegl_init(struct MPGLContext *ctx, int flags) { struct priv *p = ctx->priv; @@ -64,13 +87,20 @@ static int mpegl_init(struct MPGLContext *ctx, int flags) goto uninit; } + struct mpegl_opts opts = { + .vo_flags = flags, + .user_data = ctx, + .refine_config = (flags & VOFLAG_ALPHA) ? pick_xrgba_config : NULL, + }; + EGLConfig config; - if (!mpegl_create_context(p->egl_display, vo->log, flags, &p->egl_context, - &config)) + if (!mpegl_create_context_opts(p->egl_display, vo->log, &opts, + &p->egl_context, &config)) goto uninit; int vID, n; eglGetConfigAttrib(p->egl_display, config, EGL_NATIVE_VISUAL_ID, &vID); + MP_VERBOSE(vo, "chose visual 0x%x\n", vID); XVisualInfo template = {.visualid = vID}; XVisualInfo *vi = XGetVisualInfo(vo->x11->display, VisualIDMask, &template, &n); |