diff options
-rw-r--r-- | video/out/vo_x11.c | 3 | ||||
-rw-r--r-- | video/out/vo_xv.c | 12 | ||||
-rw-r--r-- | video/out/x11_common.c | 42 | ||||
-rw-r--r-- | video/out/x11_common.h | 4 |
4 files changed, 28 insertions, 33 deletions
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 232a3bf844..973c6e49a9 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -409,8 +409,7 @@ static bool resize(struct vo *vo) if (!p->swsContext) return false; - if (vo->x11->window) - vo_x11_clearwindow(vo, vo->x11->window); + vo_x11_clear_background(vo, &p->dst); vo->want_redraw = true; return true; diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index 8e2ab5bb68..8ae5a31a9a 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -384,8 +384,7 @@ static int xv_init_colorkey(struct vo *vo) * * Also draws the black bars ( when the video doesn't fit the display in * fullscreen ) separately, so they don't overlap with the video area. */ -static void xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y, - int32_t w, int32_t h) +static void xv_draw_colorkey(struct vo *vo, const struct mp_rect *rc) { struct xvctx *ctx = vo->priv; struct vo_x11_state *x11 = vo->x11; @@ -394,7 +393,8 @@ static void xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y, { //less tearing than XClearWindow() XSetForeground(x11->display, x11->vo_gc, ctx->xv_colorkey); - XFillRectangle(x11->display, x11->window, x11->vo_gc, x, y, w, h); + XFillRectangle(x11->display, x11->window, x11->vo_gc, rc->x0, rc->y0, + rc->x1 - rc->x0, rc->y1 - rc->y0); } } @@ -474,10 +474,8 @@ static void resize(struct vo *vo) vo_get_src_dst_rects(vo, &ctx->src_rect, &ctx->dst_rect, &unused); - struct mp_rect *dst = &ctx->dst_rect; - int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0; - vo_x11_clearwindow_part(vo, vo->x11->window, dw, dh); - xv_draw_colorkey(vo, dst->x0, dst->y0, dw, dh); + vo_x11_clear_background(vo, &ctx->dst_rect); + xv_draw_colorkey(vo, &ctx->dst_rect); read_xv_csp(vo); } diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 13da2706fb..c6741f2662 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1074,36 +1074,34 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, x11->pending_vo_events &= ~VO_EVENT_RESIZE; // implicitly done by the VO } -void vo_x11_clearwindow_part(struct vo *vo, Window vo_window, - int img_width, int img_height) +static void fill_rect(struct vo *vo, GC gc, int x0, int y0, int x1, int y1) { struct vo_x11_state *x11 = vo->x11; - Display *mDisplay = vo->x11->display; - int u_dheight, u_dwidth, left_ov, left_ov2; - if (x11->f_gc == None) - return; + x0 = FFMAX(x0, 0); + y0 = FFMAX(y0, 0); + x1 = FFMIN(x1, x11->win_width); + y1 = FFMIN(y1, x11->win_height); - u_dheight = x11->win_height; - u_dwidth = x11->win_width; - if ((u_dheight <= img_height) && (u_dwidth <= img_width)) - return; + if (x11->window && x1 > x0 && y1 > y0) + XFillRectangle(x11->display, x11->window, gc, x0, y0, x1 - x0, y1 - y0); +} - left_ov = (u_dheight - img_height) / 2; - left_ov2 = (u_dwidth - img_width) / 2; +// Clear everything outside of rc with the background color +void vo_x11_clear_background(struct vo *vo, const struct mp_rect *rc) +{ + struct vo_x11_state *x11 = vo->x11; + GC gc = x11->f_gc; - XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, 0, u_dwidth, left_ov); - XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, u_dheight - left_ov - 1, - u_dwidth, left_ov + 1); + int w = x11->win_width; + int h = x11->win_height; - if (u_dwidth > img_width) { - XFillRectangle(mDisplay, vo_window, x11->f_gc, 0, left_ov, left_ov2, - img_height); - XFillRectangle(mDisplay, vo_window, x11->f_gc, u_dwidth - left_ov2 - 1, - left_ov, left_ov2 + 1, img_height); - } + fill_rect(vo, gc, 0, 0, w, rc->y0); // top + fill_rect(vo, gc, 0, rc->y1, w, h); // bottom + fill_rect(vo, gc, 0, rc->y0, rc->x0, rc->y1); // left + fill_rect(vo, gc, rc->x1, rc->y0, w, rc->y1); // right - XFlush(mDisplay); + XFlush(x11->display); } void vo_x11_clearwindow(struct vo *vo, Window vo_window) diff --git a/video/out/x11_common.h b/video/out/x11_common.h index c54404fb7f..2ac3da2864 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -27,6 +27,7 @@ #include "config.h" struct vo; +struct mp_rect; struct vo_x11_state { Display *display; @@ -136,8 +137,7 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, unsigned int width, unsigned int height, int flags, const char *classname); -void vo_x11_clearwindow_part(struct vo *vo, Window vo_window, - int img_width, int img_height); +void vo_x11_clear_background(struct vo *vo, const struct mp_rect *rc); void vo_x11_clearwindow(struct vo *vo, Window vo_window); void vo_x11_ontop(struct vo *vo); void vo_x11_border(struct vo *vo); |