diff options
Diffstat (limited to 'src/sis_shadow.c')
-rw-r--r-- | src/sis_shadow.c | 312 |
1 files changed, 149 insertions, 163 deletions
diff --git a/src/sis_shadow.c b/src/sis_shadow.c index e2c4a11..3869f6e 100644 --- a/src/sis_shadow.c +++ b/src/sis_shadow.c @@ -1,4 +1,5 @@ /* $XFree86$ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.3 2004/06/17 13:20:14 twini Exp $ */ /* * Copyright (C) 1999-2004 by The XFree86 Project, Inc. * based on code written by Mark Vojkovich @@ -39,96 +40,88 @@ #include "sis_shadow.h" void +SISPointerMoved(int index, int x, int y) +{ + ScrnInfoPtr pScrn = xf86Screens[index]; + SISPtr pSiS = SISPTR(pScrn); + + if(pSiS->Rotate == 1) { + (*pSiS->PointerMoved)(index, pScrn->pScreen->height - y - 1, x); + } else { + (*pSiS->PointerMoved)(index, y, pScrn->pScreen->width - x - 1); + } +} + +void SISRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int width, height, Bpp, FBPitch; - unsigned char *src, *dst; + int width, height, Bpp, FBPitch; + CARD8 *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 = pSiS->ShadowPtr + (pbox->y1 * pSiS->ShadowPitch) + - (pbox->x1 * Bpp); - dst = pSiS->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); - - while(height--) { - memcpy(dst, src, width); - dst += FBPitch; - src += pSiS->ShadowPitch; - } + width = (pbox->x2 - pbox->x1) * Bpp; + height = pbox->y2 - pbox->y1; + src = pSiS->ShadowPtr + (pbox->y1 * pSiS->ShadowPitch) + (pbox->x1 * Bpp); + dst = pSiS->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); + + while(height--) { + memcpy(dst, src, width); + dst += FBPitch; + src += pSiS->ShadowPitch; + } - pbox++; + pbox++; } } void -SISPointerMoved(int index, int x, int y) -{ - ScrnInfoPtr pScrn = xf86Screens[index]; - SISPtr pSiS = SISPTR(pScrn); - int newX, newY; - - if(pSiS->Rotate == 1) { - newX = pScrn->pScreen->height - y - 1; - newY = x; - } else { - newX = y; - newY = pScrn->pScreen->width - x - 1; - } - - (*pSiS->PointerMoved)(index, newX, newY); -} - -void SISRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch; - CARD8 *dstPtr, *srcPtr, *src; + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; CARD32 *dst; dstPitch = pScrn->displayWidth; srcPitch = -pSiS->Rotate * pSiS->ShadowPitch; while(num--) { - width = pbox->x2 - pbox->x1; - y1 = pbox->y1 & ~3; - y2 = (pbox->y2 + 3) & ~3; - height = (y2 - y1) >> 2; /* in dwords */ - - if(pSiS->Rotate == 1) { - dstPtr = pSiS->FbBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = pSiS->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 += pSiS->Rotate; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* in dwords */ + + if(pSiS->Rotate == 1) { + dstPtr = pSiS->FbBase + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = pSiS->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 += pSiS->Rotate; + dstPtr += dstPitch; + } + + pbox++; } } - void SISRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { @@ -141,89 +134,86 @@ SISRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) srcPitch = -pSiS->Rotate * pSiS->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(pSiS->Rotate == 1) { - dstPtr = (CARD16*)pSiS->FbBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - y2; - srcPtr = (CARD16*)pSiS->ShadowPtr + - ((1 - y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD16*)pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; - srcPtr = (CARD16*)pSiS->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 += pSiS->Rotate; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~1; + y2 = (pbox->y2 + 1) & ~1; + height = (y2 - y1) >> 1; /* in dwords */ + + if(pSiS->Rotate == 1) { + dstPtr = (CARD16 *)pSiS->FbBase + (pbox->x1 * dstPitch) + pScrn->virtualX - y2; + srcPtr = (CARD16 *)pSiS->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD16 *)pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; + srcPtr = (CARD16 *)pSiS->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 += pSiS->Rotate; + dstPtr += dstPitch; + } + + pbox++; } } - /* this one could be faster */ void SISRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int count, width, height, y1, y2, dstPitch, srcPitch; - CARD8 *dstPtr, *srcPtr, *src; + int count, width, height, y1, y2, dstPitch, srcPitch; + CARD8 *dstPtr, *srcPtr, *src; CARD32 *dst; dstPitch = BitmapBytePad(pScrn->displayWidth * 24); srcPitch = -pSiS->Rotate * pSiS->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(pSiS->Rotate == 1) { - dstPtr = pSiS->FbBase + - (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); - srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); - } else { - dstPtr = pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); - srcPtr = pSiS->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 += pSiS->Rotate * 3; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + y1 = pbox->y1 & ~3; + y2 = (pbox->y2 + 3) & ~3; + height = (y2 - y1) >> 2; /* blocks of 3 dwords */ + + if(pSiS->Rotate == 1) { + dstPtr = pSiS->FbBase + (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); + srcPtr = pSiS->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); + } else { + dstPtr = pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); + srcPtr = pSiS->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 << 2); + } + srcPtr += pSiS->Rotate * 3; + dstPtr += dstPitch; + } + + pbox++; } } @@ -231,40 +221,36 @@ void SISRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { SISPtr pSiS = SISPTR(pScrn); - int count, width, height, dstPitch, srcPitch; + int count, width, height, dstPitch, srcPitch; CARD32 *dstPtr, *srcPtr, *src, *dst; dstPitch = pScrn->displayWidth; srcPitch = -pSiS->Rotate * pSiS->ShadowPitch >> 2; while(num--) { - width = pbox->x2 - pbox->x1; - height = pbox->y2 - pbox->y1; - - if(pSiS->Rotate == 1) { - dstPtr = (CARD32*)pSiS->FbBase + - (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; - srcPtr = (CARD32*)pSiS->ShadowPtr + - ((1 - pbox->y2) * srcPitch) + pbox->x1; - } else { - dstPtr = (CARD32*)pSiS->FbBase + - ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; - srcPtr = (CARD32*)pSiS->ShadowPtr + - (pbox->y1 * srcPitch) + pbox->x2 - 1; - } - - while(width--) { - src = srcPtr; - dst = dstPtr; - count = height; - while(count--) { - *(dst++) = *src; - src += srcPitch; - } - srcPtr += pSiS->Rotate; - dstPtr += dstPitch; - } - - pbox++; + width = pbox->x2 - pbox->x1; + height = pbox->y2 - pbox->y1; + + if(pSiS->Rotate == 1) { + dstPtr = (CARD32 *)pSiS->FbBase + (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; + srcPtr = (CARD32 *)pSiS->ShadowPtr + ((1 - pbox->y2) * srcPitch) + pbox->x1; + } else { + dstPtr = (CARD32 *)pSiS->FbBase + ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; + srcPtr = (CARD32 *)pSiS->ShadowPtr + (pbox->y1 * srcPitch) + pbox->x2 - 1; + } + + while(width--) { + src = srcPtr; + dst = dstPtr; + count = height; + while(count--) { + *(dst++) = *src; + src += srcPitch; + } + srcPtr += pSiS->Rotate; + dstPtr += dstPitch; + } + + pbox++; } } |