From 27da344e6f88166a236da0e3c2163c05125e4cb3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 13 May 2015 19:43:56 +0200 Subject: [PATCH] vo_opengl: merge GL backend creation/initialization The final goal is to remove the nonsense separation between the 3 backend init/vo_init/GL context creation calls. --- video/out/gl_common.c | 48 ++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 59e40a16bf..9ea67a64a0 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -580,7 +580,7 @@ int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt, } static MPGLContext *init_backend(struct vo *vo, MPGLSetBackendFn set_backend, - bool probing) + bool probing, int vo_flags) { MPGLContext *ctx = talloc_ptrtype(NULL, ctx); *ctx = (MPGLContext) { @@ -592,35 +592,9 @@ static MPGLContext *init_backend(struct vo *vo, MPGLSetBackendFn set_backend, set_backend(ctx); if (!ctx->vo_init(vo)) { talloc_free(ctx); - ctx = NULL; + return NULL; } vo->probing = old_probing; - return ctx; -} - -static MPGLContext *mpgl_create(struct vo *vo, const char *backend_name) -{ - MPGLContext *ctx = NULL; - int index = mpgl_find_backend(backend_name); - if (index == -1) { - for (const struct backend *entry = backends; entry->name; entry++) { - ctx = init_backend(vo, entry->init, true); - if (ctx) - break; - } - } else if (index >= 0) { - ctx = init_backend(vo, backends[index].init, false); - } - return ctx; -} - -// Create a VO window and create a GL context on it. -// vo_flags: passed to the backend's create window function -MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags) -{ - MPGLContext *ctx = mpgl_create(vo, backend_name); - if (!ctx) - goto cleanup; ctx->requested_gl_version = 300; @@ -650,6 +624,24 @@ cleanup: return NULL; } +// Create a VO window and create a GL context on it. +// vo_flags: passed to the backend's create window function +MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags) +{ + MPGLContext *ctx = NULL; + int index = mpgl_find_backend(backend_name); + if (index == -1) { + for (const struct backend *entry = backends; entry->name; entry++) { + ctx = init_backend(vo, entry->init, true, vo_flags); + if (ctx) + break; + } + } else if (index >= 0) { + ctx = init_backend(vo, backends[index].init, false, vo_flags); + } + return ctx; +} + // flags: passed to the backend function bool mpgl_reconfig_window(struct MPGLContext *ctx, int vo_flags) {