xserver: Branch 'master' - 4 commits

Maarten Maathuis madman2003 at kemper.freedesktop.org
Fri Aug 29 15:44:26 PDT 2008


 composite/compalloc.c         |    2 
 composite/compwindow.c        |    4 
 damageext/damageext.c         |    4 
 exa/exa.c                     |   21 ----
 exa/exa_migration.c           |   39 --------
 exa/exa_priv.h                |    4 
 exa/exa_render.c              |   45 ++++------
 glx/glxdri.c                  |    4 
 hw/xfree86/modes/xf86Rotate.c |    2 
 miext/damage/damage.c         |  188 ++++++++++++++++++++++++++++++++----------
 miext/damage/damage.h         |   20 ++++
 miext/damage/damagestr.h      |    5 -
 12 files changed, 203 insertions(+), 135 deletions(-)

New commits:
commit 974db58f5b730c3770ee461665a02dd4334d1dea
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Sat Aug 30 00:37:11 2008 +0200

    damage: initial attempt at a damage marker mechanism
    - This should allow drivers to recieve post submission events for X<->opengl synchronisation.
    - Lacking a testcase, i'm open to suggestion how to do it better.
    - The idea is:
     - driver recieves event
     - driver creates personal identification and inserts marker into X fifo.
     - when something wants to use an X pixmap, it checks if something is pending.
     - If so, it synchronizes the 2nd fifo using the initial identification.
    - Driver is not required to use interrupt based systems (price too high).
    - Lower latency is ofcource better.
    - If this is somehow unusable for you, then come up with improvements.
    - For that reason i wouldn't consider the api fixed for the moment.

diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 60acdca..a90ee08 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -168,6 +168,48 @@ damageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
     }
 }
 
+static void
+damageReportDamagePostRendering (DamagePtr pDamage, RegionPtr pOldDamage, RegionPtr pDamageRegion)
+{
+    BoxRec tmpBox;
+    RegionRec tmpRegion, newDamage;
+    Bool was_empty;
+
+    REGION_UNION(pScreem, &newDamage, pOldDamage, pDamageRegion);
+
+    switch (pDamage->damageLevel) {
+    case DamageReportRawRegion:
+	(*pDamage->damageReportPostRendering) (pDamage, pDamageRegion, pDamage->closure);
+	break;
+    case DamageReportDeltaRegion:
+	REGION_NULL (pScreen, &tmpRegion);
+	REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, pOldDamage);
+	if (REGION_NOTEMPTY (pScreen, &tmpRegion)) {
+	    (*pDamage->damageReportPostRendering) (pDamage, &tmpRegion, pDamage->closure);
+	}
+	REGION_UNINIT(pScreen, &tmpRegion);
+	break;
+    case DamageReportBoundingBox:
+	tmpBox = *REGION_EXTENTS (pScreen, pOldDamage);
+	if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &newDamage))) {
+	    (*pDamage->damageReportPostRendering) (pDamage, &newDamage,
+				      pDamage->closure);
+	}
+	break;
+    case DamageReportNonEmpty:
+	was_empty = !REGION_NOTEMPTY(pScreen, pOldDamage);
+	if (was_empty && REGION_NOTEMPTY(pScreen, &newDamage)) {
+	    (*pDamage->damageReportPostRendering) (pDamage, &newDamage,
+				      pDamage->closure);
+	}
+	break;
+    case DamageReportNone:
+	break;
+    }
+
+    REGION_UNINIT(pScreen, &newDamage);
+}
+
 #if DAMAGE_DEBUG_ENABLE
 static void
 _damageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where)
@@ -306,15 +348,22 @@ damageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 	if (draw_x || draw_y)
 	    REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y);
 
