For external Damage, we need only track sufficient information to
satisfy the DamageReportLevel. That is if the Client only wishes to hear
that the Damage is now non-empty or if the extents change, we only need
to track the extents of the Damage and can discard the actual
rectangles. This speeds up the union operation, speeding up damage
processing for Client as well - with a noticeable increase in
performance of gnome-shell (which uses DamageReportBoundingBox) for
example.

Internal users of Damage have access to the DamageRegion irrespective of
the DamageReportLevel and so we need to keep the full region intact for
them.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Adam Jackson <a...@redhat.com>
---
 miext/damage/damage.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index b99cfb0..450a517 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1906,6 +1906,16 @@ DamageGetScreenFuncs(ScreenPtr pScreen)
     return &pScrPriv->funcs;
 }
 
+static void DamageCombineExtents(DamagePtr pDamage, RegionPtr pDamageRegion)
+{
+    if (!pDamage->isInternal) {
+        RegionUninit(pDamageRegion);
+        RegionUnion(&pDamage->damage, &pDamage->damage, pDamageRegion);
+        RegionUninit(&pDamage->damage);
+    } else
+        RegionUnion(&pDamage->damage, &pDamage->damage, pDamageRegion);
+}
+
 void
 DamageReportDamage(DamagePtr pDamage, RegionPtr pDamageRegion)
 {
@@ -1929,7 +1939,7 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr 
pDamageRegion)
         break;
     case DamageReportBoundingBox:
         tmpBox = *RegionExtents(&pDamage->damage);
-        RegionUnion(&pDamage->damage, &pDamage->damage, pDamageRegion);
+        DamageCombineExtents(pDamage, pDamageRegion);
         if (!BOX_SAME(&tmpBox, RegionExtents(&pDamage->damage))) {
             (*pDamage->damageReport) (pDamage, &pDamage->damage,
                                       pDamage->closure);
@@ -1937,7 +1947,7 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr 
pDamageRegion)
         break;
     case DamageReportNonEmpty:
         was_empty = !RegionNotEmpty(&pDamage->damage);
-        RegionUnion(&pDamage->damage, &pDamage->damage, pDamageRegion);
+        DamageCombineExtents(pDamage, pDamageRegion);
         if (was_empty && RegionNotEmpty(&pDamage->damage)) {
             (*pDamage->damageReport) (pDamage, &pDamage->damage,
                                       pDamage->closure);
-- 
2.1.4

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to