[PATCH] fb: cleanup fbChangeWindowAttributes
Dave Airlie
airlied at gmail.com
Wed Mar 30 22:35:42 PDT 2011
From: Dave Airlie <airlied at redhat.com>
This cleans up the duplication in fbChangeWindowAttributes,
and fixes a bug if the fb24_32ReformatTile ever failed,
since the old code would happily dereference it in the fbEvenTile
call a few lines later.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
fb/fbwindow.c | 55 ++++++++++++++++++++-----------------------------------
1 files changed, 20 insertions(+), 35 deletions(-)
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 5cad00c..8b439b1 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -72,51 +72,36 @@ fbPixmapCopyRegion(PixmapPtr pPixmap,
prgnDst, dx, dy, fbCopyNtoN, 0, 0);
}
+static void
+fbFixupWindowPixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
+{
+ PixmapPtr pPixmap = *ppPixmap;
+
+ if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap, pDrawable->bitsPerPixel);
+ if (!pPixmap)
+ return;
+ (*pDrawable->pScreen->DestroyPixmap) (*ppPixmap);
+ *ppPixmap = pPixmap;
+ }
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+}
+
Bool
fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
{
- PixmapPtr pPixmap;
-
if (mask & CWBackPixmap)
{
if (pWin->backgroundState == BackgroundPixmap)
- {
- pPixmap = pWin->background.pixmap;
- if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
- {
- pPixmap = fb24_32ReformatTile (pPixmap,
- pWin->drawable.bitsPerPixel);
- if (pPixmap)
- {
- (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
- pWin->background.pixmap = pPixmap;
- }
- }
- if (FbEvenTile (pPixmap->drawable.width *
- pPixmap->drawable.bitsPerPixel))
- fbPadPixmap (pPixmap);
- }
+ fbFixupWindowPixmap(&pWin->drawable, &pWin->background.pixmap);
}
if (mask & CWBorderPixmap)
{
if (pWin->borderIsPixel == FALSE)
- {
- pPixmap = pWin->border.pixmap;
- if (pPixmap->drawable.bitsPerPixel !=
- pWin->drawable.bitsPerPixel)
- {
- pPixmap = fb24_32ReformatTile (pPixmap,
- pWin->drawable.bitsPerPixel);
- if (pPixmap)
- {
- (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
- pWin->border.pixmap = pPixmap;
- }
- }
- if (FbEvenTile (pPixmap->drawable.width *
- pPixmap->drawable.bitsPerPixel))
- fbPadPixmap (pPixmap);
- }
+ fbFixupWindowPixmap(&pWin->drawable, &pWin->border.pixmap);
}
return TRUE;
}
--
1.7.1
More information about the xorg-devel
mailing list