[PATCH 2/7] damage: Simplify DamageUnregister

Adam Jackson ajax at redhat.com
Mon Sep 2 07:18:57 PDT 2013


You can only register one drawable on a given damage, so there's no
reason to require the caller to specify the drawable, the damage is
enough.  The implementation would do something fairly horrible if you
_did_ pass mismatched drawable and damage, so let's avoid the problem
entirely.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 composite/compalloc.c         | 4 ++--
 hw/xfree86/modes/xf86Rotate.c | 4 +---
 mi/misprite.c                 | 3 +--
 miext/damage/damage.c         | 5 +++--
 miext/damage/damage.h         | 2 +-
 miext/shadow/shadow.c         | 2 +-
 6 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/composite/compalloc.c b/composite/compalloc.c
index cc69c68..b7d731e 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -205,7 +205,7 @@ compRedirectWindow(ClientPtr pClient, WindowPtr pWin, int update)
             anyMarked = compMarkWindows(pWin, &pLayerWin);
 
         if (cw->damageRegistered) {
-            DamageUnregister(&pWin->drawable, cw->damage);
+            DamageUnregister(cw->damage);
             cw->damageRegistered = FALSE;
         }
         cw->update = CompositeRedirectManual;
@@ -638,7 +638,7 @@ compSetParentPixmap(WindowPtr pWin)
     CompWindowPtr cw = GetCompWindow(pWin);
 
     if (cw->damageRegistered) {
-        DamageUnregister(&pWin->drawable, cw->damage);
+        DamageUnregister(cw->damage);
         cw->damageRegistered = FALSE;
         DamageEmpty(cw->damage);
     }
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index a393747..0b86f01 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -272,9 +272,7 @@ xf86RotateDestroy(xf86CrtcPtr crtc)
             screenDrawable = &pScreen->root->drawable;
         /* Free damage structure */
         if (xf86_config->rotation_damage_registered) {
-            if (screenDrawable)
-                DamageUnregister(screenDrawable,
-                        xf86_config->rotation_damage);
+            DamageUnregister(xf86_config->rotation_damage);
             xf86_config->rotation_damage_registered = FALSE;
             DisableLimitedSchedulingLatency();
         }
diff --git a/mi/misprite.c b/mi/misprite.c
index 8163f5b..85ca022 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -146,8 +146,7 @@ static void
 miSpriteDisableDamage(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
 {
     if (pScreenPriv->damageRegistered) {
-        DamageUnregister(&(pScreen->GetScreenPixmap(pScreen)->drawable),
-                         pScreenPriv->pDamage);
+        DamageUnregister(pScreenPriv->pDamage);
         pScreenPriv->damageRegistered = 0;
     }
 }
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 4753fb5..c059a3a 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1839,8 +1839,9 @@ DamageDrawInternal(ScreenPtr pScreen, Bool enable)
 }
 
 void
-DamageUnregister(DrawablePtr pDrawable, DamagePtr pDamage)
+DamageUnregister(DamagePtr pDamage)
 {
+    DrawablePtr pDrawable = pDamage->pDrawable;
     ScreenPtr pScreen = pDrawable->pScreen;
 
     damageScrPriv(pScreen);
@@ -1884,7 +1885,7 @@ DamageDestroy(DamagePtr pDamage)
     damageScrPriv(pScreen);
 
     if (pDamage->pDrawable)
-        DamageUnregister(pDamage->pDrawable, pDamage);
+        DamageUnregister(pDamage);
 
     if (pDamage->damageDestroy)
         (*pDamage->damageDestroy) (pDamage, pDamage->closure);
diff --git a/miext/damage/damage.h b/miext/damage/damage.h
index c2c313a..e5d6913 100644
--- a/miext/damage/damage.h
+++ b/miext/damage/damage.h
@@ -80,7 +80,7 @@ extern _X_EXPORT void
  DamageRegister(DrawablePtr pDrawable, DamagePtr pDamage);
 
 extern _X_EXPORT void
- DamageUnregister(DrawablePtr pDrawable, DamagePtr pDamage);
+ DamageUnregister(DamagePtr pDamage);
 
 extern _X_EXPORT void
  DamageDestroy(DamagePtr pDamage);
diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
index 2d869e5..1a9088c 100644
--- a/miext/shadow/shadow.c
+++ b/miext/shadow/shadow.c
@@ -219,7 +219,7 @@ shadowRemove(ScreenPtr pScreen, PixmapPtr pPixmap)
     shadowBuf(pScreen);
 
     if (pBuf->pPixmap) {
-        DamageUnregister(&pBuf->pPixmap->drawable, pBuf->pDamage);
+        DamageUnregister(pBuf->pDamage);
         pBuf->update = 0;
         pBuf->window = 0;
         pBuf->randr = 0;
-- 
1.8.3.1



More information about the xorg-devel mailing list