[PATCH video-ati] video: Refill color key when there is expose

Pauli ext-pauli.nieminen at nokia.com
Tue Jan 18 08:15:38 PST 2011


From: Pauli Nieminen <ext-pauli.nieminen at nokia.com>

XResizeWindow causes background painting if bit gravity is forget. In
that case clipBoxes didn't change but color key would still have to be
filled.

xf86XVGetPortFillArea can be used to fill color key to areas that were
exposed since last PutImage or PutVideo.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---

This is example how drivers would have to be changed to use
xf86XVGetPortFillArea. I didn't actually test the patch as I don't have any hw
here.

 configure.ac       |    5 ++++
 src/radeon_video.c |   58 +++++++++++++++++++++++++++++++++++++--------------
 src/radeon_video.h |    3 ++
 3 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5dbf65a..8521b80 100644
--- a/configure.ac
+++ b/configure.ac
@@ -198,6 +198,11 @@ if test "x$have_exa_h" = xyes; then
         fi
 fi
 
+AC_CHECK_DECL(xf86XVGetPortFillArea,
+	      [AC_DEFINE(HAVE_XV_GET_PORT_FILL_AREA, 1, [Have xf86XVGetPortFillArea prototype])],
+	      [],
+	      [#include <xf86xv.h>])
+
 AC_CHECK_DECL(xf86XVFillKeyHelperDrawable,
 	      [AC_DEFINE(HAVE_XV_DRAWABLE_HELPER, 1, [Have xf86XVFillKeyHelperDrawable prototype])],
 	      [],
diff --git a/src/radeon_video.c b/src/radeon_video.c
index 0bb5ab3..4b5659c 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -1627,7 +1627,11 @@ RADEONSetupImageVideo(ScreenPtr pScreen)
     adapt->QueryImageAttributes = RADEONQueryImageAttributes;
 
     pPriv = (RADEONPortPrivPtr)(adapt->pPortPrivates[0].ptr);
+#ifdef HAVE_XV_GET_PORT_FILL_AREA
+    pPriv->colorKeyChanged = TRUE;
+#else
     REGION_NULL(pScreen, &(pPriv->clip));
+#endif
 
     pPriv->textured = FALSE;
 
@@ -1662,7 +1666,9 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
       return;
   }
 
+#ifndef HAVE_XV_GET_PORT_FILL_AREA
   REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
+#endif
 
   if(cleanup) {
      if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
@@ -1794,7 +1800,11 @@ RADEONSetPortAttribute(ScrnInfoPtr  pScrn,
     {
 	pPriv->colorKey = value;
 	RADEONSetColorKey (pScrn, pPriv->colorKey);
+#ifdef HAVE_XV_GET_PORT_FILL_AREA
+	pPriv->colorKeyChanged = TRUE;
+#else
 	REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
+#endif
     } 
     else if(attribute == xvCRTC) 
     {
@@ -2823,6 +2833,32 @@ RADEONFillKeyHelper(DrawablePtr pDraw, uint32_t colorKey, RegionPtr clipBoxes)
 #endif
 }
 
+static void RADEONFillKey(DrawablePtr pDraw, RADEONPortPrivPtr pPriv, RegionPtr clipBoxes)
+{
+#ifdef HAVE_XV_GET_PORT_FILL_AREA
+   RegionRec fillBoxes;
+
+    REGION_NULL(pDraw->pScreen, &fillBoxes);
+    if(xf86XVGetPortFillArea(pDraw, pPriv, clipBoxes, &fillBoxes) ||
+	    pPriv->colorKeyChanged) {
+	RegionPtr fill = !pPriv->colorKeyChanged ? &fillBoxes : clipBoxes;
+	pPriv->colorKeyChanged = FALSE;
+        /* draw these */
+        if(pPriv->autopaint_colorkey)
+	    RADEONFillKeyHelper(pDraw, pPriv->colorKey, fill);
+    }
+    REGION_UNINIT(pDraw->pScreen, &fillBoxes);
+#else
+    /* update cliplist */
+    if(!REGION_EQUAL(pDraw->pScreen, &pPriv->clip, clipBoxes)) {
+	REGION_COPY(pDraw->pScreen, &pPriv->clip, clipBoxes);
+        /* draw these */
+        if(pPriv->autopaint_colorkey)
+	    RADEONFillKeyHelper(pDraw, pPriv->colorKey, clipBoxes);
+    }
+#endif
+}
+
 
 static int
 RADEONPutImage(
@@ -3057,14 +3093,7 @@ RADEONPutImage(
     	break;
     }
 
-    /* update cliplist */
-    if(!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes))
-    {
-	REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes);
-	/* draw these */
-	if(pPriv->autopaint_colorkey)
-	    RADEONFillKeyHelper(pDraw, pPriv->colorKey, clipBoxes);
-    }
+    RADEONFillKey(pDraw, pPriv, clipBoxes);
 
     /* FIXME: someone should look at these offsets, I don't think it makes sense how
               they are handled throughout the source. */
@@ -3349,7 +3378,11 @@ RADEONDisplaySurface(
     pPriv->isOn = TRUE;
     /* we've prempted the XvImage stream so set its free timer */
     if (portPriv->videoStatus & CLIENT_VIDEO_ON) {
+#ifdef HAVE_XV_GET_PORT_FILL_AREA
+	portPriv->colorKeyChanged = TRUE;
+#else
 	REGION_EMPTY(pScrn->pScreen, &portPriv->clip);
+#endif
 	UpdateCurrentTime();
 	portPriv->videoStatus = FREE_TIMER;
 	portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
@@ -3620,14 +3653,7 @@ RADEONPutVideo(
       if(pPriv->i2c != NULL)RADEON_board_setmisc(pPriv);
    }
 
-   
-   /* update cliplist */
-   if(!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) {
-        REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
-        /* draw these */
-        if(pPriv->autopaint_colorkey)
-	    RADEONFillKeyHelper(pDraw, pPriv->colorKey, clipBoxes);
-   }
+   RADEONFillKey(pDraw, pPriv, clipBoxes);
 
    RADEONDisplayVideo(pScrn, crtc, pPriv, id, pPriv->video_offset,
 		      offset1+top*srcPitch, offset2+top*srcPitch,
diff --git a/src/radeon_video.h b/src/radeon_video.h
index ab0c433..d9e98e0 100644
--- a/src/radeon_video.h
+++ b/src/radeon_video.h
@@ -77,6 +77,9 @@ typedef struct {
 
    Bool          doubleBuffer;
    unsigned char currentBuffer;
+#ifdef HAVE_XV_GET_PORT_FILL_AREA
+   Bool          colorKeyChanged;
+#endif
    RegionRec     clip;
    uint32_t      colorKey;
    uint32_t      videoStatus;
-- 
1.7.0.4



More information about the xorg-devel mailing list