summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-10-02 18:09:13 +0200
committerwm4 <wm4@nowhere>2015-10-02 18:10:58 +0200
commitfe993a67123f3e7bf8c92d7b38545ffc2aba79ed (patch)
tree2fe6271e161d12a76ff21b747c40e61170f8c5af
parent69bc7e34b9ce6a8be6731a42a00a01a120194a41 (diff)
downloadmpv-fe993a67123f3e7bf8c92d7b38545ffc2aba79ed.tar.bz2
mpv-fe993a67123f3e7bf8c92d7b38545ffc2aba79ed.tar.xz
vo_opengl: w32: switch to new internal API
-rw-r--r--video/out/opengl/common.c3
-rw-r--r--video/out/opengl/common.h1
-rw-r--r--video/out/opengl/w32.c51
-rw-r--r--video/out/w32_common.c8
4 files changed, 36 insertions, 27 deletions
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index 765a499706..3973a533e9 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -502,6 +502,7 @@ extern const struct mpgl_driver mpgl_driver_x11;
extern const struct mpgl_driver mpgl_driver_x11egl;
extern const struct mpgl_driver mpgl_driver_cocoa;
extern const struct mpgl_driver mpgl_driver_wayland;
+extern const struct mpgl_driver mpgl_driver_w32;
static const struct backend backends[] = {
#if HAVE_RPI
@@ -511,7 +512,7 @@ static const struct backend backends[] = {
{.driver = &mpgl_driver_cocoa},
#endif
#if HAVE_GL_WIN32
- {"win", mpgl_set_backend_w32},
+ {.driver = &mpgl_driver_w32},
#endif
//Add the wayland backend before x11, in order to probe for a wayland-server before a x11-server and avoid using xwayland
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index e746fe0d8d..5622702f16 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -151,7 +151,6 @@ 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_set_backend_w32(MPGLContext *ctx);
void mpgl_set_backend_rpi(MPGLContext *ctx);
void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
diff --git a/video/out/opengl/w32.c b/video/out/opengl/w32.c
index 00616742c2..29a7c75d32 100644
--- a/video/out/opengl/w32.c
+++ b/video/out/opengl/w32.c
@@ -39,6 +39,8 @@ struct w32_context {
HRESULT (WINAPI *dwmflush)(void);
};
+static void w32_uninit(MPGLContext *ctx);
+
static __thread struct w32_context *current_w32_context;
static int GLAPIENTRY w32_swap_interval(int interval)
@@ -227,20 +229,18 @@ static void create_ctx(void *ptr)
wglMakeCurrent(w32_ctx->hdc, NULL);
}
-static bool config_window_w32(struct MPGLContext *ctx, int flags)
+static int w32_init(struct MPGLContext *ctx, int flags)
{
- struct w32_context *w32_ctx = ctx->priv;
- if (!vo_w32_config(ctx->vo, flags))
- return false;
+ if (!vo_w32_init(ctx->vo))
+ goto fail;
- if (w32_ctx->context) // reuse existing context
- return true;
+ struct w32_context *w32_ctx = ctx->priv;
w32_ctx->flags = flags;
vo_w32_run_on_thread(ctx->vo, create_ctx, ctx);
if (!w32_ctx->context)
- return false;
+ goto fail;
if (!ctx->gl->SwapInterval)
MP_VERBOSE(ctx->vo, "WGL_EXT_swap_control missing.");
@@ -250,7 +250,17 @@ static bool config_window_w32(struct MPGLContext *ctx, int flags)
current_w32_context = w32_ctx;
wglMakeCurrent(w32_ctx->hdc, w32_ctx->context);
- return true;
+ return 0;
+
+fail:
+ w32_uninit(ctx);
+ return -1;
+}
+
+static int w32_reconfig(struct MPGLContext *ctx, int flags)
+{
+ vo_w32_config(ctx->vo, flags);
+ return 0;
}
static void destroy_gl(void *ptr)
@@ -266,7 +276,7 @@ static void destroy_gl(void *ptr)
current_w32_context = NULL;
}
-static void releaseGlContext_w32(MPGLContext *ctx)
+static void w32_uninit(MPGLContext *ctx)
{
struct w32_context *w32_ctx = ctx->priv;
if (w32_ctx->context)
@@ -276,9 +286,10 @@ static void releaseGlContext_w32(MPGLContext *ctx)
if (w32_ctx->dwmapi_dll)
FreeLibrary(w32_ctx->dwmapi_dll);
w32_ctx->dwmapi_dll = NULL;
+ vo_w32_uninit(ctx->vo);
}
-static void swapGlBuffers_w32(MPGLContext *ctx)
+static void w32_swap_buffers(MPGLContext *ctx)
{
struct w32_context *w32_ctx = ctx->priv;
SwapBuffers(w32_ctx->hdc);
@@ -302,13 +313,17 @@ static void swapGlBuffers_w32(MPGLContext *ctx)
w32_ctx->current_swapinterval = new_swapinterval;
}
-void mpgl_set_backend_w32(MPGLContext *ctx)
+static int w32_control(MPGLContext *ctx, int *events, int request, void *arg)
{
- ctx->priv = talloc_zero(ctx, struct w32_context);
- ctx->config_window = config_window_w32;
- ctx->releaseGlContext = releaseGlContext_w32;
- ctx->swapGlBuffers = swapGlBuffers_w32;
- ctx->vo_init = vo_w32_init;
- ctx->vo_uninit = vo_w32_uninit;
- ctx->vo_control = vo_w32_control;
+ return vo_w32_control(ctx->vo, events, request, arg);
}
+
+const struct mpgl_driver mpgl_driver_w32 = {
+ .name = "w32",
+ .priv_size = sizeof(struct w32_context),
+ .init = w32_init,
+ .reconfig = w32_reconfig,
+ .swap_buffers = w32_swap_buffers,
+ .control = w32_control,
+ .uninit = w32_uninit,
+};
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 905fb42141..4c7df7d6c2 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -1059,12 +1059,6 @@ static void gui_thread_reconfig(void *ptr)
struct vo *vo = w32->vo;
- // we already have a fully initialized window, so nothing needs to be done
- if (flags & VOFLAG_HIDDEN) {
- *res = 1;
- return;
- }
-
struct vo_win_geometry geo;
vo_calc_window_geometry(vo, &w32->screenrc, &geo);
vo_apply_window_geometry(vo, &geo);
@@ -1107,7 +1101,7 @@ static void gui_thread_reconfig(void *ptr)
*res = reinit_window_state(w32);
}
-// Resize the window. On the first non-VOFLAG_HIDDEN call, it's also made visible.
+// Resize the window. On the first call, it's also made visible.
int vo_w32_config(struct vo *vo, uint32_t flags)
{
struct vo_w32_state *w32 = vo->w32;