diff options
author | wm4 <wm4@nowhere> | 2015-12-19 09:30:20 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-12-19 10:24:03 +0100 |
commit | d2baaaa7df87eba9566fb935eeab5bd0af80fe1b (patch) | |
tree | 280326dfe7742c9623a3664e047baac118d1c273 /video | |
parent | fc9eef3b814ab0cb8134fdb8f249b48e490a9d4e (diff) | |
download | mpv-d2baaaa7df87eba9566fb935eeab5bd0af80fe1b.tar.bz2 mpv-d2baaaa7df87eba9566fb935eeab5bd0af80fe1b.tar.xz |
vo_opengl: cocoa: implement alpha window support
With --vo=opengl:alpha=yes, the Cocoa backend will now render alpha
video without background.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/cocoa_common.m | 6 | ||||
-rw-r--r-- | video/out/opengl/cocoa.c | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 2cb365cc1f..b88d42ae19 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -591,6 +591,12 @@ int vo_cocoa_config_window(struct vo *vo) cocoa_add_fs_screen_profile_observer(vo); cocoa_set_window_title(vo); vo_set_level(vo, vo->opts->ontop); + + GLint o; + if (!CGLGetParameter(s->cgl_ctx, kCGLCPSurfaceOpacity, &o) && !o) { + [s->window setOpaque:NO]; + [s->window setBackgroundColor:[NSColor clearColor]]; + } } s->vo_ready = true; diff --git a/video/out/opengl/cocoa.c b/video/out/opengl/cocoa.c index 7d367e99b4..5e98fce8a1 100644 --- a/video/out/opengl/cocoa.c +++ b/video/out/opengl/cocoa.c @@ -99,7 +99,7 @@ error_out: return err; } -static bool create_gl_context(struct MPGLContext *ctx) +static bool create_gl_context(struct MPGLContext *ctx, int vo_flags) { struct cgl_context *p = ctx->priv; CGLError err; @@ -124,6 +124,9 @@ static bool create_gl_context(struct MPGLContext *ctx) vo_cocoa_set_opengl_ctx(ctx->vo, p->ctx); CGLSetCurrentContext(p->ctx); + if (vo_flags & VOFLAG_ALPHA) + CGLSetParameter(p->ctx, kCGLCPSurfaceOpacity, &(GLint){0}); + ctx->depth_r = ctx->depth_g = ctx->depth_b = cgl_color_size(ctx); mpgl_load_functions(ctx->gl, (void *)cocoa_glgetaddr, NULL, ctx->vo->log); @@ -143,7 +146,7 @@ static int cocoa_init(MPGLContext *ctx, int vo_flags) { vo_cocoa_init(ctx->vo); - if (!create_gl_context(ctx)) + if (!create_gl_context(ctx, vo_flags)) return -1; ctx->gl->SwapInterval = set_swap_interval; |