1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 00:02:13 +00:00

vo_x11, vo_xv: fix OSD redrawing with --force-window

The window wasn't cleared in this mode before doing the redrawing.
This commit is contained in:
wm4 2013-10-06 23:03:30 +02:00
parent 2d638347c1
commit 8304046180
2 changed files with 19 additions and 16 deletions

View File

@ -468,20 +468,26 @@ static void flip_page(struct vo *vo)
XSync(vo->x11->display, False);
}
// Note: redraw_frame() can call this with NULL.
static void draw_image(struct vo *vo, mp_image_t *mpi)
{
struct priv *p = vo->priv;
wait_for_completion(vo, p->num_buffers - 1);
struct mp_image src = *mpi;
struct mp_rect src_rc = p->src;
src_rc.x0 = MP_ALIGN_DOWN(src_rc.x0, src.fmt.align_x);
src_rc.y0 = MP_ALIGN_DOWN(src_rc.y0, src.fmt.align_y);
mp_image_crop_rc(&src, src_rc);
struct mp_image img = get_x_buffer(p, p->current_buf);
mp_sws_scale(p->sws, &img, &src);
if (mpi) {
struct mp_image src = *mpi;
struct mp_rect src_rc = p->src;
src_rc.x0 = MP_ALIGN_DOWN(src_rc.x0, src.fmt.align_x);
src_rc.y0 = MP_ALIGN_DOWN(src_rc.y0, src.fmt.align_y);
mp_image_crop_rc(&src, src_rc);
mp_sws_scale(p->sws, &img, &src);
} else {
mp_image_clear(&img, 0, 0, img.w, img.h);
}
mp_image_setrefp(&p->original_image, mpi);
}
@ -490,11 +496,6 @@ static int redraw_frame(struct vo *vo)
{
struct priv *p = vo->priv;
if (!p->original_image) {
vo_x11_clear_background(vo, &(struct mp_rect){0, 0, vo->dwidth, vo->dheight});
return false;
}
draw_image(vo, p->original_image);
return true;
}

View File

@ -653,6 +653,7 @@ static mp_image_t *get_screenshot(struct vo *vo)
return mp_image_new_ref(ctx->original_image);
}
// Note: redraw_frame() can call this with NULL.
static void draw_image(struct vo *vo, mp_image_t *mpi)
{
struct xvctx *ctx = vo->priv;
@ -660,7 +661,11 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
wait_for_completion(vo, ctx->num_buffers - 1);
struct mp_image xv_buffer = get_xv_buffer(vo, ctx->current_buf);
mp_image_copy(&xv_buffer, mpi);
if (mpi) {
mp_image_copy(&xv_buffer, mpi);
} else {
mp_image_clear(&xv_buffer, 0, 0, xv_buffer.w, xv_buffer.h);
}
mp_image_setrefp(&ctx->original_image, mpi);
}
@ -669,9 +674,6 @@ static int redraw_frame(struct vo *vo)
{
struct xvctx *ctx = vo->priv;
if (!ctx->original_image)
return false;
draw_image(vo, ctx->original_image);
return true;
}