summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-13 19:43:56 +0200
committerwm4 <wm4@nowhere>2015-05-13 22:56:44 +0200
commit27da344e6f88166a236da0e3c2163c05125e4cb3 (patch)
tree0b61da5f1343b571e3e2546e1bb61b778c9c57d3
parent5ab05f61ca7b3cd4cbb9ab35a27e6e98860bbe85 (diff)
downloadmpv-27da344e6f88166a236da0e3c2163c05125e4cb3.tar.bz2
mpv-27da344e6f88166a236da0e3c2163c05125e4cb3.tar.xz
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.
-rw-r--r--video/out/gl_common.c48
1 files 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)
{