2 Copyright (c) 1999, The XFree86 Project Inc.
3 Written by Mark Vojkovich <markv@valinux.com>
5 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c,v 1.5 2000/03/13 18:49:29 mvojkovi Exp $ */
8 #include "nv_include.h"
15 NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
17 NVPtr pNv = NVPTR(pScrn);
18 int width, height, Bpp, FBPitch;
19 unsigned char *src, *dst;
21 Bpp = pScrn->bitsPerPixel >> 3;
22 FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel);
25 width = (pbox->x2 - pbox->x1) * Bpp;
26 height = pbox->y2 - pbox->y1;
27 src = pNv->ShadowPtr + (pbox->y1 * pNv->ShadowPitch) +
29 dst = pNv->FB->map + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp);
32 memcpy(dst, src, width);
34 src += pNv->ShadowPitch;
42 NVPointerMoved(int index, int x, int y)
44 ScrnInfoPtr pScrn = xf86Screens[index];
45 NVPtr pNv = NVPTR(pScrn);
48 if(pNv->Rotate == 1) {
49 newX = pScrn->pScreen->height - y - 1;
53 newY = pScrn->pScreen->width - x - 1;
56 (*pNv->PointerMoved)(index, newX, newY);
60 NVRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
62 NVPtr pNv = NVPTR(pScrn);
63 int count, width, height, y1, y2, dstPitch, srcPitch;
64 CARD8 *dstPtr, *srcPtr, *src;
68 NVRefreshArea(pScrn, num, pbox);
72 dstPitch = pScrn->displayWidth;
73 srcPitch = -pNv->Rotate * pNv->ShadowPitch;
76 width = pbox->x2 - pbox->x1;
78 y2 = (pbox->y2 + 3) & ~3;
79 height = (y2 - y1) >> 2; /* in dwords */
81 if(pNv->Rotate == 1) {
82 dstPtr = pNv->FB->map +
83 (pbox->x1 * dstPitch) + pScrn->virtualX - y2;
84 srcPtr = pNv->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1;
86 dstPtr = pNv->FB->map +
87 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
88 srcPtr = pNv->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1;
93 dst = (CARD32*)dstPtr;
96 *(dst++) = src[0] | (src[srcPitch] << 8) |
97 (src[srcPitch * 2] << 16) |
98 (src[srcPitch * 3] << 24);
101 srcPtr += pNv->Rotate;
111 NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
113 NVPtr pNv = NVPTR(pScrn);
114 int count, width, height, y1, y2, dstPitch, srcPitch;
115 CARD16 *dstPtr, *srcPtr, *src;
119 NVRefreshArea(pScrn, num, pbox);
123 dstPitch = pScrn->displayWidth;
124 srcPitch = -pNv->Rotate * pNv->ShadowPitch >> 1;
127 width = pbox->x2 - pbox->x1;
129 y2 = (pbox->y2 + 1) & ~1;
130 height = (y2 - y1) >> 1; /* in dwords */
132 if(pNv->Rotate == 1) {
133 dstPtr = (CARD16*)pNv->FB->map +
134 (pbox->x1 * dstPitch) + pScrn->virtualX - y2;
135 srcPtr = (CARD16*)pNv->ShadowPtr +
136 ((1 - y2) * srcPitch) + pbox->x1;
138 dstPtr = (CARD16*)pNv->FB->map +
139 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
140 srcPtr = (CARD16*)pNv->ShadowPtr +
141 (y1 * srcPitch) + pbox->x2 - 1;
146 dst = (CARD32*)dstPtr;
149 *(dst++) = src[0] | (src[srcPitch] << 16);
152 srcPtr += pNv->Rotate;
162 NVRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
164 NVPtr pNv = NVPTR(pScrn);
165 int count, width, height, dstPitch, srcPitch;
166 CARD32 *dstPtr, *srcPtr, *src, *dst;
169 NVRefreshArea(pScrn, num, pbox);
173 dstPitch = pScrn->displayWidth;
174 srcPitch = -pNv->Rotate * pNv->ShadowPitch >> 2;
177 width = pbox->x2 - pbox->x1;
178 height = pbox->y2 - pbox->y1;
180 if(pNv->Rotate == 1) {
181 dstPtr = (CARD32*)pNv->FB->map +
182 (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2;
183 srcPtr = (CARD32*)pNv->ShadowPtr +
184 ((1 - pbox->y2) * srcPitch) + pbox->x1;
186 dstPtr = (CARD32*)pNv->FB->map +
187 ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1;
188 srcPtr = (CARD32*)pNv->ShadowPtr +
189 (pbox->y1 * srcPitch) + pbox->x2 - 1;
200 srcPtr += pNv->Rotate;