ct_shadow.c revision c06b6b69
1/* $XFree86: Exp $ */ 2 3#ifdef HAVE_CONFIG_H 4#include "config.h" 5#endif 6 7#include "xf86.h" 8#include "xf86_OSproc.h" 9#include "xf86Resources.h" 10#include "xf86PciInfo.h" 11#include "xf86Pci.h" 12#include "shadowfb.h" 13#include "servermd.h" 14#include "ct_driver.h" 15 16void 17chipsRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 18{ 19 CHIPSPtr cPtr = CHIPSPTR(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 = cPtr->ShadowPtr + (pbox->y1 * cPtr->ShadowPitch) + 30 (pbox->x1 * Bpp); 31 dst = cPtr->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); 32 33 while(height--) { 34 memcpy(dst, src, width); 35 dst += FBPitch; 36 src += cPtr->ShadowPitch; 37 } 38 39 pbox++; 40 } 41} 42 43void 44chipsPointerMoved(int index, int x, int y) 45{ 46 ScrnInfoPtr pScrn = xf86Screens[index]; 47 CHIPSPtr cPtr = CHIPSPTR(pScrn); 48 int newX, newY; 49 50 if(cPtr->Rotate == 1) { 51 newX = pScrn->pScreen->height - y - 1; 52 newY = x; 53 } else { 54 newX = y; 55 newY = pScrn->pScreen->width - x - 1; 56 } 57 58 (*cPtr->PointerMoved)(index, newX, newY); 59} 60 61void 62chipsRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 63{ 64 CHIPSPtr cPtr = CHIPSPTR(pScrn); 65 int count, width, height, y1, y2, dstPitch, srcPitch; 66 CARD8 *dstPtr, *srcPtr, *src; 67 CARD32 *dst; 68 69 dstPitch = pScrn->displayWidth; 70 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch; 71 72 while(num--) { 73 width = pbox->x2 - pbox->x1; 74 y1 = pbox->y1 & ~3; 75 y2 = (pbox->y2 + 3) & ~3; 76 height = (y2 - y1) >> 2; /* in dwords */ 77 78 if(cPtr->Rotate == 1) { 79 dstPtr = cPtr->FbBase + 80 (pbox->x1 * dstPitch) + pScrn->virtualX - y2; 81 srcPtr = cPtr->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; 82 } else { 83 dstPtr = cPtr->FbBase + 84 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; 85 srcPtr = cPtr->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; 86 } 87 88 while(width--) { 89 src = srcPtr; 90 dst = (CARD32*)dstPtr; 91 count = height; 92 while(count--) { 93 *(dst++) = src[0] | (src[srcPitch] << 8) | 94 (src[srcPitch * 2] << 16) | 95 (src[srcPitch * 3] << 24); 96 src += srcPitch * 4; 97 } 98 srcPtr += cPtr->Rotate; 99 dstPtr += dstPitch; 100 } 101 102 pbox++; 103 } 104} 105 106 107void 108chipsRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 109{ 110 CHIPSPtr cPtr = CHIPSPTR(pScrn); 111 int count, width, height, y1, y2, dstPitch, srcPitch; 112 CARD16 *dstPtr, *srcPtr, *src; 113 CARD32 *dst; 114 115 dstPitch = pScrn->displayWidth; 116 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch >> 1; 117 118 while(num--) { 119 width = pbox->x2 - pbox->x1; 120 y1 = pbox->y1 & ~1; 121 y2 = (pbox->y2 + 1) & ~1; 122 height = (y2 - y1) >> 1; /* in dwords */ 123 124 if(cPtr->Rotate == 1) { 125 dstPtr = (CARD16*)cPtr->FbBase + 126 (pbox->x1 * dstPitch) + pScrn->virtualX - y2; 127 srcPtr = (CARD16*)cPtr->ShadowPtr + 128 ((1 - y2) * srcPitch) + pbox->x1; 129 } else { 130 dstPtr = (CARD16*)cPtr->FbBase + 131 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; 132 srcPtr = (CARD16*)cPtr->ShadowPtr + 133 (y1 * srcPitch) + pbox->x2 - 1; 134/* ErrorF("dst: %x base: %x\n",dstPtr,cPtr->FbBase);*/ 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 += cPtr->Rotate; 146 dstPtr += dstPitch; 147 } 148 149 pbox++; 150 } 151} 152 153 154/* this one could be faster */ 155void 156chipsRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 157{ 158 CHIPSPtr cPtr = CHIPSPTR(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 = -cPtr->Rotate * cPtr->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(cPtr->Rotate == 1) { 173 dstPtr = cPtr->FbBase + 174 (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); 175 srcPtr = cPtr->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); 176 } else { 177 dstPtr = cPtr->FbBase + 178 ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); 179 srcPtr = cPtr->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 += cPtr->Rotate * 3; 199 dstPtr += dstPitch; 200 } 201 202 pbox++; 203 } 204} 205 206void 207chipsRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 208{ 209 CHIPSPtr cPtr = CHIPSPTR(pScrn); 210 int count, width, height, dstPitch, srcPitch; 211 CARD32 *dstPtr, *srcPtr, *src, *dst; 212 213 dstPitch = pScrn->displayWidth; 214 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch >> 2; 215 216 while(num--) { 217 width = pbox->x2 - pbox->x1; 218 height = pbox->y2 - pbox->y1; 219 220 if(cPtr->Rotate == 1) { 221 dstPtr = (CARD32*)cPtr->FbBase + 222 (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; 223 srcPtr = (CARD32*)cPtr->ShadowPtr + 224 ((1 - pbox->y2) * srcPitch) + pbox->x1; 225 } else { 226 dstPtr = (CARD32*)cPtr->FbBase + 227 ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; 228 srcPtr = (CARD32*)cPtr->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 += cPtr->Rotate; 241 dstPtr += dstPitch; 242 } 243 244 pbox++; 245 } 246} 247