diff options
author | wm4 <wm4@nowhere> | 2015-10-01 22:25:12 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-10-01 22:42:25 +0200 |
commit | f4d62da8f028bb2359a9a4c6792690cfa5bc8930 (patch) | |
tree | 458a2be844057c4d87055089d36a640b28cfa595 /video/out/opengl | |
parent | ae7212963ee55c11cf025beccf86c55c1d898128 (diff) | |
download | mpv-f4d62da8f028bb2359a9a4c6792690cfa5bc8930.tar.bz2 mpv-f4d62da8f028bb2359a9a4c6792690cfa5bc8930.tar.xz |
vo_opengl: cocoa: switch to new internal API
Diffstat (limited to 'video/out/opengl')
-rw-r--r-- | video/out/opengl/cocoa.c | 51 | ||||
-rw-r--r-- | video/out/opengl/common.c | 3 | ||||
-rw-r--r-- | video/out/opengl/common.h | 1 |
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); |