[xserver-commit] xserver/miext/damage damage.c,1.10,1.11

Keith Packard xserver-commit@pdx.freedesktop.org


Committed by: keithp

Update of /cvs/xserver/xserver/miext/damage
In directory pdx:/tmp/cvs-serv24610/miext/damage

Modified Files:
	damage.c 
Log Message:
2004-02-26  Keith Packard  <keithp@keithp.com>

	* miext/damage/damage.c: (damageDamageRegion):
	Fix offsets for pixmap damage so that damage to a backing pixmap
	gets reported with the right coordinates to a window damage monitor



Index: damage.c
===================================================================
RCS file: /cvs/xserver/xserver/miext/damage/damage.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- a/damage.c	2 Dec 2003 07:11:47 -0000	1.10
+++ b/damage.c	26 Feb 2004 19:26:32 -0000	1.11
@@ -108,11 +108,29 @@
     RegionRec	    tmpRegion;
     BoxRec	    tmpBox;
     int		    draw_x, draw_y;
+#ifdef COMPOSITE
+    int		    screen_x = 0, screen_y = 0;
+#endif
 
     /* short circuit for empty regions */
     if (!REGION_NOTEMPTY(pScreen, pRegion))
 	return;
     
+#ifdef COMPOSITE
+    /*
+     * When drawing to a pixmap which is storing window contents,
+     * the region presented is in pixmap relative coordinates which
+     * need to be converted to screen relative coordinates
+     */
+    if (pDrawable->type != DRAWABLE_WINDOW)
+    {
+	screen_x = ((PixmapPtr) pDrawable)->screen_x;
+	screen_y = ((PixmapPtr) pDrawable)->screen_y;
+    }
+    if (screen_x || screen_y)
+	REGION_TRANSLATE (pScreen, pRegion, screen_x, screen_y);
+#endif
+	
     REGION_INIT (pScreen, &clippedRec, NullBox, 0);
     for (; pDamage; pDamage = pNext)
     {
@@ -136,6 +154,20 @@
 	    continue;
 	}
 	
+	draw_x = pDamage->pDrawable->x;
+	draw_y = pDamage->pDrawable->y;
+#ifdef COMPOSITE
+	/*
+	 * Need to move everyone to screen coordinates
+	 * XXX what about off-screen pixmaps with non-zero x/y?
+	 */
+	if (pDamage->pDrawable->type != DRAWABLE_WINDOW)
+	{
+	    draw_x += ((PixmapPtr) pDamage->pDrawable)->screen_x;
+	    draw_y += ((PixmapPtr) pDamage->pDrawable)->screen_y;
+	}
+#endif
+	
 	/*
 	 * Clip against border or pixmap bounds
 	 */
@@ -149,10 +181,10 @@
 	    else
 	    {
 		BoxRec	box;
-		box.x1 = pDamage->pDrawable->x;
-		box.y1 = pDamage->pDrawable->y;
-		box.x2 = pDamage->pDrawable->x + pDamage->pDrawable->width;
-		box.y2 = pDamage->pDrawable->y + pDamage->pDrawable->height;
+		box.x1 = draw_x;
+		box.y1 = draw_y;
+		box.x2 = draw_x + pDamage->pDrawable->width;
+		box.y2 = draw_y + pDamage->pDrawable->height;
 		REGION_INIT(pScreen, &pixClip, &box, 1);
 		pClip = &pixClip;
 	    }
@@ -172,8 +204,6 @@
 	/*
 	 * Move region to target coordinate space
 	 */
-	draw_x = pDamage->pDrawable->x;
-	draw_y = pDamage->pDrawable->y;
 	if (draw_x || draw_y)
 	    REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y);
 	
@@ -216,6 +246,11 @@
 	if (pDamageRegion == pRegion && (draw_x || draw_y))
 	    REGION_TRANSLATE (pScreen, pDamageRegion, draw_x, draw_y);
     }
+#ifdef COMPOSITE
+    if (screen_x || screen_y)
+	REGION_TRANSLATE (pScreen, pRegion, -screen_x, -screen_y);
+#endif
+    
     REGION_UNINIT (pScreen, &clippedRec);
 }