[PATCH 05/22] mi: Add GetSprtieScreen macro to hide dixLookupPrivate

Pauli Nieminen ext-pauli.nieminen at nokia.com
Thu Dec 30 05:47:34 PST 2010


On 30/12/10 09:11 +1000, ext Peter Hutterer wrote:
> On Wed, Dec 29, 2010 at 09:27:17PM +0200, Pauli wrote:
> > From: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
> > 
> > Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
> > ---
> >  mi/misprite.c |   24 +++++++++++-------------
> >  1 files changed, 11 insertions(+), 13 deletions(-)
> > 
> > diff --git a/mi/misprite.c b/mi/misprite.c
> > index 38a6b93..c42760c 100644
> > --- a/mi/misprite.c
> > +++ b/mi/misprite.c
> > @@ -184,6 +184,9 @@ miSpriteIsDown(miCursorInfoPtr pDevCursor)
> >  
> >  static DevPrivateKeyRec miSpriteScreenKeyRec;
> >  #define miSpriteScreenKey (&miSpriteScreenKeyRec)
> > +#define GetSpriteScreen(pScreen) \
> > +	((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
> > +					miSpriteScreenKey))
> >  static DevPrivateKeyRec miSpriteDevPrivatesKeyRec;
> >  #define miSpriteDevPrivatesKey (&miSpriteDevPrivatesKeyRec)
> >  
> > @@ -373,9 +376,8 @@ miSpriteInitialize (ScreenPtr               pScreen,
> >  static Bool
> >  miSpriteCloseScreen (int i, ScreenPtr pScreen)
> >  {
> > -    miSpriteScreenPtr   pScreenPriv;
> > +    miSpriteScreenPtr   pScreenPriv = GetSpriteScreen(pScreen);
> >  
> > -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> 
> I don't quite understand the motivation for this. You're replacing one
> function call with one other function call. there's no real space-saver and
> while I admit that GetSpriteScreen() is nicer to read, dixLookupPrivate()
> carries some information too - namely that the data is in the privates.
> 

I'm used to reading code like composite and DRI2 that are simplifying code.
If you think it doesn't make sense I can drop this patch.

> also, there's a few indentation issues with this patch.
> 
> Cheers,
>   Peter
> 
> >      pScreen->CloseScreen = pScreenPriv->CloseScreen;
> >      pScreen->GetImage = pScreenPriv->GetImage;
> >      pScreen->GetSpans = pScreenPriv->GetSpans;
> > @@ -546,11 +548,10 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
> >                        pointer pReadmask)
> >  {
> >      ScreenPtr		pScreen = screenInfo.screens[i];
> > -    miSpriteScreenPtr	pPriv;
> > +    miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
> >      DeviceIntPtr            pDev;
> >      miCursorInfoPtr         pCursorInfo;
> >  
> > -    pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> >      SCREEN_PROLOGUE(pScreen, BlockHandler);
> >  
> >      (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
> > @@ -591,9 +592,8 @@ static void
> >  miSpriteInstallColormap (ColormapPtr pMap)
> >  {
> >      ScreenPtr		pScreen = pMap->pScreen;
> > -    miSpriteScreenPtr	pPriv;
> > +    miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
> >  
> > -    pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> >      SCREEN_PROLOGUE(pScreen, InstallColormap);
> >  
> >      (*pScreen->InstallColormap) (pMap);
> > @@ -624,14 +624,13 @@ static void
> >  miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
> >  {
> >      ScreenPtr		pScreen = pMap->pScreen;
> > -    miSpriteScreenPtr	pPriv;
> > +    miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
> >      int			i;
> >      int			updated;
> >      VisualPtr		pVisual;
> >      DeviceIntPtr        pDev;
> >      miCursorInfoPtr     pCursorInfo;
> >  
> > -    pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> >      SCREEN_PROLOGUE(pScreen, StoreColors);
> >  
> >      (*pScreen->StoreColors) (pMap, ndef, pdef);
> > @@ -706,8 +705,7 @@ miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
> >  static void
> >  miSpriteFindColors (miCursorInfoPtr pDevCursor, ScreenPtr pScreen)
> >  {
> > -    miSpriteScreenPtr   pScreenPriv =
> > -	dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> > +    miSpriteScreenPtr   pScreenPriv = GetSpriteScreen(pScreen);
> >      CursorPtr		pCursor;
> >      xColorItem		*sourceColor, *maskColor;
> >  
> > @@ -884,7 +882,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
> >          return;
> >  
> >      DamageDrawInternal (pScreen, TRUE);
> > -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> > +    pScreenPriv = GetSpriteScreen(pScreen);
> >      pCursorInfo = MISPRITE(pDev);
> >  
> >      miSpriteIsDown(pCursorInfo);
> > @@ -922,7 +920,7 @@ miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
> >          return;
> >  
> >      DamageDrawInternal (pScreen, TRUE);
> > -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> > +    pScreenPriv = GetSpriteScreen(pScreen);
> >      pCursorInfo = MISPRITE(pDev);
> >  
> >      miSpriteComputeSaved (pDev, pScreen);
> > @@ -963,7 +961,7 @@ miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
> >          return;
> >  
> >      DamageDrawInternal (pScreen, TRUE);
> > -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> > +    pScreenPriv = GetSpriteScreen(pScreen);
> >      pCursorInfo = MISPRITE(pDev);
> >  
> >      miSpriteComputeSaved (pDev, pScreen);
> > -- 
> > 1.7.0.4
> > 
> > _______________________________________________
> > xorg-devel at lists.x.org: X.Org development
> > Archives: http://lists.x.org/archives/xorg-devel
> > Info: http://lists.x.org/mailman/listinfo/xorg-devel
> > 


More information about the xorg-devel mailing list