-	/* If the damage rec has been flagged to report damage after the op has
-	 * completed, then union it into the delayed damage region, which will
-	 * be used for reporting after calling down, and skip the reporting 
-	 */
-	if (!pDamage->reportAfter) {
-	    damageReportDamage (pDamage, pDamageRegion);
-	} else {
+	/* Store damage region if needed after submission. */
+	if (pDamage->reportAfter || pDamage->damageMarker)
 	    REGION_UNION(pScreen, &pDamage->pendingDamage,
 			 &pDamage->pendingDamage, pDamageRegion);
+
+	/* Duplicate current damage if needed. */
+	if (pDamage->damageMarker)
+	    REGION_COPY(pScreen, &pDamage->backupDamage, &pDamage->damage);
+
+	/* Report damage now, if desired. */
+	if (!pDamage->reportAfter) {
+	    if (pDamage->damageReport)
+		damageReportDamage (pDamage, pDamageRegion);
+	    else
+		REGION_UNION(pScreen, &pDamage->damage,
+			 &pDamage->damage, pDamageRegion);
 	}
 
 	/*
@@ -338,10 +387,22 @@ damageRegionSubmitted (DrawablePtr pDrawable)
 
     for (; pDamage != NULL; pDamage = pDamage->pNext)
     {
+	/* submit damage marker whenever possible. */
+	if (pDamage->damageMarker)
+	    (*pDamage->damageMarker) (pDrawable, pDamage, &pDamage->backupDamage, &pDamage->pendingDamage, pDamage->closure);
 	if (pDamage->reportAfter) {
-	    damageReportDamage (pDamage, &pDamage->pendingDamage);
-	    REGION_EMPTY (pScreen, &pDamage->pendingDamage);
+	    /* It's possible that there is only interest in postRendering reporting. */
+	    if (pDamage->damageReport)
+		damageReportDamage (pDamage, &pDamage->pendingDamage);
+	    else
+		REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+			&pDamage->pendingDamage);
 	}
+
+	if (pDamage->reportAfter || pDamage->damageMarker)
+	    REGION_EMPTY (pScreen, &pDamage->pendingDamage);
+	if (pDamage->damageMarker)
+	    REGION_EMPTY (pScreen, &pDamage->backupDamage);
     }
     
 }
@@ -1810,7 +1871,9 @@ DamageCreate (DamageReportFunc  damageReport,
     pDamage->reportAfter = FALSE;
 
     pDamage->damageReport = damageReport;
+    pDamage->damageReportPostRendering = NULL;
     pDamage->damageDestroy = damageDestroy;
+    pDamage->damageMarker = NULL;
     return pDamage;
 }
 
@@ -1934,7 +1997,7 @@ DamageEmpty (DamagePtr	    pDamage)
     REGION_EMPTY (pDamage->pDrawable->pScreen, &pDamage->damage);
 }
 
-RegionPtr
+_X_EXPORT RegionPtr
 DamageRegion (DamagePtr		    pDamage)
 {
     return &pDamage->damage;
@@ -1958,6 +2021,16 @@ DamageRegionSubmitted (DrawablePtr pDrawable)
     damageRegionSubmitted (pDrawable);
 }
 
