diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2006-11-26 20:11:54 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2006-11-26 20:11:54 +0000 |
commit | 04eb64ac3368815e6771321719f2c74ff135ef40 (patch) | |
tree | 687d09c83c54bee958d337614d4fb07cf3ecc851 /driver/xf86-video-savage/src/savage_shadow.c | |
parent | c242f9427187ed63205b55ff46c6d406095c130f (diff) |
Importing xf86-video-savage 2.1.2
Diffstat (limited to 'driver/xf86-video-savage/src/savage_shadow.c')
-rw-r--r-- | driver/xf86-video-savage/src/savage_shadow.c | 248 |
1 files changed, 248 insertions, 0 deletions
diff --git a/driver/xf86-video-savage/src/savage_shadow.c b/driver/xf86-video-savage/src/savage_shadow.c new file mode 100644 index 000000000..77d687d33 --- /dev/null +++ b/driver/xf86-video-savage/src/savage_shadow.c @@ -0,0 +1,248 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c,v 1.3 2000/03/31 20:13:33 dawes Exp $ */ + +/* + Copyright (c) 1999,2000 The XFree86 Project Inc. + based on code written by Mark Vojkovich <markv@valinux.com> +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "savage_driver.h" +#include "shadowfb.h" +#include "servermd.h" + + +void +SavageRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int width, height, Bpp, FBPitch; + unsigned char *src, *dst; + + Bpp = pScrn->bitsPerPixel >> 3; + FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); + + while(num--) { + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = psav->ShadowPtr + (pbox->y1 * psav->ShadowPitch) + + (pbox->x1 * Bpp); + dst = psav->FBStart + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + + while(height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += psav->ShadowPitch; + } + + pbox++; + } +} + + +void +SavagePointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + SavagePtr psav = SAVPTR(pScrn); + int newX, newY; + + if(psav->rotate == 1) { + newX = pScrn->pScreen->height - y - 1; + newY = x; + } else { + newX = y; + newY = pScrn->pScreen->width - x - 1; + } + + (*psav->PointerMoved)(index, newX, newY); +} + +void +SavageRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -psav->rotate * psav->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ + + if(psav->rotate == 1) { + dstPtr = psav->FBStart + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = psav->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = psav->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 8) | + (src[srcPitch * 2] << 16) | + (src[srcPitch * 3] << 24); + src += srcPitch * 4; + } + srcPtr += psav->rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +void +SavageRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD16 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -psav->rotate * psav->ShadowPitch >> 1; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + + if(psav->rotate == 1) { + dstPtr = (CARD16*)psav->FBStart + + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16*)psav->ShadowPtr + + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD16*)psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16*)psav->ShadowPtr + + (y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + *(dst++) = src[0] | (src[srcPitch] << 16); + src += srcPitch * 2; + } + srcPtr += psav->rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + + +/* this one could be faster */ +void +SavageRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; + CARD32 *dst; + + dstPitch = BitmapBytePad(pScrn->displayWidth * 24); + srcPitch = -psav->rotate * psav->ShadowPitch; + + while(num--) { + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + + if(psav->rotate == 1) { + dstPtr = psav->FBStart + + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = psav->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } else { + dstPtr = psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = psav->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; + } + + while(width--) { + src = srcPtr; + dst = (CARD32*)dstPtr; + count = height; + while(count--) { + dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | + (src[srcPitch] << 24); + dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | + (src[srcPitch * 2] << 16) | + (src[(srcPitch * 2) + 1] << 24); + dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | + (src[(srcPitch * 3) + 1] << 16) | + (src[(srcPitch * 3) + 2] << 24); + dst += 3; + src += srcPitch * 4; + } + srcPtr += psav->rotate * 3; + dstPtr += dstPitch; + } + + pbox++; + } +} + +void +SavageRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SavagePtr psav = SAVPTR(pScrn); + int count, width, height, dstPitch, srcPitch; + CARD32 *dstPtr, *srcPtr, *src, *dst; + + dstPitch = pScrn->displayWidth; + srcPitch = -psav->rotate * psav->ShadowPitch >> 2; + + while(num--) { + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(psav->rotate == 1) { + dstPtr = (CARD32*)psav->FBStart + + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32*)psav->ShadowPtr + + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD32*)psav->FBStart + + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32*)psav->ShadowPtr + + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while(count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += psav->rotate; + dstPtr += dstPitch; + } + + pbox++; + } +} + |