[PATCH] EXA: Try to prevent the valid regions from growing too many rects.
Michel Dänzer
michel at daenzer.net
Sat Feb 14 05:28:50 PST 2009
From: Michel Dänzer <daenzer at vmware.com>
This helps contain region management overhead in some pathological cases.
Signed-off-by: Michel Dänzer <daenzer at vmware.com>
---
exa/exa_migration.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index 8fb6d2f..11647d9 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -173,7 +173,29 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
}
#endif
- REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
+ /* Try to prevent destination valid region from growing too many
+ * rects
+ */
+ if (REGION_NUM_RECTS(pValidDst) > 10) {
+ BoxRec box;
+ BoxPtr pValidExt, pDamageExt;
+ RegionRec closure;
+
+ pValidExt = REGION_EXTENTS(pScreen, pValidDst);
+ pDamageExt = REGION_EXTENTS(pScreen, pending_damage);
+
+ box.x1 = min(pValidExt->x1, pDamageExt->x1);
+ box.y1 = min(pValidExt->y1, pDamageExt->y1);
+ box.x2 = max(pValidExt->x2, pDamageExt->x2);
+ box.y2 = max(pValidExt->y2, pDamageExt->y2);
+
+ /* Limit migration to extents of union of destination valid
+ * region and pending damage region
+ */
+ REGION_INIT(pScreen, &closure, &box, 0);
+ REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, &closure);
+ } else
+ REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
}
/* The caller may provide a region to be subtracted from the calculated
@@ -237,6 +259,10 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
pExaPixmap->offscreen = save_offscreen;
pPixmap->devKind = save_pitch;
+ /* Try to prevent source valid region from growing too many rects */
+ if (REGION_NUM_RECTS(pValidSrc) > 10)
+ REGION_SUBTRACT(pScreen, pValidSrc, pValidSrc, pValidDst);
+
/* The copied bits are now valid in destination */
REGION_UNION(pScreen, pValidDst, pValidDst, &CopyReg);
--
1.6.2.rc0
More information about the xorg-devel
mailing list