From 3d6d549dac2aa06ecd07bb04902f55140661ace3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 22 Dec 2012 17:50:15 +0100 Subject: vo_xv, vo_x11: simplify OSD redrawing In order to support OSD redrawing for vo_xv and vo_x11, draw_bmp.c included an awkward "backup" mechanism to copy and restore image regions that have been changed by OSD/subtitles. Replace this by a much simpler mechanism: keep a reference to the original image, and use that to restore the Xv/X framebuffers. In the worst case, this may increase cache pressure and memory usage, even if no OSD or subtitles are rendered. In practice, it seems to be always faster. --- video/out/vo_x11.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'video/out/vo_x11.c') diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 8b41a7afc3..c45dac5bdd 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -55,7 +55,7 @@ extern int sws_flags; struct priv { struct vo *vo; - struct mp_draw_sub_backup *osd_backup; + struct mp_image *original_image; /* local data */ unsigned char *ImageData; @@ -268,6 +268,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, Colormap theCmap; const struct fmt2Xfmtentry_s *fmte = fmt2Xfmt; + mp_image_unrefp(&p->original_image); + #ifdef CONFIG_XF86VM int vm = flags & VOFLAG_MODESWITCHING; #endif @@ -441,30 +443,21 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) .video_par = vo->aspdat.par, }; - osd_draw_on_image_bk(osd, res, osd->vo_pts, 0, p->osd_backup, &img); + osd_draw_on_image(osd, res, osd->vo_pts, 0, &img); } static mp_image_t *get_screenshot(struct vo *vo) { struct priv *p = vo->priv; - struct mp_image img = get_x_buffer(p); - struct mp_image *res = mp_image_new_copy(&img); - mp_draw_sub_backup_restore(p->osd_backup, res); + if (!p->original_image) + return NULL; + struct mp_image *res = mp_image_new_ref(p->original_image); + mp_image_set_display_size(res, vo->aspdat.prew, vo->aspdat.preh); return res; } -static int redraw_frame(struct vo *vo) -{ - struct priv *p = vo->priv; - - struct mp_image img = get_x_buffer(p); - mp_draw_sub_backup_restore(p->osd_backup, &img); - - return true; -} - static void flip_page(struct vo *vo) { struct priv *p = vo->priv; @@ -516,7 +509,19 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) } sws_scale(p->swsContext, (const uint8_t **)mpi->planes, mpi->stride, 0, mpi->h, dst, dstStride); - mp_draw_sub_backup_reset(p->osd_backup); + + mp_image_setrefp(&p->original_image, mpi); +} + +static int redraw_frame(struct vo *vo) +{ + struct priv *p = vo->priv; + + if (!p->original_image) + return false; + + draw_image(vo, p->original_image); + return true; } static int query_format(struct vo *vo, uint32_t format) @@ -551,6 +556,8 @@ static void uninit(struct vo *vo) if (p->myximage) freeMyXImage(p); + talloc_free(p->original_image); + #ifdef CONFIG_XF86VM vo_vm_close(vo); #endif @@ -571,8 +578,6 @@ static int preinit(struct vo *vo, const char *arg) return ENOSYS; } - p->osd_backup = talloc_steal(p, mp_draw_sub_backup_new()); - if (!vo_init(vo)) return -1; // Can't open X11 return 0; -- cgit v1.2.3