summaryrefslogtreecommitdiffstats
path: root/sub/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-05-11 19:51:32 +0200
committerwm4 <wm4@nowhere>2020-05-11 19:57:34 +0200
commit55e1f15cdb9d73af56715ffe030a626697c1b917 (patch)
treeb5c8a68ccbcc6fb0b4f7555f10d31ce1236196d0 /sub/osd.c
parent6db890ebab2839443ddbfc34a4a0246d464bd14f (diff)
downloadmpv-55e1f15cdb9d73af56715ffe030a626697c1b917.tar.bz2
mpv-55e1f15cdb9d73af56715ffe030a626697c1b917.tar.xz
draw_bmp: add a function to return a single-texture OSD overlay
Maybe this is useful for some of the lesser VOs. It's preferable over bad ad-hoc solutions based on the more complex sub_bitmap data structures (as observed e.g. in vo_vaapi.c), and does not use that much more code since draw_bmp already created such an overlay internally. But I still wanted something that avoids having to upload/render a full screen-sized overlay if for example there's only a tiny subtitle line on the bottom of the screen. So the new API can return a list of modified pixels (for upload) and non-transparent pixels (for display). The way these pixel rectangles are computed is a bit dumb and returns dumb results, but it should be usable, and the implementation can change.
Diffstat (limited to 'sub/osd.c')
-rw-r--r--sub/osd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sub/osd.c b/sub/osd.c
index 52b69461ff..d6f284c398 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -425,9 +425,12 @@ void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res,
// Need to lock for the dumb osd->draw_cache thing.
pthread_mutex_lock(&osd->lock);
+ if (!osd->draw_cache)
+ osd->draw_cache = mp_draw_sub_alloc(osd);
+
stats_time_start(osd->stats, "draw-bmp");
- if (!mp_draw_sub_bitmaps(&osd->draw_cache, dest, list))
+ if (!mp_draw_sub_bitmaps(osd->draw_cache, dest, list))
MP_WARN(osd, "Failed rendering OSD.\n");
talloc_steal(osd, osd->draw_cache);