neo_shadow.c revision 2e71ea71
1 2/* 3 Copyright (c) 1999, 2000 The XFree86 Project Inc. 4 based on code written by Mark Vojkovich <markv@valinux.com> 5*/ 6 7#ifdef HAVE_CONFIG_H 8#include "config.h" 9#endif 10 11#include "xf86.h" 12#include "xf86_OSproc.h" 13#include "xf86PciInfo.h" 14#include "xf86Pci.h" 15#include "shadowfb.h" 16#include "servermd.h" 17#include "neo.h" 18 19void 20neoShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf) 21{ 22 RegionPtr damage = &pBuf->damage; 23 ScrnInfoPtr pScrn; 24 pScrn = xf86Screens[pScreen->myNum]; 25 26 (NEOPTR(pScrn))->refreshArea (pScrn, REGION_NUM_RECTS(damage), 27 REGION_RECTS(damage)); 28} 29 30void 31neoRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 32{ 33 NEOPtr nPtr = NEOPTR(pScrn); 34 int width, height, Bpp, FBPitch; 35 unsigned char *src, *dst; 36 37 Bpp = pScrn->bitsPerPixel >> 3; 38 FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); 39 40 while(num--) { 41 width = (pbox->x2 - pbox->x1) * Bpp; 42 height = pbox->y2 - pbox->y1; 43 src = nPtr->ShadowPtr + (pbox->y1 * nPtr->ShadowPitch) + 44 (pbox->x1 * Bpp); 45 dst = nPtr->NeoFbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); 46 47 while(height--) { 48 memcpy(dst, src, width); 49 dst += FBPitch; 50 src += nPtr->ShadowPitch; 51 } 52 53 pbox++; 54 } 55} 56 57void 58neoPointerMoved(int index, int x, int y) 59{ 60 ScrnInfoPtr pScrn = xf86Screens[index]; 61 NEOPtr nPtr = NEOPTR(pScrn); 62 int newX, newY; 63 64 if(nPtr->rotate == 1) { 65 newX = pScrn->pScreen->height - y - 1; 66 newY = x; 67 } else { 68 newX = y; 69 newY = pScrn->pScreen->width - x - 1; 70 } 71 72 (*nPtr->PointerMoved)(index, newX, newY); 73} 74 75void 76neoRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 77{ 78 NEOPtr nPtr = NEOPTR(pScrn); 79 int count, width, height, y1, y2, dstPitch, srcPitch; 80 CARD8 *dstPtr, *srcPtr, *src; 81 CARD32 *dst; 82 83 dstPitch = pScrn->displayWidth; 84 srcPitch = -nPtr->rotate * nPtr->ShadowPitch; 85 86 while(num--) { 87 width = pbox->x2 - pbox->x1; 88 y1 = pbox->y1 & ~3; 89 y2 = (pbox->y2 + 3) & ~3; 90 height = (y2 - y1) >> 2; /* in dwords */ 91 92 if(nPtr->rotate == 1) { 93 dstPtr = nPtr->NeoFbBase + 94 (pbox->x1 * dstPitch) + pScrn->virtualX - y2; 95 srcPtr = nPtr->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; 96 } else { 97 dstPtr = nPtr->NeoFbBase + 98 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; 99 srcPtr = nPtr->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; 100 } 101 102 while(width--) { 103 src = srcPtr; 104 dst = (CARD32*)dstPtr; 105 count = height; 106 while(count--) { 107 *(dst++) = src[0] | (src[srcPitch] << 8) | 108 (src[srcPitch * 2] << 16) | 109 (src[srcPitch * 3] << 24); 110 src += srcPitch * 4; 111 } 112 srcPtr += nPtr->rotate; 113 dstPtr += dstPitch; 114 } 115 116 pbox++; 117 } 118} 119 120 121void 122neoRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 123{ 124 NEOPtr nPtr = NEOPTR(pScrn); 125 int count, width, height, y1, y2, dstPitch, srcPitch; 126 CARD16 *dstPtr, *srcPtr, *src; 127 CARD32 *dst; 128 129 dstPitch = pScrn->displayWidth; 130 srcPitch = -nPtr->rotate * nPtr->ShadowPitch >> 1; 131 132 while(num--) { 133 width = pbox->x2 - pbox->x1; 134 y1 = pbox->y1 & ~1; 135 y2 = (pbox->y2 + 1) & ~1; 136 height = (y2 - y1) >> 1; /* in dwords */ 137 138 if(nPtr->rotate == 1) { 139 dstPtr = (CARD16*)nPtr->NeoFbBase + 140 (pbox->x1 * dstPitch) + pScrn->virtualX - y2; 141 srcPtr = (CARD16*)nPtr->ShadowPtr + 142 ((1 - y2) * srcPitch) + pbox->x1; 143 } else { 144 dstPtr = (CARD16*)nPtr->NeoFbBase + 145 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; 146 srcPtr = (CARD16*)nPtr->ShadowPtr + 147 (y1 * srcPitch) + pbox->x2 - 1; 148 } 149 150 while(width--) { 151 src = srcPtr; 152 dst = (CARD32*)dstPtr; 153 count = height; 154 while(count--) { 155 *(dst++) = src[0] | (src[srcPitch] << 16); 156 src += srcPitch * 2; 157 } 158 srcPtr += nPtr->rotate; 159 dstPtr += dstPitch; 160 } 161 162 pbox++; 163 } 164} 165 166 167/* this one could be faster */ 168void 169neoRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 170{ 171 NEOPtr nPtr = NEOPTR(pScrn); 172 int count, width, height, y1, y2, dstPitch, srcPitch; 173 CARD8 *dstPtr, *srcPtr, *src; 174 CARD32 *dst; 175 176 dstPitch = BitmapBytePad(pScrn->displayWidth * 24); 177 srcPitch = -nPtr->rotate * nPtr->ShadowPitch; 178 179 while(num--) { 180 width = pbox->x2 - pbox->x1; 181 y1 = pbox->y1 & ~3; 182 y2 = (pbox->y2 + 3) & ~3; 183 height = (y2 - y1) >> 2; /* blocks of 3 dwords */ 184 185 if(nPtr->rotate == 1) { 186 dstPtr = nPtr->NeoFbBase + 187 (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); 188 srcPtr = nPtr->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); 189 } else { 190 dstPtr = nPtr->NeoFbBase + 191 ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); 192 srcPtr = nPtr->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; 193 } 194 195 while(width--) { 196 src = srcPtr; 197 dst = (CARD32*)dstPtr; 198 count = height; 199 while(count--) { 200 dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | 201 (src[srcPitch] << 24); 202 dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | 203 (src[srcPitch * 2] << 16) | 204 (src[(srcPitch * 2) + 1] << 24); 205 dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | 206 (src[(srcPitch * 3) + 1] << 16) | 207 (src[(srcPitch * 3) + 2] << 24); 208 dst += 3; 209 src += srcPitch * 4; 210 } 211 srcPtr += nPtr->rotate * 3; 212 dstPtr += dstPitch; 213 } 214 215 pbox++; 216 } 217} 218 219void 220neoRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 221{ 222 NEOPtr nPtr = NEOPTR(pScrn); 223 int count, width, height, dstPitch, srcPitch; 224 CARD32 *dstPtr, *srcPtr, *src, *dst; 225 226 dstPitch = pScrn->displayWidth; 227 srcPitch = -nPtr->rotate * nPtr->ShadowPitch >> 2; 228 229 while(num--) { 230 width = pbox->x2 - pbox->x1; 231 height = pbox->y2 - pbox->y1; 232 233 if(nPtr->rotate == 1) { 234 dstPtr = (CARD32*)nPtr->NeoFbBase + 235 (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; 236 srcPtr = (CARD32*)nPtr->ShadowPtr + 237 ((1 - pbox->y2) * srcPitch) + pbox->x1; 238 } else { 239 dstPtr = (CARD32*)nPtr->NeoFbBase + 240 ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; 241 srcPtr = (CARD32*)nPtr->ShadowPtr + 242 (pbox->y1 * srcPitch) + pbox->x2 - 1; 243 } 244 245 while(width--) { 246 src = srcPtr; 247 dst = dstPtr; 248 count = height; 249 while(count--) { 250 *(dst++) = *src; 251 src += srcPitch; 252 } 253 srcPtr += nPtr->rotate; 254 dstPtr += dstPitch; 255 } 256 257 pbox++; 258 } 259} 260 261 262 263