From ec6e8a31e092a1d5e162eaa81c538a81fb5c449a Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 29 Mar 2016 22:26:24 +0200 Subject: 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) --- video/out/opengl/video.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'video/out/opengl/video.c') 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); } -- cgit v1.2.3