summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sequeira <phsequei@gmail.com>2016-11-12 13:19:40 -0500
committerwm4 <wm4@nowhere>2016-11-13 18:21:27 +0100
commitcf85191cb7322b9cfeda3a872ef22e6df4f97860 (patch)
tree205f8d10ce786e6f71cbf99e1e79950d9b62ac27
parent19c9347e47dcf7678b7256967b487fbea4366ca6 (diff)
downloadmpv-cf85191cb7322b9cfeda3a872ef22e6df4f97860.tar.bz2
mpv-cf85191cb7322b9cfeda3a872ef22e6df4f97860.tar.xz
vo_opengl: blend against background color for --alpha=blend
Do it after color management, etc. so that it matches the color drawn in the margins.
-rw-r--r--DOCS/man/options.rst3
-rw-r--r--video/out/opengl/video.c22
2 files changed, 16 insertions, 9 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 731da7836e..20744a0323 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4581,7 +4581,8 @@ The following video options are currently all specific to ``--vo=opengl`` and
blend-tiles
Blend the frame against a 16x16 gray/white tiles background (default).
blend
- Blend the frame against a black background.
+ Blend the frame against the background color (``--background``, normally
+ black).
yes
Try to create a framebuffer with alpha component. This only makes sense
if the video contains alpha information (which is extremely rare). May
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index a59a8e4ffa..498d89259e 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -2013,8 +2013,6 @@ static void pass_convert_yuv(struct gl_video *p)
p->components = 3;
if (!p->has_alpha || p->opts.alpha_mode == ALPHA_NO) {
GLSL(color.a = 1.0;)
- } else if (p->opts.alpha_mode == ALPHA_BLEND) {
- GLSL(color = vec4(color.rgb * color.a, 1.0);)
} else { // alpha present in image
p->components = 4;
GLSL(color = vec4(color.rgb * color.a, color.a);)
@@ -2537,12 +2535,20 @@ static void pass_draw_to_screen(struct gl_video *p, int fbo)
pass_colormanage(p, p->image_params.color, false);
- // Draw checkerboard pattern to indicate transparency
- if (p->has_alpha && p->opts.alpha_mode == ALPHA_BLEND_TILES) {
- GLSLF("// transparency checkerboard\n");
- GLSL(bvec2 tile = lessThan(fract(gl_FragCoord.xy / 32.0), vec2(0.5));)
- GLSL(vec3 background = vec3(tile.x == tile.y ? 1.0 : 0.75);)
- GLSL(color.rgb = mix(background, color.rgb, color.a);)
+ if (p->has_alpha){
+ if (p->opts.alpha_mode == ALPHA_BLEND_TILES) {
+ // Draw checkerboard pattern to indicate transparency
+ GLSLF("// transparency checkerboard\n");
+ GLSL(bvec2 tile = lessThan(fract(gl_FragCoord.xy / 32.0), vec2(0.5));)
+ GLSL(vec3 background = vec3(tile.x == tile.y ? 1.0 : 0.75);)
+ GLSL(color.rgb = mix(background, color.rgb, color.a);)
+ } 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);)
+ }
}
pass_opt_hook_point(p, "OUTPUT", NULL);