From d8673e73b3a63bfca56748e02e5a889328c3e702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20Ni=C3=9Fl?= Date: Thu, 26 Jul 2007 21:39:14 +0200 Subject: clip overlay against sub image when calling XvMCCompositeSubpicture() Blending functions like _x_blend_xx44() take care to clip the overlay against the destination bitmap. The same clipping must be applied to determine the relevant area in the destination bitmap for the call to XvMCCompositeSubpicture(). --- src/video_out/video_out_xxmc.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index 1c71bb534..4b926a2f1 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -1500,6 +1500,7 @@ static void xxmc_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, } else if (frame->format == XINE_IMGFMT_XXMC) { if (this->ovl_changed && this->hwSubpictures) { if (this->new_subpic) { + int x0, y0, x1, y1, w, h; LOCK_AND_SURFACE_VALID( this, frame->xvmc_surf ); if (this->first_overlay) { memset(this->subImage->data,0,this->subImage->width* @@ -1510,13 +1511,29 @@ static void xxmc_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, this->subImage->height, this->subImage->width, &this->alphablend_extra_data, &this->palette, (this->subImage->id == FOURCC_IA44)); - XVMCLOCKDISPLAY( this->display ); - XvMCCompositeSubpicture( this->display, this->new_subpic, - this->subImage, - overlay->x, overlay->y,overlay->width, - overlay->height, - overlay->x, overlay->y); - XVMCUNLOCKDISPLAY( this->display ); + + /* clip overlay against sub image like in _x_blend_xx44() */ + x0 = overlay->x; + y0 = overlay->y; + x1 = x0 + overlay->width; + y1 = y0 + overlay->height; + w = this->subImage->width; + h = this->subImage->height; + + x0 = (x0 < 0) ? 0 : ((x0 > w) ? w : x0); + y0 = (y0 < 0) ? 0 : ((y0 > h) ? h : y0); + x1 = (x1 < 0) ? 0 : ((x1 > w) ? w : x1); + y1 = (y1 < 0) ? 0 : ((y1 > h) ? h : y1); + + /* anything left after clipping? */ + if (x0 != x1 && y0 != y1) { + XVMCLOCKDISPLAY( this->display ); + XvMCCompositeSubpicture( this->display, this->new_subpic, + this->subImage, + x0, y0, x1 - x0, y1 - y0, + x0, y0); + XVMCUNLOCKDISPLAY( this->display ); + } xvmc_context_reader_unlock( &this->xvmc_lock ); } } -- cgit v1.2.3