mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
vo_opengl: cocoa: implement alpha window support
With --vo=opengl:alpha=yes, the Cocoa backend will now render alpha video without background.
This commit is contained in:
parent
fc9eef3b81
commit
d2baaaa7df
@ -591,6 +591,12 @@ int vo_cocoa_config_window(struct vo *vo)
|
|||||||
cocoa_add_fs_screen_profile_observer(vo);
|
cocoa_add_fs_screen_profile_observer(vo);
|
||||||
cocoa_set_window_title(vo);
|
cocoa_set_window_title(vo);
|
||||||
vo_set_level(vo, vo->opts->ontop);
|
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;
|
s->vo_ready = true;
|
||||||
|
@ -99,7 +99,7 @@ error_out:
|
|||||||
return err;
|
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;
|
struct cgl_context *p = ctx->priv;
|
||||||
CGLError err;
|
CGLError err;
|
||||||
@ -124,6 +124,9 @@ static bool create_gl_context(struct MPGLContext *ctx)
|
|||||||
vo_cocoa_set_opengl_ctx(ctx->vo, p->ctx);
|
vo_cocoa_set_opengl_ctx(ctx->vo, p->ctx);
|
||||||
CGLSetCurrentContext(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);
|
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);
|
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);
|
vo_cocoa_init(ctx->vo);
|
||||||
|
|
||||||
if (!create_gl_context(ctx))
|
if (!create_gl_context(ctx, vo_flags))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ctx->gl->SwapInterval = set_swap_interval;
|
ctx->gl->SwapInterval = set_swap_interval;
|
||||||
|
Loading…
Reference in New Issue
Block a user