+/* If a damage marker is provided, then this function must be called after rendering is done. */
+/* Please do call back so any future enhancements can assume this function is called. */
+/* There are no strict timing requirements for calling this function, just as soon as (is cheaply) possible. */
+_X_EXPORT void
+DamageRegionRendered (DrawablePtr pDrawable, DamagePtr pDamage, RegionPtr pOldDamage, RegionPtr pRegion)
+{
+    if (pDamage->damageReportPostRendering)
+	damageReportDamagePostRendering (pDamage, pOldDamage, pRegion);
+}
+
 /* This call is very odd, i'm leaving it intact for API sake, but please don't use it. */
 _X_EXPORT void
 DamageDamageRegion (DrawablePtr	pDrawable,
@@ -1972,8 +2045,16 @@ DamageDamageRegion (DrawablePtr	pDrawable,
     damageRegionSubmitted (pDrawable);
 }
 
-void
+_X_EXPORT void
 DamageSetReportAfterOp (DamagePtr pDamage, Bool reportAfter)
 {
     pDamage->reportAfter = reportAfter;
 }
+
+_X_EXPORT void
+DamageSetPostRenderingFunctions(DamagePtr pDamage, DamageReportFunc damageReportPostRendering,
+				DamageMarkerFunc damageMarker)
+{
+    pDamage->damageReportPostRendering = damageReportPostRendering;
+    pDamage->damageMarker = damageMarker;
+}
diff --git a/miext/damage/damage.h b/miext/damage/damage.h
index ad9ab4c..c20a250 100755
--- a/miext/damage/damage.h
+++ b/miext/damage/damage.h
@@ -39,6 +39,9 @@ typedef enum _damageReportLevel {
 
 typedef void (*DamageReportFunc) (DamagePtr pDamage, RegionPtr pRegion, void *closure);
 typedef void (*DamageDestroyFunc) (DamagePtr pDamage, void *closure);
+/* It's the responsibility of the driver to duplicate both regions. */
+/* At some point DamageRegionRendered() must be called. */
+typedef void (*DamageMarkerFunc) (DrawablePtr pDrawable, DamagePtr pDamage, RegionPtr pOldDamage, RegionPtr pRegion, void *closure);
 
 Bool
 DamageSetup (ScreenPtr pScreen);
@@ -86,6 +89,10 @@ DamageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion);
 void
 DamageRegionSubmitted (DrawablePtr pDrawable);
 
+/* Call this some time after rendering is done, only relevant when a damageMarker is provided. */
+void
+DamageRegionRendered (DrawablePtr pDrawable, DamagePtr pDamage, RegionPtr pOldDamage, RegionPtr pRegion);
+
 /* Avoid using this call, it only exists for API compatibility. */
 void
 DamageDamageRegion (DrawablePtr	    pDrawable,
@@ -94,4 +101,8 @@ DamageDamageRegion (DrawablePtr	    pDrawable,
 void
 DamageSetReportAfterOp (DamagePtr pDamage, Bool reportAfter);
 
+void
+DamageSetPostRenderingFunctions(DamagePtr pDamage, DamageReportFunc damageReportPostRendering,
+				DamageMarkerFunc damageMarker);
+
 #endif /* _DAMAGE_H_ */
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index 2f6d538..f5e0ab9 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -46,10 +46,13 @@ typedef struct _damage {
     DrawablePtr		pDrawable;
     
     DamageReportFunc	damageReport;
+    DamageReportFunc	damageReportPostRendering;
     DamageDestroyFunc	damageDestroy;
+    DamageMarkerFunc	damageMarker;
 
     Bool		reportAfter;
-    RegionRec		pendingDamage;
+    RegionRec		pendingDamage; /* will be flushed post submission at the latest */
+    RegionRec		backupDamage; /* for use with damageMarker */
 } DamageRec;
 
 typedef struct _damageScrPriv {
commit 454cb0802eec3c2c2cdbcc17971bced868462b83
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Fri Aug 29 22:28:02 2008 +0200

    damage: DamageReportRawRegion should set pDamage->damage
    
    - I found no evidence in the protocol, that it should be differently from all the other modes.
    - It seems to have been like this from day 1.
    - If anyone has evidence to the contrary, please enlighten me.

diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 80fcddf..60acdca 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -129,6 +129,8 @@ damageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
 
     switch (pDamage->damageLevel) {
     case DamageReportRawRegion:
+	REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
+			 pDamageRegion);
 	(*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure);
 	break;
     case DamageReportDeltaRegion:
commit ae6ca434104405302f30a58bde8738d9579d9dc9
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Fri Aug 29 22:21:54 2008 +0200

    damage: internal functions start with a non-capital letter

diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index c5fdca7..80fcddf 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -121,7 +121,7 @@ getDrawableDamageRef (DrawablePtr pDrawable)
 	dixLookupPrivateAddr(&(pWindow)->devPrivates, damageWinPrivateKey)
 
 static void
-DamageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
+damageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
 {
     BoxRec tmpBox;
     RegionRec tmpRegion;
@@ -309,7 +309,7 @@ damageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 	 * be used for reporting after calling down, and skip the reporting 
 	 */
 	if (!pDamage->reportAfter) {
-	    DamageReportDamage (pDamage, pDamageRegion);
+	    damageReportDamage (pDamage, pDamageRegion);
 	} else {
 	    REGION_UNION(pScreen, &pDamage->pendingDamage,
 			 &pDamage->pendingDamage, pDamageRegion);
@@ -337,7 +337,7 @@ damageRegionSubmitted (DrawablePtr pDrawable)
     for (; pDamage != NULL; pDamage = pDamage->pNext)
     {
 	if (pDamage->reportAfter) {
-	    DamageReportDamage (pDamage, &pDamage->pendingDamage);
+	    damageReportDamage (pDamage, &pDamage->pendingDamage);
 	    REGION_EMPTY (pScreen, &pDamage->pendingDamage);
 	}
     }
commit 1861250cd7e84b05e8298b74e3c7e97da72ddfba
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Fri Aug 29 22:15:23 2008 +0200

    {damage,exa}: sanitise damage
    
    - Redo damage naming for more consistency.
    - Call post submission functions only where appropriate.
    - EXA can now live without it's odd damage workarounds.

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 19c7db0..a62647e 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -224,7 +224,7 @@ compFreeClientWindow (WindowPtr pWin, XID id)
 	DamageRegister (&pWin->drawable, cw->damage);
 	cw->damageRegistered = TRUE;
 	pWin->redirectDraw = RedirectDrawAutomatic;
-	DamageDamageRegion (&pWin->drawable, &pWin->borderSize);
+	DamageRegionPending(&pWin->drawable, &pWin->borderSize);
     }
     if (wasMapped && !pWin->mapped)
     {
diff --git a/composite/compwindow.c b/composite/compwindow.c
index c1657bd..d2931e7 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -585,7 +585,7 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 	REGION_TRANSLATE (prgnSrc, prgnSrc,
 			  pWin->drawable.x - ptOldOrg.x,
 			  pWin->drawable.y - ptOldOrg.y);
-	DamageDamageRegion (&pWin->drawable, prgnSrc);
+	DamageRegionPending(&pWin->drawable, prgnSrc);
     }
     cs->CopyWindow = pScreen->CopyWindow;
     pScreen->CopyWindow = compCopyWindow;
@@ -664,7 +664,7 @@ compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion)
     /*
      * Report that as damaged so it will be redrawn
      */
-    DamageDamageRegion (&pWin->drawable, &damage);
+    DamageRegionPending(&pWin->drawable, &damage);
     REGION_UNINIT (pScreen, &damage);
     /*
      * Save the new border clip region
diff --git a/damageext/damageext.c b/damageext/damageext.c
index 4d91580..fdf31f3 100755
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -233,7 +233,7 @@ ProcDamageCreate (ClientPtr client)
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
 	pRegion = &((WindowPtr) pDrawable)->borderClip;
-	DamageDamageRegion (pDrawable, pRegion);
+	DamageRegionPending(pDrawable, pRegion);
     }
 
     return (client->noClientException);
@@ -303,7 +303,7 @@ ProcDamageAdd (ClientPtr client)
      * screen coordinates like damage expects.
      */
     REGION_TRANSLATE(pScreen, pRegion, pDrawable->x, pDrawable->y);
-    DamageDamageRegion(pDrawable, pRegion);
+    DamageRegionPending(pDrawable, pRegion);
     REGION_TRANSLATE(pScreen, pRegion, -pDrawable->x, -pDrawable->y);
 
     return (client->noClientException);
diff --git a/exa/exa.c b/exa/exa.c
index 677e2d5..2ceee51 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -261,21 +261,6 @@ exaSetFbPitch(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap,
                                      pExaScr->info->pixmapPitchAlign);
 }
 
-
-static void
-ExaDamageReport(DamagePtr pDamage, RegionPtr pReg, void *pClosure)
-{
-    PixmapPtr pPixmap = pClosure;
-    ExaPixmapPriv(pPixmap);
-    RegionPtr pDamageReg = DamageRegion(pDamage);
-
-    if (pExaPixmap->pendingDamage) {
-	REGION_UNION(pScreen, pDamageReg, pDamageReg, pReg);
-	pExaPixmap->pendingDamage = FALSE;
-    }
-}
-
-
 /**
  * exaCreatePixmap() creates a new pixmap.
  *
@@ -363,8 +348,8 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
         }
 
 	/* Set up damage tracking */
-	pExaPixmap->pDamage = DamageCreate (ExaDamageReport, NULL,
-					    DamageReportRawRegion, TRUE,
+	pExaPixmap->pDamage = DamageCreate (NULL, NULL,
+					    DamageReportNone, TRUE,
 					    pScreen, pPixmap);
 
 	if (pExaPixmap->pDamage == NULL) {
@@ -373,6 +358,8 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
 	}
 
 	DamageRegister (&pPixmap->drawable, pExaPixmap->pDamage);
+	/* This ensures that pending damage reflects the current operation. */
+	/* This is used by exa to optimize migration. */
 	DamageSetReportAfterOp (pExaPixmap->pDamage, TRUE);
     }
  
diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index 2bb2ad9..2f90b82 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -43,39 +43,6 @@
 #endif
 
 /**
- * Returns TRUE if the pixmap has damage.
- * EXA only migrates the parts of a destination 
- * that are affected by rendering.
- * It uses the current damage as indication.
- * So anything that does not need to be updated won't be.
- * For clarity this seperate function was made.
- * Note that some situations don't use this, 
- * because their calls are wrapped by the damage layer.
- */
-Bool
-exaDamageDestForMigration(DrawablePtr pDrawable, PixmapPtr pPix, RegionPtr region)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-    (void) pScreen; /* the macros don't use pScreen currently */
-    ExaPixmapPriv (pPix);
-    int x_offset, y_offset;
-    RegionPtr pending_damage;
-
-    if (!pExaPixmap->pDamage)
-	return FALSE;
-
-    exaGetDrawableDeltas(pDrawable, pPix, &x_offset, &y_offset);
-
-    REGION_TRANSLATE(pScreen, region, x_offset, y_offset);
-    pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
-    REGION_UNION(pScreen, pending_damage, pending_damage, region);
-    /* Restore region as we got it. */
-    REGION_TRANSLATE(pScreen, region, -x_offset, -y_offset);
-
-    return TRUE;
-}
-
-/**
  * Returns TRUE if the pixmap is not movable.  This is the case where it's a
  * fake pixmap for the frontbuffer (no pixmap private) or it's a scratch
  * pixmap created by some other X Server internals (the score says it's
@@ -332,9 +299,6 @@ exaDoMoveInPixmap (ExaMigrationPtr migrate)
     ExaScreenPriv (pScreen);
     ExaPixmapPriv (pPixmap);
 
-    if (migrate->as_dst)
-	pExaPixmap->pendingDamage = TRUE;
-
     /* If we're VT-switched away, no touching card memory allowed. */
     if (pExaScr->swappedOut)
 	return;
@@ -403,9 +367,6 @@ exaDoMoveOutPixmap (ExaMigrationPtr migrate)
     PixmapPtr pPixmap = migrate->pPix;
     ExaPixmapPriv (pPixmap);
 
-    if (migrate->as_dst)
-	pExaPixmap->pendingDamage = TRUE;
-
     if (!pExaPixmap->area || exaPixmapIsPinned(pPixmap))
 	return;
 
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 0ebe07b..bd3c76e 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -226,7 +226,6 @@ typedef struct {
      * location.
      */
     DamagePtr	    pDamage;
-    Bool	    pendingDamage;
     /**
      * The valid regions mark the valid bits (at least, as they're derived from
      * damage, which may be overreported) of a pixmap's system and FB copies.
@@ -494,7 +493,4 @@ exaDoMigration (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
 void
 exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area);
 
-Bool
-exaDamageDestForMigration(DrawablePtr pDrawable, PixmapPtr pPix, RegionPtr region);
-
 #endif /* EXAPRIV_H */
diff --git a/exa/exa_render.c b/exa/exa_render.c
index bafa309..9f6ac3f 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -466,11 +466,11 @@ exaCompositeRects(CARD8	              op,
 {
     PixmapPtr pPixmap = exaGetDrawablePixmap(pDst->pDrawable);
     ExaPixmapPriv(pPixmap);
-    RegionRec region;
     int n;
     ExaCompositeRectPtr r;
     
     if (pExaPixmap->pDamage) {
+	RegionRec region;
 	int x1 = MAXSHORT;
 	int y1 = MAXSHORT;
 	int x2 = MINSHORT;
@@ -518,7 +518,9 @@ exaCompositeRects(CARD8	              op,
 
 	REGION_INIT(pScreen, &region, &box, 1);
     
-	exaDamageDestForMigration(pDst->pDrawable, pPixmap, &region);
+	DamageRegionPending(pDst->pDrawable, &region);
+
+	REGION_UNINIT(pScreen, &region);
     }
     
     /************************************************************/
@@ -543,13 +545,10 @@ exaCompositeRects(CARD8	              op,
 
     if (pExaPixmap->pDamage) {
 	/* Now we have to flush the damage out from pendingDamage => damage 
-	 * Calling DamageDamageRegion has that effect. (We could pass
-	 * in an empty region here, but we pass in the same region we
-	 * use above; the effect is the same.)
+	 * Calling DamageRegionSubmitted has that effect.
 	 */
 
-	DamageDamageRegion(pDst->pDrawable, &region);
-	REGION_UNINIT(pScreen, &region);
+	DamageRegionSubmitted(pDst->pDrawable);
     }
 }
 
@@ -1064,16 +1063,20 @@ exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 	DrawablePtr pDraw = pDst->pDrawable;
 	PixmapPtr pixmap = exaGetDrawablePixmap (pDraw);
 	ExaPixmapPriv (pixmap);
-	RegionRec migration;
 
+	/* Damage manually, because Trapezoids expects to hit Composite normally. */
+	/* Composite is wrapped by damage, but Trapezoids isn't. */
 	if (pExaPixmap->pDamage) {
+	    RegionRec migration;
+
 	    bounds.x1 += pDraw->x;
 	    bounds.y1 += pDraw->y;
 	    bounds.x2 += pDraw->x;
 	    bounds.y2 += pDraw->y;
 
 	    REGION_INIT(pScreen, &migration, &bounds, 1);
-	    exaDamageDestForMigration(pDraw, pixmap, &migration);
+	    DamageRegionPending(pDraw, &migration);
+	    REGION_UNINIT(pScreen, &migration);
 	}
 
 	exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
@@ -1083,12 +1086,8 @@ exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 
 	exaFinishAccess(pDraw, EXA_PREPARE_DEST);
 
-	/* Damage manually, because Trapezoids expects to hit Composite normally. */
-	/* Composite is wrapped by damage, but Trapezoids isn't. */
-	if (pExaPixmap->pDamage) {
-	    DamageDamageRegion(pDraw, &migration);
-	    REGION_UNINIT(pScreen, &migration);
-	}
+	if (pExaPixmap->pDamage)
+	    DamageRegionSubmitted(pDraw);
     }
     else if (maskFormat)
     {
@@ -1168,28 +1167,28 @@ exaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 	DrawablePtr pDraw = pDst->pDrawable;
 	PixmapPtr pixmap = exaGetDrawablePixmap (pDraw);
 	ExaPixmapPriv (pixmap);
-	RegionRec migration;
 
+	/* Damage manually, because Triangles expects to hit Composite normally. */
+	/* Composite is wrapped by damage, but Triangles isn't. */
 	if (pExaPixmap->pDamage) {
+	    RegionRec migration;
+
 	    bounds.x1 += pDraw->x;
 	    bounds.y1 += pDraw->y;
 	    bounds.x2 += pDraw->x;
 	    bounds.y2 += pDraw->y;
 
 	    REGION_INIT(pScreen, &migration, &bounds, 1);
-	    exaDamageDestForMigration(pDraw, pixmap, &migration);
+	    DamageRegionPending(pDraw, &migration);
+	    REGION_UNINIT(pScreen, &migration);
 	}
 
 	exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
 	(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
 	exaFinishAccess(pDraw, EXA_PREPARE_DEST);
 
-	/* Damage manually, because Triangles expects to hit Composite normally. */
-	/* Composite is wrapped by damage, but Triangles isn't. */
-	if (pExaPixmap->pDamage) {
-	    DamageDamageRegion(pDraw, &migration);
-	    REGION_UNINIT(pScreen, &migration);
-	}
+	if (pExaPixmap->pDamage)
+	    DamageRegionSubmitted(pDraw);
     }
     else if (maskFormat)
     {
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 8ae56ed..eedb8ad 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -804,7 +804,9 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
 
     REGION_INIT(pDraw->pScreen, &region, (BoxPtr) rects, num_rects);
     REGION_TRANSLATE(pScreen, &region, pDraw->x, pDraw->y);
-    DamageDamageRegion(pDraw, &region);
+    DamageRegionPending(pDraw, &region);
+    /* This is wrong, this needs a seperate function. */
+    DamageRegionSubmitted(pDraw);
     REGION_UNINIT(pDraw->pScreen, &region);
 
     __glXleaveServer(GL_FALSE);
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 6c93066..9526284 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -336,7 +336,7 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc)
     damage_box.y1 = crtc->y;
     damage_box.y2 = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
     REGION_INIT (pScreen, &damage_region, &damage_box, 1);
-    DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
+    DamageRegionPending (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
 			&damage_region);
     REGION_UNINIT (pScreen, &damage_region);
 }
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 5000a82..c5fdca7 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -168,11 +168,11 @@ DamageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
 
 #if DAMAGE_DEBUG_ENABLE
 static void
-_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where)
-#define damageDamageRegion(d,r,c,m) _damageDamageRegion(d,r,c,m,__FUNCTION__)
+_damageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where)
+#define damageRegionPending(d,r,c,m) _damageRegionPending(d,r,c,m,__FUNCTION__)
 #else
 static void
-damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
+damageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 			int subWindowMode)
 #endif
 {
@@ -330,7 +330,7 @@ damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 }
 
 static void
-damageReportPostOp (DrawablePtr pDrawable)
+damageRegionSubmitted (DrawablePtr pDrawable)
 {
     drawableDamage(pDrawable);
 
@@ -357,9 +357,9 @@ damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode)
 
     REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
 #if DAMAGE_DEBUG_ENABLE
-    _damageDamageRegion (pDrawable, &region, TRUE, subWindowMode, where);
+    _damageRegionPending (pDrawable, &region, TRUE, subWindowMode, where);
 #else
-    damageDamageRegion (pDrawable, &region, TRUE, subWindowMode);
+    damageRegionPending (pDrawable, &region, TRUE, subWindowMode);
 #endif
     REGION_UNINIT (pDrawable->pScreen, &region);
 }
@@ -589,7 +589,7 @@ damageComposite (CARD8      op,
 		       yDst,
 		       width,
 		       height);
-    damageReportPostOp (pDst->pDrawable);
+    damageRegionSubmitted (pDst->pDrawable);
     wrap (pScrPriv, ps, Composite, damageComposite);
 }
 
