summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-19 12:59:07 +0100
committerwm4 <wm4@nowhere>2015-12-19 14:14:12 +0100
commit6154c1d06d38bd236a0adb57556f7d871b75469b (patch)
treeb99c5a3a50411cdddfeb8a2d2d85660d8ed349c2 /video
parent32cd85bc7ecfa74d3fefef5570e4ef546ae0643a (diff)
downloadmpv-6154c1d06d38bd236a0adb57556f7d871b75469b.tar.bz2
mpv-6154c1d06d38bd236a0adb57556f7d871b75469b.tar.xz
vo_opengl: split backend code from common.c to context.c
Now common.c only contains the code for the function loader, while context.c contains the backend loader/dispatcher. Not calling it "backend.c", because the central struct is called MPGLContext.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/angle.c2
-rw-r--r--video/out/opengl/cocoa.c2
-rw-r--r--video/out/opengl/common.c196
-rw-r--r--video/out/opengl/common.h70
-rw-r--r--video/out/opengl/context.c228
-rw-r--r--video/out/opengl/context.h104
-rw-r--r--video/out/opengl/drm_egl.c2
-rw-r--r--video/out/opengl/dxinterop.c2
-rw-r--r--video/out/opengl/rpi.c2
-rw-r--r--video/out/opengl/w32.c2
-rw-r--r--video/out/opengl/wayland.c2
-rw-r--r--video/out/opengl/x11.c2
-rw-r--r--video/out/opengl/x11egl.c2
-rw-r--r--video/out/vo_opengl.c2
14 files changed, 343 insertions, 275 deletions
diff --git a/video/out/opengl/angle.c b/video/out/opengl/angle.c
index d660f82762..61eb6af61b 100644
--- a/video/out/opengl/angle.c
+++ b/video/out/opengl/angle.c
@@ -26,7 +26,7 @@
#include "common/common.h"
#include "video/out/w32_common.h"
-#include "common.h"
+#include "context.h"
struct priv {
EGLDisplay egl_display;
diff --git a/video/out/opengl/cocoa.c b/video/out/opengl/cocoa.c
index 8a3c3721fa..1bcfa09755 100644
--- a/video/out/opengl/cocoa.c
+++ b/video/out/opengl/cocoa.c
@@ -24,7 +24,7 @@
#include <dlfcn.h>
#include "video/out/cocoa_common.h"
#include "osdep/macosx_versions.h"
-#include "common.h"
+#include "context.h"
struct cgl_context {
CGLPixelFormatObj pix;
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index 00cd535301..80e0348a3c 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -26,11 +26,6 @@
* version 2.1 of the License, or (at your option) any later version.
*/
-/**
- * \file gl_common.c
- * \brief OpenGL helper functions used by vo_gl.c and vo_gl2.c
- */
-
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@@ -38,11 +33,9 @@
#include <stdbool.h>
#include <math.h>
#include <assert.h>
-#include "talloc.h"
+
#include "common.h"
#include "common/common.h"
-#include "options/options.h"
-#include "options/m_option.h"
// This guesses if the current GL context is a suspected software renderer.
static bool is_software_gl(GL *gl)
@@ -534,190 +527,3 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
{
mpgl_load_functions2(gl, get_procaddr_wrapper, getProcAddress, ext2, log);
}
-
-extern const struct mpgl_driver mpgl_driver_x11;
-extern const struct mpgl_driver mpgl_driver_x11egl;
-extern const struct mpgl_driver mpgl_driver_x11_probe;
-extern const struct mpgl_driver mpgl_driver_drm_egl;
-extern const struct mpgl_driver mpgl_driver_cocoa;
-extern const struct mpgl_driver mpgl_driver_wayland;
-extern const struct mpgl_driver mpgl_driver_w32;
-extern const struct mpgl_driver mpgl_driver_angle;
-extern const struct mpgl_driver mpgl_driver_dxinterop;
-extern const struct mpgl_driver mpgl_driver_rpi;
-
-static const struct mpgl_driver *const backends[] = {
-#if HAVE_RPI
- &mpgl_driver_rpi,
-#endif
-#if HAVE_GL_COCOA
- &mpgl_driver_cocoa,
-#endif
-#if HAVE_EGL_ANGLE
- &mpgl_driver_angle,
-#endif
-#if HAVE_GL_WIN32
- &mpgl_driver_w32,
-#endif
-#if HAVE_GL_DXINTEROP
- &mpgl_driver_dxinterop,
-#endif
-#if HAVE_GL_WAYLAND
- &mpgl_driver_wayland,
-#endif
-#if HAVE_GL_X11
- &mpgl_driver_x11_probe,
-#endif
-#if HAVE_EGL_X11
- &mpgl_driver_x11egl,
-#endif
-#if HAVE_GL_X11
- &mpgl_driver_x11,
-#endif
-#if HAVE_EGL_DRM
- &mpgl_driver_drm_egl,
-#endif
-};
-
-int mpgl_find_backend(const char *name)
-{
- if (name == NULL || strcmp(name, "auto") == 0)
- return -1;
- for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) {
- if (strcmp(backends[n]->name, name) == 0)
- return n;
- }
- return -2;
-}
-
-int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
- struct bstr name, struct bstr param)
-{
- if (bstr_equals0(param, "help")) {
- mp_info(log, "OpenGL windowing backends:\n");
- mp_info(log, " auto (autodetect)\n");
- for (int n = 0; n < MP_ARRAY_SIZE(backends); n++)
- mp_info(log, " %s\n", backends[n]->name);
- return M_OPT_EXIT - 1;
- }
- char s[20];
- snprintf(s, sizeof(s), "%.*s", BSTR_P(param));
- 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 mpgl_driver *driver,
- bool probing, int vo_flags)
-{
- MPGLContext *ctx = talloc_ptrtype(NULL, ctx);
- *ctx = (MPGLContext) {
- .gl = talloc_zero(ctx, GL),
- .vo = vo,
- .driver = driver,
- };
- bool old_probing = vo->probing;
- vo->probing = probing; // hack; kill it once backends are separate
- MP_VERBOSE(vo, "Initializing OpenGL backend '%s'\n", ctx->driver->name);
- ctx->priv = talloc_zero_size(ctx, ctx->driver->priv_size);
- if (ctx->driver->init(ctx, vo_flags) < 0) {
- vo->probing = old_probing;
- talloc_free(ctx);
- return NULL;
- }
- vo->probing = old_probing;
-
- if (!ctx->gl->version && !ctx->gl->es)
- goto cleanup;
-
- if (probing && ctx->gl->es && (vo_flags & VOFLAG_NO_GLES)) {
- MP_VERBOSE(ctx->vo, "Skipping GLES backend.\n");
- goto cleanup;
- }
-
- if (ctx->gl->mpgl_caps & MPGL_CAP_SW) {
- MP_WARN(ctx->vo, "Suspected software renderer or indirect context.\n");
- if (vo->probing && !(vo_flags & VOFLAG_SW))
- goto cleanup;
- }
-
- ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG);
-
- set_current_context(ctx);
-
- return ctx;
-
-cleanup:
- mpgl_uninit(ctx);
- 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 (int n = 0; n < MP_ARRAY_SIZE(backends); n++) {
- ctx = init_backend(vo, backends[n], true, vo_flags);
- if (ctx)
- break;
- }
- // VO forced, but no backend is ok => force the first that works at all
- if (!ctx && !vo->probing) {
- for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) {
- ctx = init_backend(vo, backends[n], false, vo_flags);
- if (ctx)
- break;
- }
- }
- } else if (index >= 0) {
- ctx = init_backend(vo, backends[index], false, vo_flags);
- }
- return ctx;
-}
-
-int mpgl_reconfig_window(struct MPGLContext *ctx)
-{
- return ctx->driver->reconfig(ctx);
-}
-
-int mpgl_control(struct MPGLContext *ctx, int *events, int request, void *arg)
-{
- return ctx->driver->control(ctx, events, request, arg);
-}
-
-void mpgl_swap_buffers(struct MPGLContext *ctx)
-{
- ctx->driver->swap_buffers(ctx);
-}
-
-void mpgl_uninit(MPGLContext *ctx)
-{
- set_current_context(NULL);
- if (ctx)
- ctx->driver->uninit(ctx);
- talloc_free(ctx);
-}
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index f376a41f6a..c2eb0e9c2e 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -75,76 +75,6 @@ enum {
#define MPGL_VER_P(ver) MPGL_VER_GET_MAJOR(ver), MPGL_VER_GET_MINOR(ver)
-enum {
- VOFLAG_GLES = 1 << 0, // Hint to create a GLES2 context
- VOFLAG_NO_GLES = 1 << 1, // Hint to create a desktop GL context
- VOFLAG_GL_DEBUG = 1 << 2, // Hint to request debug OpenGL context
- VOFLAG_ALPHA = 1 << 3, // Hint to request alpha framebuffer
- VOFLAG_SW = 1 << 4, // Hint to accept a software GL renderer
-};
-
-struct MPGLContext;
-
-// A windowing backend (like X11, win32, ...), which provides OpenGL rendering.
-struct mpgl_driver {
- const char *name;
-
- // Size of the struct allocated for MPGLContext.priv
- int priv_size;
-
- // Init the GL context and possibly the underlying VO backend.
- // The created context should be compatible to GL 3.2 core profile, but
- // some other GL versions are supported as well (e.g. GL 2.1 or GLES 2).
- // Return 0 on success, negative value (-1) on error.
- int (*init)(struct MPGLContext *ctx, int vo_flags);
-
- // Resize the window, or create a new window if there isn't one yet.
- // Currently, there is an unfortunate interaction with ctx->vo, and
- // display size etc. are determined by it.
- // Return 0 on success, negative value (-1) on error.
- int (*reconfig)(struct MPGLContext *ctx);
-
- // Present the frame.
- void (*swap_buffers)(struct MPGLContext *ctx);
-
- // This behaves exactly like vo_driver.control().
- int (*control)(struct MPGLContext *ctx, int *events, int request, void *arg);
-
- // Destroy the GL context and possibly the underlying VO backend.
- void (*uninit)(struct MPGLContext *ctx);
-};
-
-typedef struct MPGLContext {
- GL *gl;
- struct vo *vo;
- const struct mpgl_driver *driver;
-
- // For hwdec_vaegl.c.
- const char *native_display_type;
- void *native_display;
-
- // Windows-specific hack. See vo_opengl dwmflush suboption.
- int dwm_flush_opt;
-
- // Flip the rendered image vertically. This is useful for dxinterop.
- bool flip_v;
-
- // For free use by the mpgl_driver.
- void *priv;
-} MPGLContext;
-
-MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags);
-void mpgl_uninit(MPGLContext *ctx);
-int mpgl_reconfig_window(struct MPGLContext *ctx);
-int mpgl_control(struct MPGLContext *ctx, int *events, int request, void *arg);
-void mpgl_swap_buffers(struct MPGLContext *ctx);
-
-int mpgl_find_backend(const char *name);
-
-struct m_option;
-int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
- struct bstr name, struct bstr param);
-
void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
const char *ext2, struct mp_log *log);
void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n),
diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c
new file mode 100644
index 0000000000..c863334306
--- /dev/null
+++ b/video/out/opengl/context.c
@@ -0,0 +1,228 @@
+/*
+ * common OpenGL routines
+ *
+ * copyleft (C) 2005-2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ * Special thanks go to the xine team and Matthias Hopf, whose video_out_opengl.c
+ * gave me lots of good ideas.
+ *
+ * This file is part of mpv.
+ *
+ * mpv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with mpv. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * You can alternatively redistribute this file and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+#include <math.h>
+#include <assert.h>
+
+#include "context.h"
+#include "common/common.h"
+#include "options/options.h"
+#include "options/m_option.h"
+
+extern const struct mpgl_driver mpgl_driver_x11;
+extern const struct mpgl_driver mpgl_driver_x11egl;
+extern const struct mpgl_driver mpgl_driver_x11_probe;
+extern const struct mpgl_driver mpgl_driver_drm_egl;
+extern const struct mpgl_driver mpgl_driver_cocoa;
+extern const struct mpgl_driver mpgl_driver_wayland;
+extern const struct mpgl_driver mpgl_driver_w32;
+extern const struct mpgl_driver mpgl_driver_angle;
+extern const struct mpgl_driver mpgl_driver_dxinterop;
+extern const struct mpgl_driver mpgl_driver_rpi;
+
+static const struct mpgl_driver *const backends[] = {
+#if HAVE_RPI
+ &mpgl_driver_rpi,
+#endif
+#if HAVE_GL_COCOA
+ &mpgl_driver_cocoa,
+#endif
+#if HAVE_EGL_ANGLE
+ &mpgl_driver_angle,
+#endif
+#if HAVE_GL_WIN32
+ &mpgl_driver_w32,
+#endif
+#if HAVE_GL_DXINTEROP
+ &mpgl_driver_dxinterop,
+#endif
+#if HAVE_GL_WAYLAND
+ &mpgl_driver_wayland,
+#endif
+#if HAVE_GL_X11
+ &mpgl_driver_x11_probe,
+#endif
+#if HAVE_EGL_X11
+ &mpgl_driver_x11egl,
+#endif
+#if HAVE_GL_X11
+ &mpgl_driver_x11,
+#endif
+#if HAVE_EGL_DRM
+ &mpgl_driver_drm_egl,
+#endif
+};
+
+int mpgl_find_backend(const char *name)
+{
+ if (name == NULL || strcmp(name, "auto") == 0)
+ return -1;
+ for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) {
+ if (strcmp(backends[n]->name, name) == 0)
+ return n;
+ }
+ return -2;
+}
+
+int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param)
+{
+ if (bstr_equals0(param, "help")) {
+ mp_info(log, "OpenGL windowing backends:\n");
+ mp_info(log, " auto (autodetect)\n");
+ for (int n = 0; n < MP_ARRAY_SIZE(backends); n++)
+ mp_info(log, " %s\n", backends[n]->name);
+ return M_OPT_EXIT - 1;
+ }
+ char s[20];
+ snprintf(s, sizeof(s), "%.*s", BSTR_P(param));
+ 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 mpgl_driver *driver,
+ bool probing, int vo_flags)
+{
+ MPGLContext *ctx = talloc_ptrtype(NULL, ctx);
+ *ctx = (MPGLContext) {
+ .gl = talloc_zero(ctx, GL),
+ .vo = vo,
+ .driver = driver,
+ };
+ bool old_probing = vo->probing;
+ vo->probing = probing; // hack; kill it once backends are separate
+ MP_VERBOSE(vo, "Initializing OpenGL backend '%s'\n", ctx->driver->name);
+ ctx->priv = talloc_zero_size(ctx, ctx->driver->priv_size);
+ if (ctx->driver->init(ctx, vo_flags) < 0) {
+ vo->probing = old_probing;
+ talloc_free(ctx);
+ return NULL;
+ }
+ vo->probing = old_probing;
+
+ if (!ctx->gl->version && !ctx->gl->es)
+ goto cleanup;
+
+ if (probing && ctx->gl->es && (vo_flags & VOFLAG_NO_GLES)) {
+ MP_VERBOSE(ctx->vo, "Skipping GLES backend.\n");
+ goto cleanup;
+ }
+
+ if (ctx->gl->mpgl_caps & MPGL_CAP_SW) {
+ MP_WARN(ctx->vo, "Suspected software renderer or indirect context.\n");
+ if (vo->probing && !(vo_flags & VOFLAG_SW))
+ goto cleanup;
+ }
+
+ ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG);
+
+ set_current_context(ctx);
+
+ return ctx;
+
+cleanup:
+ mpgl_uninit(ctx);
+ 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 (int n = 0; n < MP_ARRAY_SIZE(backends); n++) {
+ ctx = init_backend(vo, backends[n], true, vo_flags);
+ if (ctx)
+ break;
+ }
+ // VO forced, but no backend is ok => force the first that works at all
+ if (!ctx && !vo->probing) {
+ for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) {
+ ctx = init_backend(vo, backends[n], false, vo_flags);
+ if (ctx)
+ break;
+ }
+ }
+ } else if (index >= 0) {
+ ctx = init_backend(vo, backends[index], false, vo_flags);
+ }
+ return ctx;
+}
+
+int mpgl_reconfig_window(struct MPGLContext *ctx)
+{
+ return ctx->driver->reconfig(ctx);
+}
+
+int mpgl_control(struct MPGLContext *ctx, int *events, int request, void *arg)
+{
+ return ctx->driver->control(ctx, events, request, arg);
+}
+
+void mpgl_swap_buffers(struct MPGLContext *ctx)
+{
+ ctx->driver->swap_buffers(ctx);
+}
+
+void mpgl_uninit(MPGLContext *ctx)
+{
+ set_current_context(NULL);
+ if (ctx)
+ ctx->driver->uninit(ctx);
+ talloc_free(ctx);
+}
diff --git a/video/out/opengl/context.h b/video/out/opengl/context.h
new file mode 100644
index 0000000000..d8f6538fca
--- /dev/null
+++ b/video/out/opengl/context.h
@@ -0,0 +1,104 @@
+/*
+ * common OpenGL routines
+ *
+ * copyleft (C) 2005-2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ * Special thanks go to the xine team and Matthias Hopf, whose video_out_opengl.c
+ * gave me lots of good ideas.
+ *
+ * This file is part of mpv.
+ *
+ * mpv is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * mpv is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with mpv. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * You can alternatively redistribute this file and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#ifndef MP_GL_CONTEXT_H_
+#define MP_GL_CONTEXT_H_
+
+#include "common.h"
+
+enum {
+ VOFLAG_GLES = 1 << 0, // Hint to create a GLES2 context
+ VOFLAG_NO_GLES = 1 << 1, // Hint to create a desktop GL context
+ VOFLAG_GL_DEBUG = 1 << 2, // Hint to request debug OpenGL context
+ VOFLAG_ALPHA = 1 << 3, // Hint to request alpha framebuffer
+ VOFLAG_SW = 1 << 4, // Hint to accept a software GL renderer
+};
+
+struct MPGLContext;
+
+// A windowing backend (like X11, win32, ...), which provides OpenGL rendering.
+struct mpgl_driver {
+ const char *name;
+
+ // Size of the struct allocated for MPGLContext.priv
+ int priv_size;
+
+ // Init the GL context and possibly the underlying VO backend.
+ // The created context should be compatible to GL 3.2 core profile, but
+ // some other GL versions are supported as well (e.g. GL 2.1 or GLES 2).
+ // Return 0 on success, negative value (-1) on error.
+ int (*init)(struct MPGLContext *ctx, int vo_flags);
+
+ // Resize the window, or create a new window if there isn't one yet.
+ // Currently, there is an unfortunate interaction with ctx->vo, and
+ // display size etc. are determined by it.
+ // Return 0 on success, negative value (-1) on error.
+ int (*reconfig)(struct MPGLContext *ctx);
+
+ // Present the frame.
+ void (*swap_buffers)(struct MPGLContext *ctx);
+
+ // This behaves exactly like vo_driver.control().
+ int (*control)(struct MPGLContext *ctx, int *events, int request, void *arg);
+
+ // Destroy the GL context and possibly the underlying VO backend.
+ void (*uninit)(struct MPGLContext *ctx);
+};
+
+typedef struct MPGLContext {
+ GL *gl;
+ struct vo *vo;
+ const struct mpgl_driver *driver;
+
+ // For hwdec_vaegl.c.
+ const char *native_display_type;
+ void *native_display;
+
+ // Windows-specific hack. See vo_opengl dwmflush suboption.
+ int dwm_flush_opt;
+
+ // Flip the rendered image vertically. This is useful for dxinterop.
+ bool flip_v;
+
+ // For free use by the mpgl_driver.
+ void *priv;
+} MPGLContext;
+
+MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags);
+void mpgl_uninit(MPGLContext *ctx);
+int mpgl_reconfig_window(struct MPGLContext *ctx);
+int mpgl_control(struct MPGLContext *ctx, int *events, int request, void *arg);
+void mpgl_swap_buffers(struct MPGLContext *ctx);
+
+int mpgl_find_backend(const char *name);
+
+struct m_option;
+int mpgl_validate_backend_opt(struct mp_log *log, const struct m_option *opt,
+ struct bstr name, struct bstr param);
+
+#endif
diff --git a/video/out/opengl/drm_egl.c b/video/out/opengl/drm_egl.c
index f8e528201a..34029a1a34 100644
--- a/video/out/opengl/drm_egl.c
+++ b/video/out/opengl/drm_egl.c
@@ -34,7 +34,7 @@
#include <EGL/eglext.h>
#include <GL/gl.h>
-#include "common.h"
+#include "context.h"
#include "common/common.h"
#include "video/out/drm_common.h"
diff --git a/video/out/opengl/dxinterop.c b/video/out/opengl/dxinterop.c
index 093729351d..2ea2ea0ec9 100644
--- a/video/out/opengl/dxinterop.c
+++ b/video/out/opengl/dxinterop.c
@@ -25,7 +25,7 @@
#include <d3d9.h>
#include <dwmapi.h>
#include "video/out/w32_common.h"
-#include "common.h"
+#include "context.h"
// For WGL_ACCESS_WRITE_DISCARD_NV, etc.
#include <GL/wglext.h>
diff --git a/video/out/opengl/rpi.c b/video/out/opengl/rpi.c
index 79aad522e4..55594413a8 100644
--- a/video/out/opengl/rpi.c
+++ b/video/out/opengl/rpi.c
@@ -25,7 +25,7 @@
#include "common/common.h"
#include "video/out/x11_common.h"
-#include "common.h"
+#include "context.h"
#include "rpi.h"
diff --git a/video/out/opengl/w32.c b/video/out/opengl/w32.c
index 86f4414aa4..5157cd97a5 100644
--- a/video/out/opengl/w32.c
+++ b/video/out/opengl/w32.c
@@ -25,7 +25,7 @@
#include <dwmapi.h>
#include "video/out/w32_common.h"
#include "video/out/win32/exclusive_hack.h"
-#include "common.h"
+#include "context.h"
struct w32_context {
int opt_swapinterval;
diff --git a/video/out/opengl/wayland.c b/video/out/opengl/wayland.c
index 215084672d..c16444ba15 100644
--- a/video/out/opengl/wayland.c
+++ b/video/out/opengl/wayland.c
@@ -17,7 +17,7 @@
*/
#include "video/out/wayland_common.h"
-#include "common.h"
+#include "context.h"
static void egl_resize(struct vo_wayland_state *wl)
{
diff --git a/video/out/opengl/x11.c b/video/out/opengl/x11.c
index 1ef44ab604..46e9f0cb7e 100644
--- a/video/out/opengl/x11.c
+++ b/video/out/opengl/x11.c
@@ -27,7 +27,7 @@
#include "header_fixes.h"
#include "video/out/x11_common.h"
-#include "common.h"
+#include "context.h"
struct glx_context {
XVisualInfo *vinfo;
diff --git a/video/out/opengl/x11egl.c b/video/out/opengl/x11egl.c
index 405350d7bb..18f947d48d 100644
--- a/video/out/opengl/x11egl.c
+++ b/video/out/opengl/x11egl.c
@@ -28,7 +28,7 @@
#include "common/common.h"
#include "video/out/x11_common.h"
-#include "common.h"
+#include "context.h"
#include "egl_helpers.h"
struct priv {
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 068b004e5d..612cb79663 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -43,7 +43,7 @@
#include "video/mp_image.h"
#include "sub/osd.h"
-#include "opengl/common.h"
+#include "opengl/context.h"
#include "opengl/utils.h"
#include "opengl/hwdec.h"
#include "opengl/osd.h"