diff options
author | wm4 <wm4@nowhere> | 2020-05-09 17:54:33 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-09 18:02:57 +0200 |
commit | b3a9058c0db3a14aa0e5f50a34b93753f1eb9a49 (patch) | |
tree | 18613a2f38f344529dcf9321d5fb4031399c8f81 /sub | |
parent | b727600d1fc883cd24f2d54e9691bb0d3a895844 (diff) | |
download | mpv-b3a9058c0db3a14aa0e5f50a34b93753f1eb9a49.tar.bz2 mpv-b3a9058c0db3a14aa0e5f50a34b93753f1eb9a49.tar.xz |
osd: add change timestamp and screen size to struct sub_bitmap_list
Should be somewhat helpful. (All VOs are full of code trying to
compensate for this, more or less, and this will allow simplifying
some code later. Maybe.)
The screen size is mostly for robustness checks.
Diffstat (limited to 'sub')
-rw-r--r-- | sub/osd.c | 11 | ||||
-rw-r--r-- | sub/osd.h | 12 | ||||
-rw-r--r-- | sub/osd_state.h | 1 |
3 files changed, 23 insertions, 1 deletions
@@ -136,6 +136,7 @@ struct osd_state *osd_create(struct mpv_global *global) .type = n, .text = talloc_strdup(obj, ""), .progbar_state = {.type = -1}, + .vo_change_id = 1, }; osd->objs[n] = obj; } @@ -293,6 +294,11 @@ static struct sub_bitmaps *render_object(struct osd_state *osd, res = osd_object_get_bitmaps(osd, obj, format); } + if (obj->vo_had_output != !!res) { + obj->vo_had_output = !!res; + obj->vo_change_id += 1; + } + if (res) { obj->vo_change_id += res->change_id; @@ -314,6 +320,9 @@ struct sub_bitmap_list *osd_render(struct osd_state *osd, struct mp_osd_res res, pthread_mutex_lock(&osd->lock); struct sub_bitmap_list *list = talloc_zero(NULL, struct sub_bitmap_list); + list->change_id = 1; + list->w = res.w; + list->h = res.h; if (osd->force_video_pts != MP_NOPTS_VALUE) video_pts = osd->force_video_pts; @@ -352,6 +361,8 @@ struct sub_bitmap_list *osd_render(struct osd_state *osd, struct mp_osd_res res, } } + list->change_id += obj->vo_change_id; + talloc_free(imgs); } @@ -73,10 +73,20 @@ struct sub_bitmaps { // box. (The origin of the box is at (0,0).) int packed_w, packed_h; - int change_id; // Incremented on each change + int change_id; // Incremented on each change (0 is never used) }; struct sub_bitmap_list { + // Combined change_id - of any of the existing items change (even if they + // e.g. go away and are removed from items[]), this is incremented. + int64_t change_id; + + // Bounding box for rendering. It's notable that SUBBITMAP_LIBASS images are + // always within these bounds, while SUBBITMAP_RGBA is not necessarily. + int w, h; + + // Sorted by sub_bitmaps.render_index. Unused parts are not in the array, + // and you cannot index items[] with render_index. struct sub_bitmaps **items; int num_items; }; diff --git a/sub/osd_state.h b/sub/osd_state.h index 054a98775b..056e54b1a8 100644 --- a/sub/osd_state.h +++ b/sub/osd_state.h @@ -49,6 +49,7 @@ struct osd_object { // VO cache state int vo_change_id; struct mp_osd_res vo_res; + bool vo_had_output; // Internally used by osd_libass.c bool changed; |