summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-19 13:12:51 +0100
committerwm4 <wm4@nowhere>2015-12-19 14:14:12 +0100
commita0519f1d188e3d3be8f0e78a71868d7cbf1cc11d (patch)
tree90d2527b5e7e68c0bf451234f78cbb942f039f9e /video
parent4cc1861378c3b1e989b5d92ea49e3d02f5e4a65a (diff)
downloadmpv-a0519f1d188e3d3be8f0e78a71868d7cbf1cc11d.tar.bz2
mpv-a0519f1d188e3d3be8f0e78a71868d7cbf1cc11d.tar.xz
vo_opengl: cocoa: output premultiplied alpha
Which is apparently what is expected here. (I'm pretty sure X11 compositors want stright alpha, so 2 code paths are needed.)
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/common.h1
-rw-r--r--video/out/opengl/context_cocoa.c1
-rw-r--r--video/out/opengl/video.c2
3 files changed, 4 insertions, 0 deletions
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index c2eb0e9c2e..b57c698d85 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -92,6 +92,7 @@ struct GL {
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
int fb_r, fb_g, fb_b; // frame buffer bit depth (0 if unknown)
+ bool fb_premultiplied; // assumption about FB alpha compositor usage
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
diff --git a/video/out/opengl/context_cocoa.c b/video/out/opengl/context_cocoa.c
index 1bcfa09755..f2329a29fd 100644
--- a/video/out/opengl/context_cocoa.c
+++ b/video/out/opengl/context_cocoa.c
@@ -129,6 +129,7 @@ static bool create_gl_context(struct MPGLContext *ctx, int vo_flags)
mpgl_load_functions(ctx->gl, (void *)cocoa_glgetaddr, NULL, ctx->vo->log);
ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = cgl_color_size(ctx);
+ ctx->gl->fb_premultiplied = true;
CGLReleasePixelFormat(p->pix);
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index a96a95b5c7..fb7f9ee882 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1527,6 +1527,8 @@ static void pass_convert_yuv(struct gl_video *p)
GLSL(color.a = 1.0;)
} else if (p->opts.alpha_mode == 2) { // blend
GLSL(color = vec4(color.rgb * color.a, 1.0);)
+ } else if (p->gl->fb_premultiplied) {
+ GLSL(color = vec4(color.rgb * color.a, color.a);)
}
}