summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-20 18:43:11 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:14 +0900
commita9db58cc3b39d78aa667c4d993f0f6dba71d809e (patch)
treea04af41d99c206680f54ddc32549198abaf49aaa
parent21c4c50ac6f0e63bf793a99055533a063bbf4858 (diff)
downloadmpv-a9db58cc3b39d78aa667c4d993f0f6dba71d809e.tar.bz2
mpv-a9db58cc3b39d78aa667c4d993f0f6dba71d809e.tar.xz
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
-rw-r--r--video/out/gl_osd.c17
-rw-r--r--video/out/gl_osd.h3
-rw-r--r--video/out/gl_video.c2
-rw-r--r--video/out/vo_opengl_old.c2
4 files changed, 17 insertions, 7 deletions
diff --git a/video/out/gl_osd.c b/video/out/gl_osd.c
index 6b97ef77cf..a25216cb29 100644
--- a/video/out/gl_osd.c
+++ b/video/out/gl_osd.c
@@ -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_gl2_formats[SUBBITMAP_COUNT] = {
+ [SUBBITMAP_LIBASS] = {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE},
+ [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},
+ [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)
+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);
diff --git a/video/out/gl_osd.h b/video/out/gl_osd.h
index c91cc1e53f..f05385b547 100644
--- a/video/out/gl_osd.h
+++ b/video/out/gl_osd.h
@@ -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,
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index f4cdff3c5c..e9d91e3f17 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -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;
}
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
index 91a14398d5..78284718aa 100644
--- a/video/out/vo_opengl_old.c
+++ b/video/out/vo_opengl_old.c
@@ -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;
}