summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2016-03-29 22:26:24 +0200
committerwm4 <wm4@nowhere>2016-03-29 22:29:19 +0200
commitec6e8a31e092a1d5e162eaa81c538a81fb5c449a (patch)
tree24cc443dce5a48d644c4f0f03c34fde6b3091357
parentdae23fff09337992f9773557a3ba41ffb1311b32 (diff)
downloadmpv-ec6e8a31e092a1d5e162eaa81c538a81fb5c449a.tar.bz2
mpv-ec6e8a31e092a1d5e162eaa81c538a81fb5c449a.tar.xz
vo_opengl: draw transparency checkerboard after upscaling
This also draws it after color management etc. In a nutshell, this change makes the transparency checkerboard independent of upscaling, panning, cropping etc. It will always be the same apparent size and position (relative to the window). It will also be independent of the video colorspace and such things. (Note: This might cause white imbalance issues if playing a file with a white point that does not match the display, in absolute colorimetric mode. But that's uncommon, especially in conjunction with transparent image files, so it's not a primary concern here)
-rw-r--r--video/out/opengl/video.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 6b46c1fb42..e9bafc0d3f 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1730,10 +1730,6 @@ static void pass_convert_yuv(struct gl_video *p)
GLSL(color.a = 1.0;)
} else if (p->opts.alpha_mode == 2) { // blend against black
GLSL(color = vec4(color.rgb * color.a, 1.0);)
- } else if (p->opts.alpha_mode == 3) { // blend against tiles
- 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 = color.rgb * color.a + background * (1.0 - color.a);)
} else { // alpha present in image
p->components = 4;
GLSL(color = vec4(color.rgb * color.a, color.a);)
@@ -2171,8 +2167,18 @@ static void pass_draw_to_screen(struct gl_video *p, int fbo)
GLSL(color.rgb = clamp(color.rgb, 0.0, 1.0);)
GLSL(color.rgb = pow(color.rgb, vec3(user_gamma));)
}
+
pass_colormanage(p, p->image_params.primaries,
p->use_linear ? MP_CSP_TRC_LINEAR : p->image_params.gamma);
+
+ // Draw checkerboard pattern to indicate transparency
+ if (p->has_alpha && p->opts.alpha_mode == 3) {
+ 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);)
+ }
+
pass_dither(p);
finish_pass_direct(p, fbo, p->vp_w, p->vp_h, &p->dst_rect);
}