[PATCH] fb: Use an indirect reference to the Screen Pixmap

Chris Wilson chris at chris-wilson.co.uk
Wed Mar 23 04:40:40 PDT 2011


In an uncomposited Display, every window renders directly onto a
clipped region of the Screen Pixmap. Currently every Window therefore
has a pointer to the Screen Pixmap as its WindowPrivate. However, this
direct reference prevents the propagation of the driver changing the
Screen Pixmap - every Window still holds a pointer to the old Screen
Pixmap!

One solution is to use the NULL WindowPrivate to imply an indirect
reference to the Screen Pixmap, and perform the redirection every time
we query the Pixmap for a Window.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 fb/fb.h        |   12 ++++++++++--
 fb/fboverlay.c |    2 +-
 fb/fbscreen.c  |    3 ++-
 fb/fbwindow.c  |    2 --
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/fb/fb.h b/fb/fb.h
index 021a940..8e17063 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -679,8 +679,16 @@ typedef struct {
 #define fbGetRotatedPixmap(pGC)	((pGC)->pRotatedPixmap)
 
 #define fbGetScreenPixmap(s)	((PixmapPtr) (s)->devPrivate)
-#define fbGetWindowPixmap(pWin)	((PixmapPtr)\
-				 dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
+static inline PixmapPtr
+fbGetWindowPixmap(void *_win)
+{
+	WindowPtr win = _win;
+	PixmapPtr pixmap = dixLookupPrivate(&win->devPrivates,
+					    fbGetWinPrivateKey());
+	if (pixmap == NULL)
+		pixmap = win->drawable.pScreen->devPrivate;
+	return pixmap;
+}
 
 #ifdef ROOTLESS
 #define __fbPixDrawableX(pPix)	((pPix)->drawable.x)
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 7fca89c..bde93f7 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -65,7 +65,7 @@ fbOverlayCreateWindow(WindowPtr pWin)
 	pPixmap = pScrPriv->layer[i].u.run.pixmap;
 	if (pWin->drawable.depth == pPixmap->drawable.depth)
 	{
-	    dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
+	    _fbSetWindowPixmap(pWin, pPixmap);
 	    /*
 	     * Make sure layer keys are written correctly by
 	     * having non-root layers set to full while the
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 2502efe..392de81 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -87,7 +87,8 @@ _fbGetWindowPixmap (WindowPtr pWindow)
 void
 _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
 {
-    dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap);
+    if (pPixmap != pWindow->drawable.pScreen->devPrivate)
+	dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap);
 }
 
 Bool
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index bb0384d..4b89d13 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -31,8 +31,6 @@
 Bool
 fbCreateWindow(WindowPtr pWin)
 {
-    dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
-		  fbGetScreenPixmap(pWin->drawable.pScreen));
 #ifdef FB_SCREEN_PRIVATE
     if (pWin->drawable.bitsPerPixel == 32)
 	pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
-- 
1.7.4.1



More information about the xorg-devel mailing list