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