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.6 2001/01/22 21:32:36 dawes 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->FbStart + (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;
67 dstPitch = pScrn->displayWidth;
68 srcPitch = -pNv->Rotate * pNv->ShadowPitch;
71 width = pbox->x2 - pbox->x1;
73 y2 = (pbox->y2 + 3) & ~3;
74 height = (y2 - y1) >> 2; /* in dwords */
76 if(pNv->Rotate == 1) {
77 dstPtr = pNv->FbStart +
78 (pbox->x1 * dstPitch) + pScrn->virtualX - y2;
79 srcPtr = pNv->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1;
81 dstPtr = pNv->FbStart +
82 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
83 srcPtr = pNv->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1;
88 dst = (CARD32*)dstPtr;
91 *(dst++) = src[0] | (src[srcPitch] << 8) |
92 (src[srcPitch * 2] << 16) |
93 (src[srcPitch * 3] << 24);
96 srcPtr += pNv->Rotate;
106 NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
108 NVPtr pNv = NVPTR(pScrn);
109 int count, width, height, y1, y2, dstPitch, srcPitch;
110 CARD16 *dstPtr, *srcPtr, *src;
113 dstPitch = pScrn->displayWidth;
114 srcPitch = -pNv->Rotate * pNv->ShadowPitch >> 1;
117 width = pbox->x2 - pbox->x1;
119 y2 = (pbox->y2 + 1) & ~1;
120 height = (y2 - y1) >> 1; /* in dwords */
122 if(pNv->Rotate == 1) {
123 dstPtr = (CARD16*)pNv->FbStart +
124 (pbox->x1 * dstPitch) + pScrn->virtualX - y2;
125 srcPtr = (CARD16*)pNv->ShadowPtr +
126 ((1 - y2) * srcPitch) + pbox->x1;
128 dstPtr = (CARD16*)pNv->FbStart +
129 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
130 srcPtr = (CARD16*)pNv->ShadowPtr +
131 (y1 * srcPitch) + pbox->x2 - 1;
136 dst = (CARD32*)dstPtr;
139 *(dst++) = src[0] | (src[srcPitch] << 16);
142 srcPtr += pNv->Rotate;
152 NVRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
154 NVPtr pNv = NVPTR(pScrn);
155 int count, width, height, dstPitch, srcPitch;
156 CARD32 *dstPtr, *srcPtr, *src, *dst;
158 dstPitch = pScrn->displayWidth;
159 srcPitch = -pNv->Rotate * pNv->ShadowPitch >> 2;
162 width = pbox->x2 - pbox->x1;
163 height = pbox->y2 - pbox->y1;
165 if(pNv->Rotate == 1) {
166 dstPtr = (CARD32*)pNv->FbStart +
167 (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2;
168 srcPtr = (CARD32*)pNv->ShadowPtr +
169 ((1 - pbox->y2) * srcPitch) + pbox->x1;
171 dstPtr = (CARD32*)pNv->FbStart +
172 ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1;
173 srcPtr = (CARD32*)pNv->ShadowPtr +
174 (pbox->y1 * srcPitch) + pbox->x2 - 1;
185 srcPtr += pNv->Rotate;