summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-07 14:26:01 +0200
committerwm4 <wm4@nowhere>2015-09-07 14:26:01 +0200
commit7c73f70b8935801760ad465fcc0345c9d59842e6 (patch)
tree049f03a83306aac8a8eaf9ea16406fc75083739f
parent392ae68e5f802e940b7b7f5a139af7e2698b5e0e (diff)
downloadmpv-7c73f70b8935801760ad465fcc0345c9d59842e6.tar.bz2
mpv-7c73f70b8935801760ad465fcc0345c9d59842e6.tar.xz
osd: delay libass initialization as far as possible
Until now, most OSD objects created the associated ASS_Renderer instance as soon as possible, even if nothing was going to be rendered. Maybe this was even intentional. Change this for the sake of lowering resource usage, and strictly initialize ASS_Renderer only when it's really needed. For the OSC, initialization has to be forced, because of the insane mechanism for translating mouse coordinates to OSD coordinates.
-rw-r--r--player/lua.c2
-rw-r--r--sub/osd_libass.c14
2 files changed, 11 insertions, 5 deletions
diff --git a/player/lua.c b/player/lua.c
index cf0c5caa41..3bf5298578 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -967,6 +967,8 @@ static int script_set_osd_ass(lua_State *L)
int res_x = luaL_checkinteger(L, 1);
int res_y = luaL_checkinteger(L, 2);
const char *text = luaL_checkstring(L, 3);
+ if (!text[0])
+ text = " "; // force external OSD initialization
osd_set_external(mpctx->osd, res_x, res_y, (char *)text);
mp_input_wakeup(mpctx->input);
return 0;
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index 727faa39f1..bc4a24228a 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -201,11 +201,12 @@ static void update_osd(struct osd_state *osd, struct osd_object *obj)
{
struct MPOpts *opts = osd->opts;
- create_ass_track(osd, obj, 0, 0);
clear_obj(obj);
if (!obj->text[0])
return;
+ create_ass_track(osd, obj, 0, 0);
+
struct osd_style_opts font = *opts->osd_style;
font.font_size *= opts->osd_scale;
@@ -326,14 +327,14 @@ static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj,
static void update_progbar(struct osd_state *osd, struct osd_object *obj)
{
- float px, py, width, height, border;
- get_osd_bar_box(osd, obj, &px, &py, &width, &height, &border);
-
clear_obj(obj);
if (obj->progbar_state.type < 0)
return;
+ float px, py, width, height, border;
+ get_osd_bar_box(osd, obj, &px, &py, &width, &height, &border);
+
float sx = px - border * 2 - height / 4; // includes additional spacing
float sy = py + height / 2;
@@ -404,10 +405,13 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
static void update_external(struct osd_state *osd, struct osd_object *obj)
{
- create_ass_track(osd, obj, obj->external_res_x, obj->external_res_y);
clear_obj(obj);
bstr t = bstr0(obj->text);
+ if (!t.len)
+ return;
+ create_ass_track(osd, obj, obj->external_res_x, obj->external_res_y);
+
while (t.len) {
bstr line;
bstr_split_tok(t, "\n", &line, &t);