diff options
author | Martin Herkt <lachs0r@srsfckn.biz> | 2017-02-12 01:01:56 +0100 |
---|---|---|
committer | Martin Herkt <lachs0r@srsfckn.biz> | 2017-02-12 01:01:56 +0100 |
commit | 35aa705c3ece8293652ffcf449c71fe80b96e722 (patch) | |
tree | 7c0fb34ec96204cbcd867a973b2476689919a5b4 /sub/osd_libass.c | |
parent | 10a005df0c981050afc35184a42173bea7ea2527 (diff) | |
parent | 3739d1318fdb658bb6037bfe06bb6cefb3b50a09 (diff) | |
download | mpv-35aa705c3ece8293652ffcf449c71fe80b96e722.tar.bz2 mpv-35aa705c3ece8293652ffcf449c71fe80b96e722.tar.xz |
Merge branch 'master' into release/current
Diffstat (limited to 'sub/osd_libass.c')
-rw-r--r-- | sub/osd_libass.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 454d0387a4..44fcf6d269 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -219,13 +219,10 @@ static ASS_Event *add_osd_ass_event_escaped(ASS_Track *track, const char *style, return e; } -static void update_osd_text(struct osd_state *osd, struct osd_object *obj) +static ASS_Style *prepare_osd_ass(struct osd_state *osd, struct osd_object *obj) { struct MPOpts *opts = osd->opts; - if (!obj->text[0]) - return; - create_ass_track(osd, obj, &obj->ass, 0, 0); struct osd_style_opts font = *opts->osd_style; @@ -236,10 +233,31 @@ static void update_osd_text(struct osd_state *osd, struct osd_object *obj) if (!opts->osd_scale_by_window) playresy *= 720.0 / obj->vo_res.h; - mp_ass_set_style(get_style(&obj->ass, "OSD"), playresy, &font); + ASS_Style *style = get_style(&obj->ass, "OSD"); + mp_ass_set_style(style, playresy, &font); + return style; +} + +static void update_osd_text(struct osd_state *osd, struct osd_object *obj) +{ + + if (!obj->text[0]) + return; + + prepare_osd_ass(osd, obj); add_osd_ass_event_escaped(obj->ass.track, "OSD", obj->text); } +void osd_get_text_size(struct osd_state *osd, int *out_screen_h, int *out_font_h) +{ + pthread_mutex_lock(&osd->lock); + struct osd_object *obj = osd->objs[OSDTYPE_OSD]; + ASS_Style *style = prepare_osd_ass(osd, obj); + *out_screen_h = obj->ass.track->PlayResY - style->MarginV; + *out_font_h = style->FontSize; + pthread_mutex_unlock(&osd->lock); +} + // align: -1 .. +1 // frame: size of the containing area // obj: size of the object that should be positioned inside the area |