From 26c1801a27b81fdd988d5bd210ba0e76ecc274ae Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Mon, 21 Apr 2008 11:03:27 +0200 Subject: [PATCH] EXA: Update sys_pitch/fb_pitch in exaModifyPixmapHeader. exaModifyPixmapHeader now also only evaluates arguments that have a meaningful value. --- exa/exa.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/exa/exa.c b/exa/exa.c index 81dc3e2ab..0e3ea7036 100644 --- a/exa/exa.c +++ b/exa/exa.c @@ -248,6 +248,19 @@ exaSetAccelBlock(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap, pExaPixmap->accel_blocked |= EXA_RANGE_HEIGHT; } +static void +exaSetFbPitch(ExaScreenPrivPtr pExaScr, ExaPixmapPrivPtr pExaPixmap, + int w, int h, int bpp) +{ + if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1) + pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8; + else + pExaPixmap->fb_pitch = w * bpp / 8; + + pExaPixmap->fb_pitch = EXA_ALIGN(pExaPixmap->fb_pitch, + pExaScr->info->pixmapPitchAlign); +} + /** * exaCreatePixmap() creates a new pixmap. * @@ -292,12 +305,8 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, if (paddedWidth / 4 > 32767 || h > 32767) return NullPixmap; - if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1) - pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8; - else - pExaPixmap->fb_pitch = w * bpp / 8; - pExaPixmap->fb_pitch = EXA_ALIGN(pExaPixmap->fb_pitch, - pExaScr->info->pixmapPitchAlign); + exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp); + if (paddedWidth < pExaPixmap->fb_pitch) paddedWidth = pExaPixmap->fb_pitch; @@ -331,12 +340,7 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, pExaPixmap->offscreen = FALSE; pExaPixmap->fb_ptr = NULL; - if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1) - pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8; - else - pExaPixmap->fb_pitch = w * bpp / 8; - pExaPixmap->fb_pitch = EXA_ALIGN(pExaPixmap->fb_pitch, - pExaScr->info->pixmapPitchAlign); + exaSetFbPitch(pExaScr, pExaPixmap, w, h, bpp); pExaPixmap->fb_size = pExaPixmap->fb_pitch * h; if (pExaPixmap->fb_pitch > 131071) { @@ -384,10 +388,19 @@ exaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, pExaPixmap = ExaGetPixmapPriv(pPixmap); if (pExaPixmap) { - pExaPixmap->sys_ptr = pPixData; + if (pPixData) + pExaPixmap->sys_ptr = pPixData; - exaSetAccelBlock(pExaScr, pExaPixmap, - width, height, bitsPerPixel); + if (devKind > 0) + pExaPixmap->sys_pitch = devKind; + + if (width > 0 && height > 0 && bitsPerPixel > 0) { + exaSetFbPitch(pExaScr, pExaPixmap, + width, height, bitsPerPixel); + + exaSetAccelBlock(pExaScr, pExaPixmap, + width, height, bitsPerPixel); + } }