[PATCH] [RFC] dix/mi: remove ChangeWindowAttributes from rendering path.

Mark Kettenis mark.kettenis at xs4all.nl
Thu Mar 31 02:34:21 PDT 2011


> From: Dave Airlie <airlied at gmail.com>
> Date: Thu, 31 Mar 2011 16:07:46 +1000
> 
> From: Dave Airlie <airlied at redhat.com>
> 
> This moves ChangeWindowAttributes to mi, and calls a new hook
> that fb/exa can use to fixup the pixmap properly.
> 
> I've looked at XAA and it seems this should work there as well,
> and I'm sure UXA is like EXA.

Hmm.  The version of the xf86-video-intel driver we use on OpenBSD
calls fbChangeWindowAttributes().  We're stuck with that particular
version for now since newer versions have the modesetting code ripped
out.  I suppose a simple s/fbChangeWindowAttributes/miChangeWindowAttributes/
would be enough to make the driver compile (and work) again.  But
probably we'll have forgotten about that in a couple of months when we
import the new xserver code with this change.  Any reason not to add a

#define fbChangeWindowAttributes miChangeWindowAttributes

to fb.h for API compatibility?

> 
> pretty much same set of open questions:
> 
> sane? interface good enough? naming?
> 
> (again only lightly tested with emacs which hits these
> paths inside Xcan't spell it.
> 
> Dave.
> ---
>  exa/exa.c            |   31 ++++++++++---------------------
>  exa/exa_priv.h       |    2 +-
>  fb/fb.h              |    6 +++---
>  fb/fbscreen.c        |    2 +-
>  fb/fbwindow.c        |   26 +++++---------------------
>  include/scrnintstr.h |    3 +++
>  mi/mi.h              |    2 ++
>  mi/miscrinit.c       |    1 +
>  mi/miwindow.c        |   14 ++++++++++++++
>  9 files changed, 40 insertions(+), 47 deletions(-)
> 
> diff --git a/exa/exa.c b/exa/exa.c
> index 604b657..afc8985 100644
> --- a/exa/exa.c
> +++ b/exa/exa.c
> @@ -642,31 +642,20 @@ exaCreateGC (GCPtr pGC)
>      return ret;
>  }
>  
> -static Bool
> -exaChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
> +static void
> +exaPixmapWindowFixup(PixmapPtr *ppPixmap, int bpp)
>  {
> -    Bool ret;
> -    ScreenPtr pScreen = pWin->drawable.pScreen;
> +    ScreenPtr pScreen = (*ppPixmap)->drawable.pScreen;
>      ExaScreenPriv(pScreen);
> -
> -    if ((mask & CWBackPixmap) && pWin->backgroundState == BackgroundPixmap) 
> -	exaPrepareAccess(&pWin->background.pixmap->drawable, EXA_PREPARE_SRC);
> -
> -    if ((mask & CWBorderPixmap) && pWin->borderIsPixel == FALSE)
> -	exaPrepareAccess(&pWin->border.pixmap->drawable, EXA_PREPARE_MASK);
> +    exaPrepareAccess(&(*ppPixmap)->drawable, EXA_PREPARE_SRC);
>  
>      pExaScr->fallback_counter++;
> -    swap(pExaScr, pScreen, ChangeWindowAttributes);
> -    ret = pScreen->ChangeWindowAttributes(pWin, mask);
> -    swap(pExaScr, pScreen, ChangeWindowAttributes);
> +    swap(pExaScr, pScreen, PixmapWindowFixup);
> +    pScreen->PixmapWindowFixup(ppPixmap, bpp);
> +    swap(pExaScr, pScreen, PixmapWindowFixup);
>      pExaScr->fallback_counter--;
>  
> -    if ((mask & CWBackPixmap) && pWin->backgroundState == BackgroundPixmap) 
> -	exaFinishAccess(&pWin->background.pixmap->drawable, EXA_PREPARE_SRC);
> -    if ((mask & CWBorderPixmap) && pWin->borderIsPixel == FALSE)
> -	exaFinishAccess(&pWin->border.pixmap->drawable, EXA_PREPARE_MASK);
> -
> -    return ret;
> +    exaFinishAccess(&(*ppPixmap)->drawable, EXA_PREPARE_SRC);
>  }
>  
>  static RegionPtr
> @@ -793,7 +782,7 @@ exaCloseScreen(int i, ScreenPtr pScreen)
>      if (pExaScr->SavedModifyPixmapHeader)
>  	unwrap(pExaScr, pScreen, ModifyPixmapHeader);
>      unwrap(pExaScr, pScreen, PixmapCopyRegion);
> -    unwrap(pExaScr, pScreen, ChangeWindowAttributes);
> +    unwrap(pExaScr, pScreen, PixmapWindowFixup);
>      unwrap(pExaScr, pScreen, BitmapToRegion);
>      unwrap(pExaScr, pScreen, CreateScreenResources);
>      unwrap(pExaScr, ps, Composite);
> @@ -952,7 +941,7 @@ exaDriverInit (ScreenPtr		pScreen,
>      wrap(pExaScr, pScreen, GetImage, exaGetImage);
>      wrap(pExaScr, pScreen, GetSpans, ExaCheckGetSpans);
>      wrap(pExaScr, pScreen, PixmapCopyRegion, exaPixmapCopyRegion);
> -    wrap(pExaScr, pScreen, ChangeWindowAttributes, exaChangeWindowAttributes);
> +    wrap(pExaScr, pScreen, PixmapWindowFixup, exaPixmapWindowFixup);
>      wrap(pExaScr, pScreen, BitmapToRegion, exaBitmapToRegion);
>      wrap(pExaScr, pScreen, CreateScreenResources, exaCreateScreenResources);
>  
> diff --git a/exa/exa_priv.h b/exa/exa_priv.h
> index 37906ba..19b9ab1 100644
> --- a/exa/exa_priv.h
> +++ b/exa/exa_priv.h
> @@ -156,7 +156,7 @@ typedef struct {
>      CreatePixmapProcPtr 	 SavedCreatePixmap;
>      DestroyPixmapProcPtr 	 SavedDestroyPixmap;
>      PixmapCopyRegionProcPtr 	 SavedPixmapCopyRegion;
> -    ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
> +    PixmapWindowFixupProcPtr     SavedPixmapWindowFixup;
>      BitmapToRegionProcPtr        SavedBitmapToRegion;
>      CreateScreenResourcesProcPtr SavedCreateScreenResources;
>      ModifyPixmapHeaderProcPtr    SavedModifyPixmapHeader;
> diff --git a/fb/fb.h b/fb/fb.h
> index dd1f533..2c1a7ad 100644
> --- a/fb/fb.h
> +++ b/fb/fb.h
> @@ -2010,9 +2010,6 @@ fbPositionWindow(WindowPtr pWin, int x, int y);
>  extern _X_EXPORT Bool
>  fbUnmapWindow(WindowPtr pWindow);
>      
> -extern _X_EXPORT Bool
> -fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
> -
>  extern _X_EXPORT void
>  fbFillRegionSolid (DrawablePtr	pDrawable,
>  		   RegionPtr	pRegion,
> @@ -2027,5 +2024,8 @@ image_from_pict (PicturePtr	pict,
>  
>  extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
>  
> +void
> +fbPixmapWindowFixup(PixmapPtr *ppPixmap, int bpp);
> +
>  #endif /* _FB_H_ */
>  
> diff --git a/fb/fbscreen.c b/fb/fbscreen.c
> index 5b5c583..93c0292 100644
> --- a/fb/fbscreen.c
> +++ b/fb/fbscreen.c
> @@ -112,10 +112,10 @@ fbSetupScreen(ScreenPtr	pScreen,
>      pScreen->CreateWindow = fbCreateWindow;
>      pScreen->DestroyWindow = fbDestroyWindow;
>      pScreen->PositionWindow = fbPositionWindow;
> -    pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
>      pScreen->RealizeWindow = fbMapWindow;
>      pScreen->UnrealizeWindow = fbUnmapWindow;
>      pScreen->PixmapCopyRegion = fbPixmapCopyRegion;
> +    pScreen->PixmapWindowFixup = fbPixmapWindowFixup;
>      pScreen->CreatePixmap = fbCreatePixmap;
>      pScreen->DestroyPixmap = fbDestroyPixmap;
>      pScreen->RealizeFont = fbRealizeFont;
> diff --git a/fb/fbwindow.c b/fb/fbwindow.c
> index 8b439b1..041a9d7 100644
> --- a/fb/fbwindow.c
> +++ b/fb/fbwindow.c
> @@ -72,17 +72,17 @@ fbPixmapCopyRegion(PixmapPtr pPixmap,
>  		 prgnDst, dx, dy, fbCopyNtoN, 0, 0);
>  }
>  
> -static void
> -fbFixupWindowPixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
> +void
> +fbPixmapWindowFixup(PixmapPtr *ppPixmap, int bpp)
>  {
>      PixmapPtr pPixmap = *ppPixmap;
>  
> -    if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
> +    if (pPixmap->drawable.bitsPerPixel != bpp)
>      {
> -	pPixmap = fb24_32ReformatTile (pPixmap, pDrawable->bitsPerPixel);
> +	pPixmap = fb24_32ReformatTile (pPixmap, bpp);
>  	if (!pPixmap)
>  	    return;
> -	(*pDrawable->pScreen->DestroyPixmap) (*ppPixmap);
> +	(*pPixmap->drawable.pScreen->DestroyPixmap) (*ppPixmap);
>  	*ppPixmap = pPixmap;
>      }
>      if (FbEvenTile (pPixmap->drawable.width *
> @@ -90,22 +90,6 @@ fbFixupWindowPixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
>  	fbPadPixmap (pPixmap);
>  }
>  
> -Bool
> -fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
> -{
> -    if (mask & CWBackPixmap)
> -    {
> -	if (pWin->backgroundState == BackgroundPixmap)
> -	    fbFixupWindowPixmap(&pWin->drawable, &pWin->background.pixmap);
> -    }
> -    if (mask & CWBorderPixmap)
> -    {
> -	if (pWin->borderIsPixel == FALSE)
> -	    fbFixupWindowPixmap(&pWin->drawable, &pWin->border.pixmap);
> -    }
> -    return TRUE;
> -}
> -
>  void
>  fbFillRegionSolid (DrawablePtr	pDrawable,
>  		   RegionPtr	pRegion,
> diff --git a/include/scrnintstr.h b/include/scrnintstr.h
> index 1c4f286..74eeb29 100644
> --- a/include/scrnintstr.h
> +++ b/include/scrnintstr.h
> @@ -201,6 +201,8 @@ typedef   void (* PixmapCopyRegionProcPtr)(
>  	RegionPtr dstregion,
>  	int dx, int dy);
>  
> +typedef void (* PixmapWindowFixupProcPtr)(PixmapPtr *ppPixmap, int bpp);
> +
>  /* pixmap will exist only for the duration of the current rendering operation */
>  #define CREATE_PIXMAP_USAGE_SCRATCH                     1
>  /* pixmap will be the backing pixmap for a redirected window */
> @@ -545,6 +547,7 @@ typedef struct _Screen {
>      DeviceCursorInitializeProcPtr DeviceCursorInitialize;
>      DeviceCursorCleanupProcPtr    DeviceCursorCleanup;
>  
> +    PixmapWindowFixupProcPtr PixmapWindowFixup;
>      PixmapCopyRegionProcPtr PixmapCopyRegion;
>      /* set it in driver side if X server can copy the framebuffer content.
>       * Meant to be used together with '-background none' option, avoiding
> diff --git a/mi/mi.h b/mi/mi.h
> index 1fb9dde..14c3a9e 100644
> --- a/mi/mi.h
> +++ b/mi/mi.h
> @@ -597,4 +597,6 @@ extern _X_EXPORT void miPolyFillArc(
>  );
>  
>  extern _X_EXPORT void miCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
> +
> +extern _X_EXPORT void miChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
>  #endif /* MI_H */
> diff --git a/mi/miscrinit.c b/mi/miscrinit.c
> index 348309e..dd9aafe 100644
> --- a/mi/miscrinit.c
> +++ b/mi/miscrinit.c
> @@ -253,6 +253,7 @@ miScreenInit(
>      pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0;
>      pScreen->WindowExposures = miWindowExposures;
>      pScreen->CopyWindow = miCopyWindow;
> +    pScreen->ChangeWindowAttributes = miChangeWindowAttributes;
>      /* CopyWindow */
>      pScreen->ClearToBackground = miClearToBackground;
>      pScreen->ClipNotify = (ClipNotifyProcPtr) 0;
> diff --git a/mi/miwindow.c b/mi/miwindow.c
> index c74357d..5ed1c27 100644
> --- a/mi/miwindow.c
> +++ b/mi/miwindow.c
> @@ -851,3 +851,17 @@ miCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
>  
>      RegionUninit(&rgnDst);    
>  }
> +
> +void
> +miChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
> +{
> +    ScreenPtr pScreen = pWin->drawable.pScreen;
> +    if (mask & CWBackPixmap)
> +	if (pWin->backgroundState == BackgroundPixmap)
> +	    (*pScreen->PixmapWindowFixup)(&pWin->background.pixmap, pWin->drawable.bitsPerPixel);
> +
> +    if (mask & CWBorderPixmap)
> +	if (pWin->borderIsPixel == FALSE)
> +	    (*pScreen->PixmapWindowFixup)(&pWin->border.pixmap, pWin->drawable.bitsPerPixel);
> +
> +}


More information about the xorg-devel mailing list