summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-21 22:23:41 +0100
committerwm4 <wm4@nowhere>2016-03-21 22:23:41 +0100
commitd6c99c8513a02c6dc7187d799c88327c858619c4 (patch)
treebe65c67446e62192ad8c6a21eef9846145d843df /video/out/opengl/osd.c
parent5f1ff78516bb5aaf6c38a5df55959e1165c059ee (diff)
downloadmpv-d6c99c8513a02c6dc7187d799c88327c858619c4.tar.bz2
mpv-d6c99c8513a02c6dc7187d799c88327c858619c4.tar.xz
vo_opengl, osd: allow osc.lua to react faster on resizes
Glitches when resizing are still possible, but are reduced. Other VOs could support this too, but don't need to do so. (Totally avoiding glitches would be much more effort, and probably not worth the trouble. How about you just watch the video the player is playing, instead of spending your time resizing the window.)
Diffstat (limited to 'video/out/opengl/osd.c')
-rw-r--r--video/out/opengl/osd.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/video/out/opengl/osd.c b/video/out/opengl/osd.c
index 215c83cbe7..c554425e0f 100644
--- a/video/out/opengl/osd.c
+++ b/video/out/opengl/osd.c
@@ -92,7 +92,7 @@ struct mpgl_osd {
int64_t change_counter;
// temporary
int stereo_mode;
- int display_size[2];
+ struct mp_osd_res osd_res;
void *scratch;
};
@@ -382,8 +382,8 @@ void mpgl_osd_draw_part(struct mpgl_osd *ctx, int vp_w, int vp_h, int index)
struct gl_transform t;
gl_transform_ortho(&t, 0, vp_w, 0, vp_h);
- float a_x = ctx->display_size[0] * x;
- float a_y = ctx->display_size[1] * y;
+ float a_x = ctx->osd_res.w * x;
+ float a_y = ctx->osd_res.h * y;
t.t[0] += a_x * t.m[0][0] + a_y * t.m[1][0];
t.t[1] += a_x * t.m[0][1] + a_y * t.m[1][1];
@@ -403,20 +403,25 @@ struct gl_vao *mpgl_osd_get_vao(struct mpgl_osd *ctx)
return &ctx->vao;
}
+static void set_res(struct mpgl_osd *ctx, struct mp_osd_res res, int stereo_mode)
+{
+ int div[2];
+ get_3d_side_by_side(stereo_mode, div);
+
+ res.w /= div[0];
+ res.h /= div[1];
+ ctx->osd_res = res;
+}
+
void mpgl_osd_generate(struct mpgl_osd *ctx, struct mp_osd_res res, double pts,
int stereo_mode, int draw_flags)
{
for (int n = 0; n < MAX_OSD_PARTS; n++)
ctx->parts[n]->num_subparts = 0;
- int div[2];
- get_3d_side_by_side(stereo_mode, div);
-
- struct mp_osd_res s_res = res;
- ctx->display_size[0] = s_res.w = s_res.w / div[0];
- ctx->display_size[1] = s_res.h = s_res.h / div[1];
+ set_res(ctx, res, stereo_mode);
- osd_draw(ctx->osd, s_res, pts, draw_flags, ctx->formats, gen_osd_cb, ctx);
+ osd_draw(ctx->osd, ctx->osd_res, pts, draw_flags, ctx->formats, gen_osd_cb, ctx);
ctx->stereo_mode = stereo_mode;
// Parts going away does not necessarily result in gen_osd_cb() being called
@@ -429,6 +434,13 @@ void mpgl_osd_generate(struct mpgl_osd *ctx, struct mp_osd_res res, double pts,
}
}
+// See osd_resize() for remarks. This function is an optional optimization too.
+void mpgl_osd_resize(struct mpgl_osd *ctx, struct mp_osd_res res, int stereo_mode)
+{
+ set_res(ctx, res, stereo_mode);
+ osd_resize(ctx->osd, ctx->osd_res);
+}
+
int64_t mpgl_get_change_counter(struct mpgl_osd *ctx)
{
return ctx->change_counter;