summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-03 17:33:59 +0200
committerwm4 <wm4@nowhere>2016-07-03 17:33:59 +0200
commit315e2e3da8b5a0d5ff75e438c9c4bbbbc6d53b91 (patch)
treed33c8fa9d35e57f72fe90d926d39a9b003a0dcca /video
parentb57debe5b3c8c85f14c1d7f895e61d4f4f26dcc4 (diff)
downloadmpv-315e2e3da8b5a0d5ff75e438c9c4bbbbc6d53b91.tar.bz2
mpv-315e2e3da8b5a0d5ff75e438c9c4bbbbc6d53b91.tar.xz
vo_opengl: remove caching GL_MAX_TEXTURE_SIZE value
No real need to cache this, and we need fewer fields in the OSD part struct. Also add logging for when the OSD texture is reallocated.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/osd.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/video/out/opengl/osd.c b/video/out/opengl/osd.c
index fde7e868c4..5df5bb199a 100644
--- a/video/out/opengl/osd.c
+++ b/video/out/opengl/osd.c
@@ -62,7 +62,6 @@ struct mpgl_osd {
struct mp_log *log;
struct osd_state *osd;
GL *gl;
- GLint max_tex_wh;
bool use_pbo;
struct mpgl_osd_part *parts[MAX_OSD_PARTS];
const struct gl_format *fmt_table[SUBBITMAP_COUNT];
@@ -85,8 +84,6 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd
.scratch = talloc_zero_size(ctx, 1),
};
- gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &ctx->max_tex_wh);
-
ctx->fmt_table[SUBBITMAP_LIBASS] = gl_find_unorm_format(gl, 1, 1);
ctx->fmt_table[SUBBITMAP_RGBA] = gl_find_unorm_format(gl, 1, 4);
@@ -136,18 +133,13 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
struct sub_bitmaps *imgs)
{
GL *gl = ctx->gl;
+ bool ok = false;
assert(imgs->packed);
int req_w = next_pow2(imgs->packed_w);
int req_h = next_pow2(imgs->packed_h);
- if (req_w > ctx->max_tex_wh || req_h > ctx->max_tex_wh) {
- MP_ERR(ctx, "OSD bitmaps do not fit on a surface with the maximum "
- "supported size %dx%d.\n", ctx->max_tex_wh, ctx->max_tex_wh);
- return false;
- }
-
const struct gl_format *fmt = ctx->fmt_table[imgs->format];
assert(fmt);
@@ -161,6 +153,17 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
osd->w = FFMAX(32, req_w);
osd->h = FFMAX(32, req_h);
+ MP_VERBOSE(ctx, "Reallocating OSD texture to %dx%d.\n", osd->w, osd->h);
+
+ GLint max_wh;
+ gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_wh);
+
+ if (osd->w > max_wh || osd->h > max_wh) {
+ MP_ERR(ctx, "OSD bitmaps do not fit on a surface with the maximum "
+ "supported size %dx%d.\n", max_wh, max_wh);
+ goto done;
+ }
+
gl->TexImage2D(GL_TEXTURE_2D, 0, fmt->internal_format, osd->w, osd->h,
0, fmt->format, fmt->type, NULL);
@@ -174,10 +177,11 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
fmt->type, osd->w, osd->h, imgs->packed->planes[0],
imgs->packed->stride[0], 0, 0,
imgs->packed_w, imgs->packed_h);
+ ok = true;
+done:
gl->BindTexture(GL_TEXTURE_2D, 0);
-
- return true;
+ return ok;
}
static void gen_osd_cb(void *pctx, struct sub_bitmaps *imgs)