summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-19 19:01:33 +0200
committerwm4 <wm4@nowhere>2017-10-19 19:01:33 +0200
commitd3c022779a9d5848a20180c1fa5f184aa9703862 (patch)
treec6b5162cc73e8931e476be42d3d0c39b11d5c143
parentf37c9b36aaf959a92cb9819d9f50ba87dfae8005 (diff)
downloadmpv-d3c022779a9d5848a20180c1fa5f184aa9703862.tar.bz2
mpv-d3c022779a9d5848a20180c1fa5f184aa9703862.tar.xz
video: fix alpha handling
Regression since ec6e8a31e092a1d. Removal of the explicit else case always applies the conversion to premultiplied alpha in the else branch. We want to scale with multiplied alpha, but we don't want to multiply with alpha again on top of it. Fixes #4983, hopefully.
-rw-r--r--video/out/gpu/video.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 2ec5e91207..9191f062b6 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -2777,13 +2777,15 @@ static void pass_draw_to_screen(struct gl_video *p, struct ra_fbo fbo)
GLSLF("// transparency checkerboard\n");
GLSL(bvec2 tile = lessThan(fract(gl_FragCoord.xy * 1.0/32.0), vec2(0.5));)
GLSL(vec3 background = vec3(tile.x == tile.y ? 0.93 : 0.87);)
- GLSL(color.rgb = mix(background, color.rgb, color.a);)
+ GLSL(color.rgb += background.rgb * (1.0 - color.a);)
+ GLSL(color.a = 1.0;)
} else if (p->opts.alpha_mode == ALPHA_BLEND) {
// Blend into background color (usually black)
struct m_color c = p->opts.background;
GLSLF("vec4 background = vec4(%f, %f, %f, %f);\n",
c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0);
- GLSL(color = mix(background, vec4(color.rgb, 1.0), color.a);)
+ GLSL(color.rgb += background.rgb * (1.0 - color.a);)
+ GLSL(color.a = background.a;)
}
}