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