summaryrefslogtreecommitdiffstats
path: root/libvo/gl_osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-19 19:25:18 +0200
committerwm4 <wm4@nowhere>2012-10-24 21:56:34 +0200
commit4d11f32162b08e3b48ae382e2ed0a151035f8aea (patch)
treec588341bf672fd935de45a05bef99e0d8f20892f /libvo/gl_osd.c
parenta4f9077f6c1a897120616cc70c1ca37c6a247be2 (diff)
downloadmpv-4d11f32162b08e3b48ae382e2ed0a151035f8aea.tar.bz2
mpv-4d11f32162b08e3b48ae382e2ed0a151035f8aea.tar.xz
VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD, VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT. Remove draw_osd_with_eosd(), which rendered the OSD by calling VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes a callback as argument. (This basically works like the old OSD API, except multiple OSD bitmap formats are supported and caching is possible.) Remove all mentions of "eosd". It's simply "osd" now. Make OSD size per-OSD-object, as they can be different when using vf_sub. Include display_par/video_par in resolution change detection. Fix the issue with margin borders in vo_corevideo.
Diffstat (limited to 'libvo/gl_osd.c')
-rw-r--r--libvo/gl_osd.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/libvo/gl_osd.c b/libvo/gl_osd.c
index 5266dca4ac..81485cabe9 100644
--- a/libvo/gl_osd.c
+++ b/libvo/gl_osd.c
@@ -68,6 +68,9 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, bool legacy)
ctx->parts[n] = p;
}
+ for (int n = 0; n < SUBBITMAP_COUNT; n++)
+ ctx->formats[n] = ctx->fmt_table[n].type != 0;
+
return ctx;
}
@@ -84,11 +87,6 @@ void mpgl_osd_destroy(struct mpgl_osd *ctx)
talloc_free(ctx);
}
-bool mpgl_osd_query_format(struct mpgl_osd *ctx, int osd_format)
-{
- return ctx->fmt_table[osd_format].type != 0;
-}
-
static bool upload_pbo(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
struct sub_bitmaps *imgs)
{
@@ -159,9 +157,9 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
osd->packer->padding = ctx->scaled || imgs->scaled;
int r = packer_pack_from_subbitmaps(osd->packer, imgs);
if (r < 0) {
- mp_msg(MSGT_VO, MSGL_ERR, "[gl] EOSD bitmaps do not fit on "
- "a surface with the maximum supported size %dx%d.\n",
- osd->packer->w_max, osd->packer->h_max);
+ mp_msg(MSGT_VO, MSGL_ERR, "[gl] OSD bitmaps do not fit on "
+ "a surface with the maximum supported size %dx%d.\n",
+ osd->packer->w_max, osd->packer->h_max);
return false;
}
@@ -207,7 +205,7 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx,
struct sub_bitmaps *imgs)
{
- if (imgs->num_parts == 0 || !mpgl_osd_query_format(ctx, imgs->format))
+ if (imgs->num_parts == 0 || !ctx->formats[imgs->format])
return NULL;
struct mpgl_osd_part *osd = ctx->parts[imgs->render_index];
@@ -226,7 +224,7 @@ struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx,
return osd->packer->count ? osd : NULL;
}
-void mpgl_osd_gl_set_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p)
+void mpgl_osd_set_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p)
{
GL *gl = ctx->gl;
@@ -235,7 +233,7 @@ void mpgl_osd_gl_set_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p)
gl->BlendFunc(blend_factors[p->format][0], blend_factors[p->format][1]);
}
-void mpgl_osd_gl_unset_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p)
+void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p)
{
GL *gl = ctx->gl;
@@ -249,8 +247,9 @@ struct vertex {
float texcoord[2];
};
-void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct sub_bitmaps *imgs)
+static void draw_legacy_cb(void *pctx, struct sub_bitmaps *imgs)
{
+ struct mpgl_osd *ctx = pctx;
struct mpgl_osd_part *osd = mpgl_osd_generate(ctx, imgs);
if (!osd)
return;
@@ -309,11 +308,17 @@ void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct sub_bitmaps *imgs)
gl->EnableClientState(GL_TEXTURE_COORD_ARRAY);
gl->EnableClientState(GL_COLOR_ARRAY);
- mpgl_osd_gl_set_state(ctx, osd);
+ mpgl_osd_set_gl_state(ctx, osd);
gl->DrawArrays(GL_TRIANGLES, 0, osd->num_vertices);
- mpgl_osd_gl_unset_state(ctx, osd);
+ mpgl_osd_unset_gl_state(ctx, osd);
gl->DisableClientState(GL_VERTEX_ARRAY);
gl->DisableClientState(GL_TEXTURE_COORD_ARRAY);
gl->DisableClientState(GL_COLOR_ARRAY);
}
+
+void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct osd_state *osd,
+ struct mp_osd_res res)
+{
+ osd_draw(osd, res, osd->vo_pts, 0, ctx->formats, draw_legacy_cb, ctx);
+}