summaryrefslogtreecommitdiff
path: root/fb
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2011-03-31 15:33:46 +1000
committerDave Airlie <airlied@redhat.com>2011-04-01 11:02:17 +1000
commitf9834d312e3059073e8ad77d9f9d57cb9d96e1e5 (patch)
tree6cc2085e00931e89e91eb13acf52485dcd1ea63f /fb
parent36c7158133660520034d645b124c2c973d2971bb (diff)
fb: cleanup fbChangeWindowAttributes
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@redhat.com> Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Diffstat (limited to 'fb')
-rw-r--r--fb/fbwindow.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index d01e6d44d..7906f8dd2 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -146,51 +146,36 @@ fbCopyWindow(WindowPtr pWin,
fbValidateDrawable (&pWin->drawable);
}
+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;
}