summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-10-01 22:25:12 +0200
committerwm4 <wm4@nowhere>2015-10-01 22:42:25 +0200
commitf4d62da8f028bb2359a9a4c6792690cfa5bc8930 (patch)
tree458a2be844057c4d87055089d36a640b28cfa595 /video
parentae7212963ee55c11cf025beccf86c55c1d898128 (diff)
downloadmpv-f4d62da8f028bb2359a9a4c6792690cfa5bc8930.tar.bz2
mpv-f4d62da8f028bb2359a9a4c6792690cfa5bc8930.tar.xz
vo_opengl: cocoa: switch to new internal API
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa_common.h4
-rw-r--r--video/out/cocoa_common.m7
-rw-r--r--video/out/opengl/cocoa.c51
-rw-r--r--video/out/opengl/common.c3
-rw-r--r--video/out/opengl/common.h1
-rw-r--r--video/out/vo_opengl.c2
6 files changed, 37 insertions, 31 deletions
diff --git a/video/out/cocoa_common.h b/video/out/cocoa_common.h
index 0427fc9de5..e7e1949541 100644
--- a/video/out/cocoa_common.h
+++ b/video/out/cocoa_common.h
@@ -27,10 +27,10 @@
struct vo;
struct vo_cocoa_state;
-int vo_cocoa_init(struct vo *vo);
+void vo_cocoa_init(struct vo *vo);
void vo_cocoa_uninit(struct vo *vo);
-int vo_cocoa_config_window(struct vo *vo, uint32_t flags);
+int vo_cocoa_config_window(struct vo *vo);
int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg);
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index f16f7aef0d..d4f70c9f90 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -248,7 +248,7 @@ static void cocoa_uninit_light_sensor(struct vo_cocoa_state *s)
}
}
-int vo_cocoa_init(struct vo *vo)
+void vo_cocoa_init(struct vo *vo)
{
struct vo_cocoa_state *s = talloc_zero(NULL, struct vo_cocoa_state);
*s = (struct vo_cocoa_state){
@@ -265,7 +265,6 @@ int vo_cocoa_init(struct vo *vo)
pthread_cond_init(&s->wakeup, NULL);
vo->cocoa = s;
cocoa_init_light_sensor(vo);
- return 1;
}
static int vo_cocoa_set_cursor_visibility(struct vo *vo, bool *visible)
@@ -554,7 +553,7 @@ void vo_cocoa_set_opengl_ctx(struct vo *vo, CGLContextObj ctx)
});
}
-int vo_cocoa_config_window(struct vo *vo, uint32_t flags)
+int vo_cocoa_config_window(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;
run_on_main_thread(vo, ^{
@@ -572,7 +571,7 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t flags)
s->old_dwidth = width;
s->old_dheight = height;
- if (!(flags & VOFLAG_HIDDEN) && !s->view) {
+ if (!s->view) {
create_ui(vo, &geo.win, geo.flags);
}
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);
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 7c287efc7c..2522c2e5c8 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -247,7 +247,7 @@ static bool get_and_update_icc_profile(struct gl_priv *p, int *events)
static void get_and_update_ambient_lighting(struct gl_priv *p, int *events)
{
int lux;
- int r = p->glctx->vo_control(p->vo, events, VOCTRL_GET_AMBIENT_LUX, &lux);
+ int r = mpgl_control(p->glctx, events, VOCTRL_GET_AMBIENT_LUX, &lux);
if (r == VO_TRUE) {
gl_video_set_ambient_lux(p->renderer, lux);
}