From 55e1f15cdb9d73af56715ffe030a626697c1b917 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 11 May 2020 19:51:32 +0200 Subject: 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. --- sub/osd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sub/osd.c') 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); -- cgit v1.2.3