diff options
Diffstat (limited to 'video/out/opengl/osd.c')
-rw-r--r-- | video/out/opengl/osd.c | 32 |
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; |