summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-05-11 17:41:54 +0200
committerwm4 <wm4@nowhere>2017-05-11 17:47:33 +0200
commit2b616c0682a894152b06ef7249b32ef17037b3e5 (patch)
treed2714deb7052e11b32437d66c348fa2b2ac6562e /video/out/opengl/context.c
parentf2961425e770defe7cedc14ee2d4c9d4a53ab203 (diff)
downloadmpv-2b616c0682a894152b06ef7249b32ef17037b3e5.tar.bz2
mpv-2b616c0682a894152b06ef7249b32ef17037b3e5.tar.xz
vo_opengl: drop TLS usage
TLS is a headache. We should avoid it if we can. The involved mechanism is unfortunately entangled with the unfortunate libmpv API for returning pointers to host API objects. This has to be kept until we change the API somehow. Practically untested out of pure laziness. I'm sure I'll get a bunch of reports if it's broken.
Diffstat (limited to 'video/out/opengl/context.c')
-rw-r--r--video/out/opengl/context.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c
index 117d7f830e..72311e11fa 100644
--- a/video/out/opengl/context.c
+++ b/video/out/opengl/context.c
@@ -126,34 +126,13 @@ 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
-#define MP_TLS _Thread_local
-#elif HAVE_GCC_TLS
-#define MP_TLS __thread
-#endif
-
-#ifdef MP_TLS
-static MP_TLS 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)
+static void *get_native_display(void *pctx, const char *name)
{
+ MPGLContext *ctx = pctx;
+ if (!ctx->native_display_type || !name)
+ return NULL;
+ return strcmp(ctx->native_display_type, name) == 0 ? ctx->native_display : NULL;
}
-#endif
static MPGLContext *init_backend(struct vo *vo, const struct mpgl_driver *driver,
bool probing, int vo_flags)
@@ -195,7 +174,8 @@ static MPGLContext *init_backend(struct vo *vo, const struct mpgl_driver *driver
ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG);
- set_current_context(ctx);
+ ctx->gl->get_native_display_ctx = ctx;
+ ctx->gl->get_native_display = get_native_display;
return ctx;
@@ -253,7 +233,6 @@ void mpgl_swap_buffers(struct MPGLContext *ctx)
void mpgl_uninit(MPGLContext *ctx)
{
- set_current_context(NULL);
if (ctx)
ctx->driver->uninit(ctx);
talloc_free(ctx);