diff options
author | wm4 <wm4@nowhere> | 2015-09-27 21:20:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-09-27 21:34:11 +0200 |
commit | 1fa674c109c05e082bf0fb43be064cbdabea3327 (patch) | |
tree | 9a4c109856a68c2795680f156aa394db5ba3ca2b /video/out/opengl/common.c | |
parent | 710872bc22c772d1ea8eb9a0383f5755dae08698 (diff) | |
download | mpv-1fa674c109c05e082bf0fb43be064cbdabea3327.tar.bz2 mpv-1fa674c109c05e082bf0fb43be064cbdabea3327.tar.xz |
vo_opengl: refactor EGL context information callback
Move the ugliness from x11egl.c to common.c, so that the ugliness
doesn't have to be duplicated in wayland.c.
Diffstat (limited to 'video/out/opengl/common.c')
-rw-r--r-- | video/out/opengl/common.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c index 640a357b12..7fced42d01 100644 --- a/video/out/opengl/common.c +++ b/video/out/opengl/common.c @@ -555,6 +555,29 @@ int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt, return mpgl_find_backend(s) >= -1 ? 1 : M_OPT_INVALID; } +#if HAVE_C11_TLS +static _Thread_local MPGLContext *current_context; + +static void * GLAPIENTRY get_native_display(const char *name) +{ + if (current_context && current_context->native_display_type && + name && strcmp(current_context->native_display_type, name) == 0) + return current_context->native_display; + return NULL; +} + +static void set_current_context(MPGLContext *context) +{ + current_context = context; + if (context && !context->gl->MPGetNativeDisplay) + context->gl->MPGetNativeDisplay = get_native_display; +} +#else +static void set_current_context(MPGLContext *context) +{ +} +#endif + static MPGLContext *init_backend(struct vo *vo, const struct backend *backend, bool probing, int vo_flags) { @@ -602,6 +625,8 @@ static MPGLContext *init_backend(struct vo *vo, const struct backend *backend, ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG); + set_current_context(ctx); + return ctx; cleanup: @@ -657,6 +682,7 @@ void mpgl_swap_buffers(struct MPGLContext *ctx) void mpgl_uninit(MPGLContext *ctx) { + set_current_context(NULL); if (ctx) { if (ctx->driver) { ctx->driver->uninit(ctx); |