1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00

vo_opengl: always premultiply alpha

Until now, we've let the windowing backend decide. But since they
usually require premultiplied alpha, and premultiplied alpha is easier
to handle, hardcode it.
This commit is contained in:
wm4 2016-03-29 21:56:38 +02:00
parent b95a10c2dd
commit dae23fff09
4 changed files with 1 additions and 5 deletions

View File

@ -89,7 +89,6 @@ 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);

View File

@ -124,7 +124,6 @@ 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);

View File

@ -274,7 +274,6 @@ static int glx_init(struct MPGLContext *ctx, int flags)
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_RED_SIZE, &ctx->gl->fb_r);
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->gl->fb_g);
glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->gl->fb_b);
ctx->gl->fb_premultiplied = true;
return 0;

View File

@ -1736,8 +1736,7 @@ static void pass_convert_yuv(struct gl_video *p)
GLSL(color.rgb = color.rgb * color.a + background * (1.0 - color.a);)
} else { // alpha present in image
p->components = 4;
if (p->gl->fb_premultiplied)
GLSL(color = vec4(color.rgb * color.a, color.a);)
GLSL(color = vec4(color.rgb * color.a, color.a);)
}
}