diff options
author | Eric Anholt <anholt@freebsd.org> | 2004-05-14 00:34:28 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2004-05-14 00:34:28 +0000 |
commit | 74b2a7694791297a4f798ecc05c7eb8f68634722 (patch) | |
tree | e80fe98bd75ca399b5020be87f4e90ace15f58e7 | |
parent | 2bea33e881693e7d7dcf938db79c888a71dfb2fb (diff) |
Add new flag, KAA_OFFSCREEN_ALIGN_POT, which tells KAA to align pixmap
pitches to a power-of-two number of bytes. Useful for Render
acceleration on older cards.
-rw-r--r-- | hw/kdrive/src/kaa.c | 19 | ||||
-rw-r--r-- | hw/kdrive/src/kaa.h | 1 | ||||
-rw-r--r-- | hw/kdrive/src/kdrive.h | 3 |
3 files changed, 20 insertions, 3 deletions
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c index 3059c1e57..86839d0da 100644 --- a/hw/kdrive/src/kaa.c +++ b/hw/kdrive/src/kaa.c @@ -95,6 +95,18 @@ kaaPixmapSave (ScreenPtr pScreen, KdOffscreenArea *area) } } +static int +kaaLog2(int val) +{ + int bits; + + if (!val) + return 0; + for (bits = 0; val != 0; bits++) + val >>= 1; + return bits - 1; +} + static Bool kaaPixmapAllocArea (PixmapPtr pPixmap) { @@ -105,7 +117,12 @@ kaaPixmapAllocArea (PixmapPtr pPixmap) int bpp = pPixmap->drawable.bitsPerPixel; CARD16 h = pPixmap->drawable.height; CARD16 w = pPixmap->drawable.width; - int pitch = KaaPixmapPitch (w * bpp / 8); + int pitch; + + if (pKaaScr->info->flags & KAA_OFFSCREEN_ALIGN_POT && w != 1) + w = 1 << (kaaLog2(w - 1) + 1); + pitch = (w * bpp / 8 + pKaaScr->info->offscreenPitch - 1) & + ~(pKaaScr->info->offscreenPitch - 1); pKaaPixmap->devKind = pPixmap->devKind; pKaaPixmap->devPrivate = pPixmap->devPrivate; diff --git a/hw/kdrive/src/kaa.h b/hw/kdrive/src/kaa.h index 5e4d1a315..c7491ab7a 100644 --- a/hw/kdrive/src/kaa.h +++ b/hw/kdrive/src/kaa.h @@ -33,7 +33,6 @@ #define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr)(p)->devPrivates[kaaPixmapPrivateIndex].ptr) #define KaaSetPixmapPriv(p,a) ((p)->devPrivates[kaaPixmapPrivateIndex].ptr = (pointer) (a)) #define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv(p) -#define KaaPixmapPitch(pitch) (((pitch) + (pKaaScr->info->offscreenPitch - 1)) & ~(pKaaScr->info->offscreenPitch - 1)) typedef struct { KaaScreenInfoPtr info; diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h index 5f937a5c9..7981c7e54 100644 --- a/hw/kdrive/src/kdrive.h +++ b/hw/kdrive/src/kdrive.h @@ -372,7 +372,8 @@ typedef struct _KaaScreenInfo { PixmapPtr pDst); } KaaScreenInfoRec, *KaaScreenInfoPtr; -#define KAA_OFFSCREEN_PIXMAPS (1 << 0) +#define KAA_OFFSCREEN_PIXMAPS (1 << 0) +#define KAA_OFFSCREEN_ALIGN_POT (1 << 1) /* * This is the only completely portable way to |