From ad8f17dec71632d0e606af1bea9432ece0bc97db Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 21 Jul 2008 15:23:50 -0700 Subject: Video Overlay: Handle clipping correctly with AutoPaint colorkey. We recently added XV_AUTOPAINT_COLORKEY attribute to the X video driver to enable applications like Real player that rely on this attribute to display video frames in Linux guest. When this attribute is SET, we paint the colorkey on 1st frame and from there on only when the video is moved. This introduced a bug 305202 with clipping. Consider a case when the video is playing, obscure the player window with another window, without moving the player window, move the other window away. The part of the window that was obscured didn't display the video. With this patch instead of relying on the target rectangle, we use the clipBoxes supplied in every frame. --- src/vmwarevideo.c | 54 ++++++++++-------------------------------------------- 1 file changed, 10 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/vmwarevideo.c b/src/vmwarevideo.c index b4b1183..59c25fe 100644 --- a/src/vmwarevideo.c +++ b/src/vmwarevideo.c @@ -165,7 +165,7 @@ struct VMWAREVideoRec { uint32 colorKey; Bool isAutoPaintColorkey; uint32 flags; - BoxRec position; + RegionRec clipBoxes; VMWAREVideoFmtData *fmt_priv; }; @@ -226,8 +226,6 @@ static void vmwareVideoFlush(VMWAREPtr pVMWARE, uint32 streamId); static void vmwareVideoSetOneReg(VMWAREPtr pVMWARE, uint32 streamId, uint32 regId, uint32 value); static void vmwareVideoEndStream(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid); -static Bool vmwareVideoMoved(VMWAREVideoPtr pVid, short drw_x, - short drw_y, short drw_w, short drw_h); /* * Offscreen memory manager functions @@ -660,10 +658,7 @@ static int vmwareVideoInitStream(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid, } pVid->currBuf = 0; - pVid->position.x1 = drw_x; - pVid->position.y1 = drw_y; - pVid->position.x2 = drw_w; - pVid->position.y2 = drw_h; + REGION_COPY(pScrn->pScreen, &pVid->clipBoxes, clipBoxes); if (pVid->isAutoPaintColorkey) { xf86XVFillKeyHelper(pScrn->pScreen, pVid->colorKey, clipBoxes); @@ -828,21 +823,18 @@ static int vmwareVideoPlay(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid, vmwareWriteWordToFIFO(pVMWARE, fifoItem[i]); } - if (pVid->isAutoPaintColorkey && - vmwareVideoMoved(pVid, drw_x, drw_y, drw_w, drw_h)) { - xf86XVFillKeyHelper(pScrn->pScreen, pVid->colorKey, clipBoxes); + /* + * Update the clipList and paint the colorkey, if required. + */ + if (!REGION_EQUAL(pScrn->pScreen, &pVid->clipBoxes, clipBoxes)) { + REGION_COPY(pScrn->pScreen, &pVid->clipBoxes, clipBoxes); + if (pVid->isAutoPaintColorkey) { + xf86XVFillKeyHelper(pScrn->pScreen, pVid->colorKey, clipBoxes); + } } vmwareVideoFlush(pVMWARE, pVid->streamId); - /* - * Update the position of the video frame. - */ - pVid->position.x1 = drw_x; - pVid->position.y1 = drw_y; - pVid->position.x2 = drw_w; - pVid->position.y2 = drw_h; - pVid->currBuf = ++pVid->currBuf & (VMWARE_VID_NUM_BUFFERS - 1); return Success; @@ -1002,32 +994,6 @@ static void vmwareVideoEndStream(ScrnInfoPtr pScrn, VMWAREVideoPtr pVid) } -/* - *----------------------------------------------------------------------------- - * - * vmwareVideoMoved -- - * - * Detects whether the video frame has changed its position. - * - * Results: - * TRUE if the position has changed, FALSE otherwise. - * - * Side effects: - * None. - * - *----------------------------------------------------------------------------- - */ - -static Bool vmwareVideoMoved(VMWAREVideoPtr pVid, short drw_x, - short drw_y, short drw_w, short drw_h) -{ - return !(pVid->position.x1 == drw_x && - pVid->position.y1 == drw_y && - pVid->position.x2 == drw_w && - pVid->position.y2 == drw_h); -} - - /* *----------------------------------------------------------------------------- * -- cgit v1.2.3