@@ -656,7 +656,7 @@ damageGlyphs (CARD8		op,
     }
     unwrap (pScrPriv, ps, Glyphs);
     (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
-    damageReportPostOp (pDst->pDrawable);
+    damageRegionSubmitted (pDst->pDrawable);
     wrap (pScrPriv, ps, Glyphs, damageGlyphs);
 }
 #endif
@@ -709,7 +709,7 @@ damageFillSpans(DrawablePtr pDrawable,
     
     (*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted);
 
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -757,7 +757,7 @@ damageSetSpans(DrawablePtr  pDrawable,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -789,7 +789,7 @@ damagePutImage(DrawablePtr  pDrawable,
     }
     (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h,
 		leftPad, format, pImage);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -833,7 +833,7 @@ damageCopyArea(DrawablePtr   pSrc,
 
     ret = (*pGC->ops->CopyArea)(pSrc, pDst,
             pGC, srcx, srcy, width, height, dstx, dsty);
-    damageReportPostOp (pDst);
+    damageRegionSubmitted (pDst);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDst);
     return ret;
 }
@@ -879,7 +879,7 @@ damageCopyPlane(DrawablePtr	pSrc,
 
     ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
 	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
-    damageReportPostOp (pDst);
+    damageRegionSubmitted (pDst);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDst);
     return ret;
 }
