summaryrefslogtreecommitdiffstats
path: root/video/out/gl_osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-15 20:17:33 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-12 15:27:54 +0200
commit6a2a8880e92442a70696cac217773f1078023084 (patch)
treecc676649342352975782c4c19721b31fa902a68d /video/out/gl_osd.c
parentf6aedac7e9891fda2f434cf7fb4bd1a7f17b0440 (diff)
downloadmpv-6a2a8880e92442a70696cac217773f1078023084.tar.bz2
mpv-6a2a8880e92442a70696cac217773f1078023084.tar.xz
add a way to resize window contents without VO resize
gl_video_resize_redraw() simply resizes and redraws (but without invoking swapGlBuffers()). The VO is not involved in any way, so this can simply be called from inside the mpgl lock from any thread. Requires a minor refactor of the GL OSD code in order to redraw without an OSD object.
Diffstat (limited to 'video/out/gl_osd.c')
-rw-r--r--video/out/gl_osd.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/video/out/gl_osd.c b/video/out/gl_osd.c
index 81485cabe9..3317062311 100644
--- a/video/out/gl_osd.c
+++ b/video/out/gl_osd.c
@@ -202,8 +202,8 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
return true;
}
-struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx,
- struct sub_bitmaps *imgs)
+static struct mpgl_osd_part *osd_generate(struct mpgl_osd *ctx,
+ struct sub_bitmaps *imgs)
{
if (imgs->num_parts == 0 || !ctx->formats[imgs->format])
return NULL;
@@ -241,6 +241,54 @@ 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,
+ struct osd_state *osd,
+ 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(osd, res, osd->vo_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];
@@ -250,7 +298,7 @@ struct vertex {
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);
+ struct mpgl_osd_part *osd = osd_generate(ctx, imgs);
if (!osd)
return;