summaryrefslogtreecommitdiffstats
path: root/video/out/gl_osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-15 23:58:33 +0200
committerwm4 <wm4@nowhere>2014-06-16 01:00:59 +0200
commiteca0fcb77a95793b31b6447e0c91bf4d4045efeb (patch)
tree1f244579f55c72b403804ccb8c05d5a8081126d3 /video/out/gl_osd.c
parentc5e13cce52fbf4cd45ec0c6220fe2e5f056bb2cd (diff)
downloadmpv-eca0fcb77a95793b31b6447e0c91bf4d4045efeb.tar.bz2
mpv-eca0fcb77a95793b31b6447e0c91bf4d4045efeb.tar.xz
vo_opengl: simplify redraw callback OSD handling
OSD used to be not thread-safe at all, so a track was used to get it redrawn. This mostly reverts commit 6a2a8880, because OSD not being thread-safe was the non-trivial part of it. Mostly untested, because this code path is used on OSX only, and I don't have OSX.
Diffstat (limited to 'video/out/gl_osd.c')
-rw-r--r--video/out/gl_osd.c54
1 files changed, 3 insertions, 51 deletions
diff --git a/video/out/gl_osd.c b/video/out/gl_osd.c
index 2458a61cce..67944186a1 100644
--- a/video/out/gl_osd.c
+++ b/video/out/gl_osd.c
@@ -208,8 +208,8 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
return true;
}
-static struct mpgl_osd_part *osd_generate(struct mpgl_osd *ctx,
- struct sub_bitmaps *imgs)
+struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx,
+ struct sub_bitmaps *imgs)
{
if (imgs->num_parts == 0 || !ctx->formats[imgs->format])
return NULL;
@@ -253,54 +253,6 @@ void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p)
gl->BindTexture(GL_TEXTURE_2D, 0);
}
-static void reset(struct mpgl_osd *ctx)
-{
- for (int n = 0; n < MAX_OSD_PARTS; n++) {
- struct mpgl_osd_part *p = ctx->parts[n];
- p->active = false;
- }
-}
-
-struct draw_cb_closure {
- struct mpgl_osd *ctx;
- void (*cb)(void *ctx, struct mpgl_osd_part *part, struct sub_bitmaps *imgs);
- void *cb_ctx;
-};
-
-static void draw_cb(void *pctx, struct sub_bitmaps *imgs)
-{
- struct draw_cb_closure *c = pctx;
- struct mpgl_osd_part *part = osd_generate(c->ctx, imgs);
- if (!part)
- return;
- part->active = true;
- c->cb(c->cb_ctx, part, imgs);
-}
-
-void mpgl_osd_draw_cb(struct mpgl_osd *ctx,
- double pts,
- struct mp_osd_res res,
- void (*cb)(void *ctx, struct mpgl_osd_part *part,
- struct sub_bitmaps *imgs),
- void *cb_ctx)
-{
- struct draw_cb_closure c = {ctx, cb, cb_ctx};
- reset(ctx);
- osd_draw(ctx->osd, res, pts, 0, ctx->formats, draw_cb, &c);
-}
-
-void mpgl_osd_redraw_cb(struct mpgl_osd *ctx,
- void (*cb)(void *ctx, struct mpgl_osd_part *part,
- struct sub_bitmaps *imgs),
- void *cb_ctx)
-{
- for (int n = 0; n < MAX_OSD_PARTS; n++) {
- struct mpgl_osd_part *p = ctx->parts[n];
- if (p->active)
- cb(cb_ctx, p, NULL);
- }
-}
-
struct vertex {
float position[2];
uint8_t color[4];
@@ -310,7 +262,7 @@ struct vertex {
static void draw_legacy_cb(void *pctx, struct sub_bitmaps *imgs)
{
struct mpgl_osd *ctx = pctx;
- struct mpgl_osd_part *osd = osd_generate(ctx, imgs);
+ struct mpgl_osd_part *osd = mpgl_osd_generate(ctx, imgs);
if (!osd)
return;