@@ -921,7 +921,7 @@ damagePolyPoint(DrawablePtr pDrawable,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -995,7 +995,7 @@ damagePolylines(DrawablePtr pDrawable,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1074,7 +1074,7 @@ damagePolySegment(DrawablePtr	pDrawable,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1136,7 +1136,7 @@ damagePolyRectangle(DrawablePtr  pDrawable,
 	}
     }
     (*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1189,7 +1189,7 @@ damagePolyArc(DrawablePtr   pDrawable,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1248,7 +1248,7 @@ damageFillPolygon(DrawablePtr	pDrawable,
     }
     
     (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1287,7 +1287,7 @@ damagePolyFillRect(DrawablePtr	pDrawable,
 	    damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1329,7 +1329,7 @@ damagePolyFillArc(DrawablePtr	pDrawable,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1440,7 +1440,7 @@ damagePolyText8(DrawablePtr pDrawable,
 		    Linear8Bit, TT_POLY8);
     else
 	x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
     return x;
 }
@@ -1461,7 +1461,7 @@ damagePolyText16(DrawablePtr	pDrawable,
 		    TT_POLY16);
     else
 	x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
     return x;
 }
@@ -1481,7 +1481,7 @@ damageImageText8(DrawablePtr	pDrawable,
 		    Linear8Bit, TT_IMAGE8);
     else
 	(*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1501,7 +1501,7 @@ damageImageText16(DrawablePtr	pDrawable,
 		    TT_IMAGE16);
     else
 	(*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1520,7 +1520,7 @@ damageImageGlyphBlt(DrawablePtr	    pDrawable,
 		       nglyph, ppci, TRUE, pGC->subWindowMode);
     (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph,
 					ppci, pglyphBase);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1538,7 +1538,7 @@ damagePolyGlyphBlt(DrawablePtr	pDrawable,
 		       nglyph, ppci, FALSE, pGC->subWindowMode);
     (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph,
 				ppci, pglyphBase);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1572,7 +1572,7 @@ damagePushPixels(GCPtr		pGC,
 	   damageDamageBox (pDrawable, &box, pGC->subWindowMode);
     }
     (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
     DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);
 }
 
@@ -1652,12 +1652,12 @@ damageCopyWindow(WindowPtr	pWindow,
 	 * at the destination location.  Translate back and forth.
 	 */
 	REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
-	damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE, -1);
+	damageRegionPending (&pWindow->drawable, prgnSrc, FALSE, -1);
 	REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
     }
     unwrap (pScrPriv, pScreen, CopyWindow);
     (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
-    damageReportPostOp (&pWindow->drawable);
+    damageRegionSubmitted (&pWindow->drawable);
     wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
 }
 
@@ -1740,6 +1740,10 @@ damageCloseScreen (int i, ScreenPtr pScreen)
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
+/**
+ * Public functions for consumption outside this file.
+ */
+
 Bool
 DamageSetup (ScreenPtr pScreen)
 {
@@ -1941,16 +1945,29 @@ DamagePendingRegion (DamagePtr	    pDamage)
 }
 
 _X_EXPORT void
+DamageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion)
+{
+    damageRegionPending (pDrawable, pRegion, FALSE, -1);
+}
+
+_X_EXPORT void
+DamageRegionSubmitted (DrawablePtr pDrawable)
+{
+    damageRegionSubmitted (pDrawable);
+}
+
+/* This call is very odd, i'm leaving it intact for API sake, but please don't use it. */
+_X_EXPORT void
 DamageDamageRegion (DrawablePtr	pDrawable,
 		    RegionPtr	pRegion)
 {
-    damageDamageRegion (pDrawable, pRegion, FALSE, -1);
+    damageRegionPending (pDrawable, pRegion, FALSE, -1);
 
     /* Go back and report this damage for DamagePtrs with reportAfter set, since
      * this call isn't part of an in-progress drawing op in the call chain and
      * the DDX probably just wants to know about it right away.
      */
-    damageReportPostOp (pDrawable);
+    damageRegionSubmitted (pDrawable);
 }
 
 void
diff --git a/miext/damage/damage.h b/miext/damage/damage.h
index 102da6e..ad9ab4c 100755
--- a/miext/damage/damage.h
+++ b/miext/damage/damage.h
@@ -78,6 +78,15 @@ DamageRegion (DamagePtr		    pDamage);
 RegionPtr
 DamagePendingRegion (DamagePtr	    pDamage);
 
+/* Call this function before rendering to a destination. */
+void
+DamageRegionPending (DrawablePtr pDrawable, RegionPtr pRegion);
+
+/* Call this directly after the rendering operation has been submitted. */
+void
+DamageRegionSubmitted (DrawablePtr pDrawable);
+
+/* Avoid using this call, it only exists for API compatibility. */
 void
 DamageDamageRegion (DrawablePtr	    pDrawable,
 		    const RegionPtr pRegion);


More information about the xorg-commit mailing list