diff --git a/sub/sub.c b/sub/sub.c index b37ec07747..f175563974 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -37,6 +37,7 @@ #include "sub.h" #include "dec_sub.h" #include "img_convert.h" +#include "draw_bmp.h" #include "spudec.h" @@ -300,6 +301,30 @@ void draw_osd_with_eosd(struct vo *vo, struct osd_state *osd) } } +// Returns whether anything was drawn. +bool osd_draw_on_image(struct osd_state *osd, struct mp_image *dest, + struct mp_csp_details *dest_csp, + struct sub_render_params *sub_params) +{ + static const bool formats[SUBBITMAP_COUNT] = { + [SUBBITMAP_LIBASS] = true, + [SUBBITMAP_RGBA] = true, + }; + bool changed = false; + osd_update_ext(osd, sub_params->dim); + for (int n = 0; n < MAX_OSD_PARTS; n++) { + struct osd_object *obj = osd->objs[n]; + if (obj->is_sub && osd->render_subs_in_filter) + continue; + struct sub_bitmaps imgs; + if (render_object(osd, obj, &imgs, sub_params, formats)) { + mp_draw_sub_bitmaps(dest, &imgs, dest_csp); + changed = true; + } + } + return changed; +} + void osd_draw_text_ext(struct osd_state *osd, int w, int h, int ml, int mt, int mr, int mb, int unused0, int unused1, void (*draw_alpha)(void *ctx, int x0, int y0, int w, diff --git a/sub/sub.h b/sub/sub.h index 649f196414..cc59077011 100644 --- a/sub/sub.h +++ b/sub/sub.h @@ -238,6 +238,12 @@ bool osd_draw_sub(struct osd_state *osd, struct sub_bitmaps *out_imgs, struct sub_render_params *sub_params, const bool formats[SUBBITMAP_COUNT]); +struct mp_image; +struct mp_csp_details; +bool osd_draw_on_image(struct osd_state *osd, struct mp_image *dest, + struct mp_csp_details *dest_csp, + struct sub_render_params *sub_params); + bool sub_bitmaps_bb(struct sub_bitmaps *imgs, int *x1, int *y1, int *x2, int *y2);