[PATCH 1/2] Replace miSpriteCursorFuncRec with direct calls to midispcur.c.

Peter Hutterer peter.hutterer at who-t.net
Wed May 19 05:06:32 PDT 2010


On Tue, May 18, 2010 at 04:50:25PM -0700, Jamey Sharp wrote:
> Nobody wraps the mi software-cursor sprite rendering implementations.
> 
> Signed-off-by: Jamey Sharp <jamey at minilop.net>

makes sense to me, I just have a few minor comments on style.

> ---
>  mi/midispcur.c |   58 ++++++------------------------------
>  mi/misprite.c  |   38 ++++++------------------
>  mi/misprite.h  |   88 ++++++++++++-------------------------------------------
>  3 files changed, 38 insertions(+), 146 deletions(-)
> 
> diff --git a/mi/midispcur.c b/mi/midispcur.c
> index 4de37d7..16495e4 100644
> --- a/mi/midispcur.c
> +++ b/mi/midispcur.c
> @@ -97,44 +97,6 @@ typedef struct {
>  #endif
>  } miDCCursorRec, *miDCCursorPtr;
>  
> -/*
> - * sprite/cursor method table
> - */
> -
> -static Bool	miDCRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
> -static Bool	miDCUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
> -static Bool	miDCPutUpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, 
> -                                CursorPtr pCursor, int x, int y, 
> -                                unsigned long source, unsigned long mask);
> -static Bool	miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, 
> -                                    int x, int y,
> -				    int w, int h);
> -static Bool	miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen, 
> -                                       int x, int y,
> -				       int w, int h);
> -static Bool	miDCMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, 
> -                               CursorPtr pCursor, int x, int y, 
> -                               int w, int h, int dx, int dy,
> -			       unsigned long source, unsigned long mask);
> -static Bool	miDCChangeSave(DeviceIntPtr pDev, ScreenPtr pScreen, 
> -                               int x, int y, int w, int h,	
> -                               int dx, int dy);
> -
> -static Bool     miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
> -static void     miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
> -
> -static miSpriteCursorFuncRec miDCFuncs = {
> -    miDCRealizeCursor,
> -    miDCUnrealizeCursor,
> -    miDCPutUpCursor,
> -    miDCSaveUnderCursor,
> -    miDCRestoreUnderCursor,
> -    miDCMoveCursor,
> -    miDCChangeSave,
> -    miDCDeviceInitialize,
> -    miDCDeviceCleanup
> -};
> -
>  Bool
>  miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs)
>  {
> @@ -150,7 +112,7 @@ miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs)
>  
>      dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, pScreenPriv);
>  
> -    if (!miSpriteInitialize (pScreen, &miDCFuncs, screenFuncs))
> +    if (!miSpriteInitialize (pScreen, screenFuncs))
>      {
>  	free((pointer) pScreenPriv);
>  	return FALSE;
> @@ -170,7 +132,7 @@ miDCCloseScreen (int index, ScreenPtr pScreen)
>      return (*pScreen->CloseScreen) (index, pScreen);
>  }
>  
> -static Bool
> +Bool
>  miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
>  {
>      if (pCursor->bits->refcnt <= 1)
> @@ -329,7 +291,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor)
>      return pPriv;
>  }
>  
> -static Bool
> +Bool
>  miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
>  {
>      miDCCursorPtr   pPriv;
> @@ -426,7 +388,7 @@ miDCMakeGC(WindowPtr pWin)
>  }
>  
>  
> -static Bool
> +Bool
>  miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
>                   int x, int y, unsigned long source, unsigned long mask)
>  {
> @@ -471,7 +433,7 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
>      return TRUE;
>  }
>  
> -static Bool
> +Bool
>  miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>                       int x, int y, int w, int h)
>  {
> @@ -505,7 +467,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>      return TRUE;
>  }
>  
> -static Bool
> +Bool
>  miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>                          int x, int y, int w, int h)
>  {
> @@ -532,7 +494,7 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>      return TRUE;
>  }
>  
> -static Bool
> +Bool
>  miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
>                  int x, int y, int w, int h, int dx, int dy)
>  {
> @@ -665,7 +627,7 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
>      return TRUE;
>  }
>  
> -static Bool
> +Bool
>  miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
>                  int x, int y, int w, int h, int dx, int dy,
>                  unsigned long source, unsigned long mask)
> @@ -764,7 +726,7 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
>      return TRUE;
>  }
>  
> -static Bool
> +Bool
>  miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
>  {
>      miDCBufferPtr   pBuffer;
> @@ -839,7 +801,7 @@ failure:
>      return FALSE;
>  }
>  
> -static void
> +void
>  miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
>  {
>      miDCBufferPtr   pBuffer;
> diff --git a/mi/misprite.c b/mi/misprite.c
> index 9f10a2b..fb73ef1 100644
> --- a/mi/misprite.c
> +++ b/mi/misprite.c
> @@ -94,7 +94,6 @@ typedef struct {
>      ColormapPtr     pInstalledMap;
>      ColormapPtr     pColormap;
>      VisualPtr	    pVisual;
> -    miSpriteCursorFuncPtr    funcs;
>      DamagePtr	    pDamage;		/* damage tracking structure */
>      Bool            damageRegistered;
>  } miSpriteScreenRec, *miSpriteScreenPtr;
> @@ -289,7 +288,6 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
>  
>  Bool
>  miSpriteInitialize (ScreenPtr               pScreen,
> -                    miSpriteCursorFuncPtr   cursorFuncs,
>                      miPointerScreenFuncPtr  screenFuncs)
>  {
>      miSpriteScreenPtr	pScreenPriv;
> @@ -336,7 +334,6 @@ miSpriteInitialize (ScreenPtr               pScreen,
>  
>      pScreenPriv->pInstalledMap = NULL;
>      pScreenPriv->pColormap = NULL;
> -    pScreenPriv->funcs = cursorFuncs;
>      pScreenPriv->colors[SOURCE_COLOR].red = 0;
>      pScreenPriv->colors[SOURCE_COLOR].green = 0;
>      pScreenPriv->colors[SOURCE_COLOR].blue = 0;
> @@ -760,10 +757,8 @@ miSpriteFindColors (miCursorInfoPtr pDevCursor, ScreenPtr pScreen)
>  static Bool
>  miSpriteRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
>  {
> -    miSpriteScreenPtr	pScreenPriv;
>      miCursorInfoPtr pCursorInfo;
>  
> -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
>      if (!IsMaster(pDev) && !pDev->u.master)
>          return FALSE;
>  
> @@ -772,27 +767,21 @@ miSpriteRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
>      if (pCursor == pCursorInfo->pCursor)
>  	pCursorInfo->checkPixels = TRUE;
>  
> -    return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor);
> +    return miDCRealizeCursor(pScreen, pCursor);
>  }
>  
>  static Bool
>  miSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
>  {
> -    miSpriteScreenPtr	pScreenPriv;
> -
> -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> -    return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor);
> +    return miDCUnrealizeCursor(pScreen, pCursor);
>  }
>  
>  static void
>  miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>                     CursorPtr pCursor, int x, int y)
>  {
> -    miSpriteScreenPtr	pScreenPriv;
>      miCursorInfoPtr pPointer;
>  
> -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> -
>      if (!IsMaster(pDev) && !pDev->u.master)
>          return;
>  
> @@ -861,7 +850,7 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>  		pointer->saved.y1 -= dy;
>  		pointer->saved.x2 -= dx;
>  		pointer->saved.y2 -= dy;
> -		(void) (*pScreenPriv->funcs->ChangeSave) (pScreen,
> +		(void) miDCChangeSave(pScreen,
>  				pointer->saved.x1,
>   				pointer->saved.y1,
>                                  pointer->saved.x2 -
> @@ -870,7 +859,7 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
>                                  pointer->saved.y1,
>  				dx, dy);
>  	    }
> -	    (void) (*pScreenPriv->funcs->MoveCursor) (pScreen, pCursor,
> +	    (void) miDCMoveCursor(pScreen, pCursor,

I'd say this and the one cast above are superfluous.

>  				  pointer->saved.x1,
>   				  pointer->saved.y1,
>                                    pointer->saved.x2 -
> @@ -920,12 +909,9 @@ miSpriteMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
>  static Bool
>  miSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
>  {
> -    miSpriteScreenPtr pScreenPriv;
>      miCursorInfoPtr pCursorInfo;
>      int ret = FALSE;
>  
> -    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
> -
>      pCursorInfo = malloc(sizeof(miCursorInfoRec));
>      if (!pCursorInfo)
>          return FALSE;
> @@ -940,7 +926,7 @@ miSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
>      pCursorInfo->checkPixels = TRUE;
>      pCursorInfo->pScreen = FALSE;
>  
> -    ret = (*pScreenPriv->funcs->DeviceCursorInitialize)(pDev, pScreen);
> +    ret = miDCDeviceInitialize(pDev, pScreen);
>      if (!ret)
>      {
>          free(pCursorInfo);
> @@ -954,13 +940,7 @@ static void
>  miSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
>  {
>      if (DevHasCursor(pDev))
> -    {
> -        miSpriteScreenPtr pScreenPriv;
> -        pScreenPriv = dixLookupPrivate(&pScreen->devPrivates,
> -                                       miSpriteScreenKey);
> -
> -        (*pScreenPriv->funcs->DeviceCursorCleanup)(pDev, pScreen);
> -    }
> +        miDCDeviceCleanup(pDev, pScreen);

indentation

>  }
>  
>  /*
> @@ -984,7 +964,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
>      miSpriteIsDown(pCursorInfo);
>      pCursorInfo->pCacheWin = NullWindow;
>      miSpriteDisableDamage(pScreen, pScreenPriv);
> -    if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pDev,
> +    if (!miDCRestoreUnderCursor(pDev,
>                                           pScreen,
>  					 pCursorInfo->saved.x1,
>                                           pCursorInfo->saved.y1,

urgh, mind fixing up the indentation here?

> @@ -1026,7 +1006,7 @@ miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
>      y = pCursorInfo->y - (int)pCursor->bits->yhot;
>      miSpriteDisableDamage(pScreen, pScreenPriv);
>  
> -    (*pScreenPriv->funcs->SaveUnderCursor) (pDev,
> +    miDCSaveUnderCursor(pDev,
>                                        pScreen,
>  				      pCursorInfo->saved.x1,
>  				      pCursorInfo->saved.y1,

same here

> @@ -1069,7 +1049,7 @@ miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
>      SPRITE_DEBUG(("RestoreCursor %d\n", pDev->id));
>      if (pCursorInfo->checkPixels)
>          miSpriteFindColors (pCursorInfo, pScreen);
> -    if ((*pScreenPriv->funcs->PutUpCursor) (pDev, pScreen,
> +    if (miDCPutUpCursor(pDev, pScreen,
>                  pCursor, x, y,
>                  pScreenPriv->colors[SOURCE_COLOR].pixel,
>                  pScreenPriv->colors[MASK_COLOR].pixel))
> diff --git a/mi/misprite.h b/mi/misprite.h
> index 72dc06f..78bf52c 100644
> --- a/mi/misprite.h
> +++ b/mi/misprite.h
> @@ -32,76 +32,26 @@ used in advertising or otherwise to promote the sale, use or other dealings
>  in this Software without prior written authorization from The Open Group.
>  */
>  
> -typedef struct {
> -    Bool	(*RealizeCursor)(
> -		ScreenPtr /*pScreen*/,
> -		CursorPtr /*pCursor*/
> -);
> -    Bool	(*UnrealizeCursor)(
> -		ScreenPtr /*pScreen*/,
> -		CursorPtr /*pCursor*/
> -);
> -    Bool	(*PutUpCursor)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/,
> -		CursorPtr /*pCursor*/,
> -		int /*x*/,
> -		int /*y*/,
> -		unsigned long /*source*/,
> -		unsigned long /*mask*/
> -);
> -    Bool	(*SaveUnderCursor)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/,
> -		int /*x*/,
> -		int /*y*/,
> -		int /*w*/,
> -		int /*h*/
> -);
> -    Bool	(*RestoreUnderCursor)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/,
> -		int /*x*/,
> -		int /*y*/,
> -		int /*w*/,
> -		int /*h*/
> -);
> -    Bool	(*MoveCursor)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/,
> -		CursorPtr /*pCursor*/,
> -		int /*x*/,
> -		int /*y*/,
> -		int /*w*/,
> -		int /*h*/,
> -		int /*dx*/,
> -		int /*dy*/,
> -		unsigned long /*source*/,
> -		unsigned long /*mask*/
> -);
> -    Bool	(*ChangeSave)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/,
> -		int /*x*/,
> -		int /*y*/,
> -		int /*w*/,
> -		int /*h*/,
> -		int /*dx*/,
> -		int /*dy*/
> -);
> -    Bool	(*DeviceCursorInitialize)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/
> -);
> -    void	(*DeviceCursorCleanup)(
> -                DeviceIntPtr /*pDev*/,
> -		ScreenPtr /*pScreen*/
> -);
> -
> -} miSpriteCursorFuncRec, *miSpriteCursorFuncPtr;
> -
>  extern Bool miSpriteInitialize(
>      ScreenPtr /*pScreen*/,
> -    miSpriteCursorFuncPtr /*cursorFuncs*/,
>      miPointerScreenFuncPtr /*screenFuncs*/
>  );
> +
> +extern Bool miDCRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
> +extern Bool miDCUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
> +extern Bool miDCPutUpCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
> +                            CursorPtr pCursor, int x, int y,
> +                            unsigned long source, unsigned long mask);
> +extern Bool miDCSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
> +                                int x, int y, int w, int h);
> +extern Bool miDCRestoreUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
> +                                   int x, int y, int w, int h);
> +extern Bool miDCMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
> +                           CursorPtr pCursor, int x, int y,
> +                           int w, int h, int dx, int dy,
> +                           unsigned long source, unsigned long mask);
> +extern Bool miDCChangeSave(DeviceIntPtr pDev, ScreenPtr pScreen,
> +                           int x, int y, int w, int h,
> +                           int dx, int dy);
> +extern Bool miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen);
> +extern void miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
> -- 
> 1.7.0

I'd like to see the minor nits fixed, but even without that.
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
  Peter


More information about the xorg-devel mailing list