mirror of
https://github.com/mpv-player/mpv
synced 2025-03-01 20:00:37 +00:00
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.
This commit is contained in:
parent
b57debe5b3
commit
315e2e3da8
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user