summaryrefslogtreecommitdiffstats
path: root/video/out/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl')
-rw-r--r--video/out/opengl/cocoa.c51
-rw-r--r--video/out/opengl/common.c3
-rw-r--r--video/out/opengl/common.h1
3 files changed, 31 insertions, 24 deletions
diff --git a/video/out/opengl/cocoa.c b/video/out/opengl/cocoa.c
index b3ca2854f3..50b149b6bc 100644
--- a/video/out/opengl/cocoa.c
+++ b/video/out/opengl/cocoa.c
@@ -132,40 +132,47 @@ static bool create_gl_context(struct MPGLContext *ctx)
return true;
}
-static bool config_window_cocoa(struct MPGLContext *ctx, int flags)
+static void cocoa_uninit(MPGLContext *ctx)
{
struct cgl_context *p = ctx->priv;
+ CGLReleaseContext(p->ctx);
+ vo_cocoa_uninit(ctx->vo);
+}
- if (p->ctx == NULL)
- if (!create_gl_context(ctx))
- return false;
-
- if (!ctx->gl->SwapInterval)
- ctx->gl->SwapInterval = set_swap_interval;
+static int cocoa_init(MPGLContext *ctx, int vo_flags)
+{
+ vo_cocoa_init(ctx->vo);
- vo_cocoa_config_window(ctx->vo, flags);
+ if (!create_gl_context(ctx))
+ return -1;
- return true;
+ ctx->gl->SwapInterval = set_swap_interval;
+ return 0;
}
-static void releaseGlContext_cocoa(MPGLContext *ctx)
+static int cocoa_reconfig(struct MPGLContext *ctx, int flags)
{
- struct cgl_context *p = ctx->priv;
- CGLReleaseContext(p->ctx);
+ vo_cocoa_config_window(ctx->vo);
+ return 0;
}
-static void swapGlBuffers_cocoa(MPGLContext *ctx)
+static int cocoa_control(struct MPGLContext *ctx, int *events, int request,
+ void *arg)
{
- vo_cocoa_swap_buffers(ctx->vo);
+ return vo_cocoa_control(ctx->vo, events, request, arg);
}
-void mpgl_set_backend_cocoa(MPGLContext *ctx)
+static void cocoa_swap_buffers(struct MPGLContext *ctx)
{
- ctx->priv = talloc_zero(ctx, struct cgl_context);
- ctx->config_window = config_window_cocoa;
- ctx->releaseGlContext = releaseGlContext_cocoa;
- ctx->swapGlBuffers = swapGlBuffers_cocoa;
- ctx->vo_init = vo_cocoa_init;
- ctx->vo_uninit = vo_cocoa_uninit;
- ctx->vo_control = vo_cocoa_control;
+ vo_cocoa_swap_buffers(ctx->vo);
}
+
+const struct mpgl_driver mpgl_driver_cocoa = {
+ .name = "cocoa",
+ .priv_size = sizeof(struct cgl_context),
+ .init = cocoa_init,
+ .reconfig = cocoa_reconfig,
+ .swap_buffers = cocoa_swap_buffers,
+ .control = cocoa_control,
+ .uninit = cocoa_uninit,
+}; \ No newline at end of file
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index 879aa7d879..f5bb45d376 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -500,13 +500,14 @@ struct backend {
extern const struct mpgl_driver mpgl_driver_x11;
extern const struct mpgl_driver mpgl_driver_x11egl;
+extern const struct mpgl_driver mpgl_driver_cocoa;
static const struct backend backends[] = {
#if HAVE_RPI
{"rpi", mpgl_set_backend_rpi},
#endif
#if HAVE_GL_COCOA
- {"cocoa", mpgl_set_backend_cocoa},
+ {.driver = &mpgl_driver_cocoa},
#endif
#if HAVE_GL_WIN32
{"win", mpgl_set_backend_w32},
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index a7dfb65be1..05115c2048 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -154,7 +154,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_cocoa(MPGLContext *ctx);
void mpgl_set_backend_w32(MPGLContext *ctx);
void mpgl_set_backend_wayland(MPGLContext *ctx);
void mpgl_set_backend_rpi(MPGLContext *ctx);