diff options
Diffstat (limited to 'sub')
-rw-r--r-- | sub/sub.c | 21 | ||||
-rw-r--r-- | sub/sub.h | 5 |
2 files changed, 26 insertions, 0 deletions
@@ -39,6 +39,8 @@ #include "draw_bmp.h" #include "spudec.h" #include "subreader.h" +#include "video/mp_image.h" +#include "video/mp_image_pool.h" char * const sub_osd_names[]={ @@ -274,6 +276,7 @@ struct draw_on_image_closure { struct osd_state *osd; struct mp_image *dest; struct mp_draw_sub_backup *bk; + struct mp_image_pool *pool; bool changed; }; @@ -283,11 +286,17 @@ static void draw_on_image(void *ctx, struct sub_bitmaps *imgs) struct osd_state *osd = closure->osd; if (closure->bk) mp_draw_sub_backup_add(closure->bk, closure->dest, imgs); + if (closure->pool) { + mp_image_pool_make_writeable(closure->pool, closure->dest); + } else { + mp_image_make_writeable(closure->dest); + } mp_draw_sub_bitmaps(&osd->draw_cache, closure->dest, imgs); talloc_steal(osd, osd->draw_cache); closure->changed = true; } +// Calls mp_image_make_writeable() on the dest image if something is drawn. // Returns whether anything was drawn. bool osd_draw_on_image(struct osd_state *osd, struct mp_osd_res res, double video_pts, int draw_flags, struct mp_image *dest) @@ -298,6 +307,18 @@ bool osd_draw_on_image(struct osd_state *osd, struct mp_osd_res res, return closure.changed; } +// Like osd_draw_on_image(), but if dest needs to be copied to make it +// writeable, allocate images from the given pool. (This is a minor +// optimization to reduce "real" image sized memory allocations.) +void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res, + double video_pts, int draw_flags, + struct mp_image_pool *pool, struct mp_image *dest) +{ + struct draw_on_image_closure closure = {osd, dest, .pool = pool}; + osd_draw(osd, res, video_pts, draw_flags, mp_draw_sub_formats, + &draw_on_image, &closure); +} + void osd_draw_on_image_bk(struct osd_state *osd, struct mp_osd_res res, double video_pts, int draw_flags, struct mp_draw_sub_backup *bk, struct mp_image *dest) @@ -222,6 +222,11 @@ struct mp_image; bool osd_draw_on_image(struct osd_state *osd, struct mp_osd_res res, double video_pts, int draw_flags, struct mp_image *dest); +struct mp_image_pool; +void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res, + double video_pts, int draw_flags, + struct mp_image_pool *pool, struct mp_image *dest); + struct mp_draw_sub_backup; void osd_draw_on_image_bk(struct osd_state *osd, struct mp_osd_res res, double video_pts, int draw_flags, |