1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-20 14:56:55 +00:00

vo_opengl_old: fix OSD regression

Commit 0e8fbdbd removed the rg_texture requirement from vo_opengl;
commit 541f6731 changed to a more convenient method. Both commits broke
vo_opengl_old in some ways. vo_opengl_old always requires GL_ALPHA for
single-channel texture, because it draws the OSD without shaders and by
using certain blend modes.

So we need to explicitly distinguish between vo_opengl and vo_opengl_old
in the OSD renderer, and force fixed texture formats for vo_opengl_old.
The other logic is specific to the internals of vo_opengl. (Although it
might be possible to get the same result by playing with the old GL
fixed-function functions in vo_opengl_old. But seems like a waste of
time.)

Fixes #1370.

Conflicts:
	video/out/gl_osd.c
This commit is contained in:
wm4 2014-12-20 18:43:11 +01:00 committed by Diogo Franco (Kovensky)
parent 21c4c50ac6
commit a9db58cc3b
4 changed files with 18 additions and 8 deletions

View File

@ -42,12 +42,18 @@ static const struct osd_fmt_entry osd_to_gl3_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
};
static const struct osd_fmt_entry osd_to_gl_legacy_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_LIBASS] = {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
[SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
static const struct osd_fmt_entry osd_to_gl2_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_LIBASS] = {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE},
[SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
};
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd)
static const struct osd_fmt_entry osd_to_gl_legacy_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_LIBASS] = {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE},
[SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
};
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd,
bool legacy)
{
GLint max_texture_size;
gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
@ -61,8 +67,11 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd
.scratch = talloc_zero_size(ctx, 1),
};
if (!(gl->mpgl_caps & MPGL_CAP_TEX_RG))
if (legacy) {
ctx->fmt_table = osd_to_gl_legacy_formats;
} else if (!(gl->mpgl_caps & MPGL_CAP_TEX_RG)) {
ctx->fmt_table = osd_to_gl2_formats;
}
for (int n = 0; n < MAX_OSD_PARTS; n++) {
struct mpgl_osd_part *p = talloc_ptrtype(ctx, p);

View File

@ -30,7 +30,8 @@ struct mpgl_osd {
void *scratch;
};
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd);
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd,
bool legacy);
void mpgl_osd_destroy(struct mpgl_osd *ctx);
struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx,

View File

@ -1288,7 +1288,7 @@ static void recreate_osd(struct gl_video *p)
{
if (p->osd)
mpgl_osd_destroy(p->osd);
p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state);
p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state, false);
p->osd->use_pbo = p->opts.pbo;
}

View File

@ -1687,7 +1687,7 @@ static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height)
}
if (gl->BindTexture) {
p->osd = mpgl_osd_init(gl, vo->log, vo->osd);
p->osd = mpgl_osd_init(gl, vo->log, vo->osd, true);
p->osd->scaled = p->scaled_osd;
}