📄 cfbpixmap.c
字号:
if (width >= 32) return; if (pPixmap->devKind == PIXMAP_FRAME_BUFFER) stride = ((hpPrivPixmapPtr) pPixmap->devPrivate.ptr)->stride >> 2; else stride = 1; rep = 32/width; if (rep*width != 32) return; mask = masktab[width]; p = (unsigned int *)(((hpPrivPixmapPtr)(pPixmap->devPrivate.ptr))->bits); for (h=0; h < pPixmap->drawable.height; h++) { *p &= mask; bits = *p; for(i=1; i<rep; i++) {#if (BITMAP_BIT_ORDER == MSBFirst) bits >>= width;#else bits <<= width;#endif *p |= bits; } p += stride; } pPixmap->drawable.width = 32/(pPixmap->drawable.bitsPerPixel);}#ifdef notdef/* * cfb debugging routine -- assumes pixmap is 1 byte deep */static cfbdumppixmap(pPix) PixmapPtr pPix;{ unsigned int *pw; char *psrc, *pdst; int i, j; char line[66]; ErrorF( "pPixmap: 0x%x\n", pPix); ErrorF( "%d wide %d high\n", pPix->drawable.width, pPix->drawable.height); if (pPix->drawable.width > 64) { ErrorF( "too wide to see\n"); return; } pw = (unsigned int *) (((hpPrivPixmapPtr)(pPix->devPrivate.ptr))->bits; psrc = (char *) pw;/* for ( i=0; i<pPix->drawable.height; ++i ) ErrorF( "0x%x\n", pw[i] );*/ for ( i = 0; i < pPix->drawable.height; ++i ) { pdst = line; for(j = 0; j < pPix->drawable.width; j++) { *pdst++ = *psrc++ ? 'X' : ' ' ; } *pdst++ = '\n'; *pdst++ = '\0'; ErrorF( "%s", line); }}#endif /* notdef *//* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that * words are 32 bits wide, and that the least significant bit appears on the * left. */voidcfbXRotatePixmap(pPix, rw) PixmapPtr pPix; register int rw;{ register unsigned int *pw, *pwFinal; register unsigned int t; int rot; hpPrivPixmapPtr pPrivPix; int i; if (pPix == NullPixmap) return; switch (((DrawablePtr) pPix)->bitsPerPixel) { case PSZ: break; case 1: mfbXRotatePixmap(pPix, rw); return; default: ErrorF("cfbXRotatePixmap: unsupported bitsPerPixel %d\n", ((DrawablePtr) pPix)->bitsPerPixel); return; } pPrivPix = (hpPrivPixmapPtr) (pPix->devPrivate.ptr); pw = (unsigned int *) pPrivPix->bits; modulus (rw, (int) pPix->drawable.width, rot); if (rot == 0) return; if(pPix->drawable.width == PPW) { if (pPix->devKind == PIXMAP_HOST_MEMORY) { pwFinal = pw + pPix->drawable.height; while(pw < pwFinal) { t = *pw; *pw++ = SCRRIGHT(t, rot) | (SCRLEFT(t, (PPW-rot)) & cfbendtab[rot]); } } else /* PIXMAP_FRAME_BUFFER */ { int stride = pPrivPix->stride >> 2; SET_REGISTERS_FOR_WRITING(pPix->drawable.pScreen, ~0, GXcopy); for (i=0; i<pPix->drawable.height; i++, pw += stride) { t = *pw; *pw = SCRRIGHT(t, rot) | (SCRLEFT(t, (PPW-rot)) & cfbendtab[rot]); } } } else /* slow case */ { ErrorF("cfb internal error: trying to rotate odd-sized pixmap.\n");#ifdef notdef register unsigned int *pwTmp; int size, tsize; tsize = PixmapBytePad(pPix->drawable.width - rot, PSZ); pwTmp = (unsigned int *) ALLOCATE_LOCAL(pPix->drawable.height * tsize); if (!pwTmp) return; /* divide pw (the pixmap) in two vertically at (w - rot) and swap */ tsize >>= 2; size = pPix->devKind >> 2; cfbQuickBlt((int *)pw, (int *)pwTmp, 0, 0, 0, 0, (int)pPix->drawable.width - rot, (int)pPix->drawable.height, size, tsize); cfbQuickBlt((int *)pw, (int *)pw, (int)pPix->drawable.width - rot, 0, 0, 0, rot, (int)pPix->drawable.height, size, size); cfbQuickBlt((int *)pwTmp, (int *)pw, 0, 0, rot, 0, (int)pPix->drawable.width - rot, (int)pPix->drawable.height, tsize, size); DEALLOCATE_LOCAL(pwTmp);#endif }}/* Rotates pixmap pPix by h lines. Assumes that h is always less than pPix->drawable.height works on any width. */voidcfbYRotatePixmap(pPix, rh) register PixmapPtr pPix; int rh;{ int nbyDown; /* bytes to move down to row 0; also offset of row rh */ int nbyUp; /* bytes to move up to line rh; also offset of first line moved down to 0 */ char *pbase; char *ptmp; int rot; hpPrivPixmapPtr pPrivPix; if (pPix == NullPixmap) return; switch (((DrawablePtr) pPix)->bitsPerPixel) { case PSZ: break; case 1: mfbYRotatePixmap(pPix, rh); return; default: ErrorF("cfbYRotatePixmap: unsupported bitsPerPixel %d\n", ((DrawablePtr) pPix)->bitsPerPixel); return; } pPrivPix = (hpPrivPixmapPtr) (pPix->devPrivate.ptr); modulus (rh, (int) pPix->drawable.height, rot); if (rot == 0) return; if (pPix->devKind == PIXMAP_HOST_MEMORY) { pbase = (char *)pPrivPix->bits; nbyDown = rot * pPrivPix->stride; nbyUp = (pPrivPix->stride * pPix->drawable.height) - nbyDown; if(!(ptmp = (char *)ALLOCATE_LOCAL(nbyUp))) return; bcopy(pbase, ptmp, nbyUp); /* save the low rows */ bcopy(pbase+nbyUp, pbase, nbyDown); /* slide the top rows down */ bcopy(ptmp, pbase+nbyDown, nbyUp); /* move lower rows up to row rot */ DEALLOCATE_LOCAL(ptmp); } else /* PIXMAP_FRAME_BUFFER */ { /* o.k., divide the pixmap in two horizontally at (h - rh) * pick up the part on the top and make it the temp * pixmap. then pick up the part on the bottom and make it the top * of the original pixmap. now copy in the part saved in temp and * discard temp. All done. */ PixmapPtr pTemp; short realTemp = 0; if ((pPix->drawable.width > PRIV_PIX_WIDTH) || ((pPix->drawable.height - rot) > PRIV_PIX_HEIGHT)) { pTemp = (* pPix->drawable.pScreen->CreatePixmap) (pPix->drawable.pScreen, pPix->drawable.width, pPix->drawable.height - rot, pPix->drawable.depth); realTemp = 1; } else { /* use pre-allocated pixmap */ pTemp = (PixmapPtr) ((hpPrivScreen *) (pPix->drawable.pScreen->devPrivate))->pTmpPixmap; } if (pTemp->devKind == PIXMAP_FRAME_BUFFER) { register hpChunk *pixChunk; register hpChunk *tempChunk; register void (*bitMover)(); tempChunk = ((hpPrivPixmapPtr)(pTemp->devPrivate.ptr))->pChunk; pixChunk = pPrivPix->pChunk; bitMover = ((hpPrivScreenPtr) (pPix->drawable.pScreen->devPrivate))->MoveBits; (*bitMover)(pPix->drawable.pScreen, ~0, GXcopy, pixChunk->x, pixChunk->y, tempChunk->x, tempChunk->y, pPix->drawable.width, pPix->drawable.height - rot); (*bitMover)(pPix->drawable.pScreen, ~0, GXcopy, pixChunk->x, (pixChunk->y + pPix->drawable.height - rot), pixChunk->x, pixChunk->y, pPix->drawable.width, rot); (*bitMover)(pPix->drawable.pScreen, ~0, GXcopy, tempChunk->x, tempChunk->y, pixChunk->x, (pixChunk->y + rot), pPix->drawable.width, pPix->drawable.height - rot); if (realTemp) (* pPix->drawable.pScreen->DestroyPixmap)(pTemp); } else /* forced to use generic code */ { GCPtr pGC; CARD32 attribute; pGC = GetScratchGC(pPix->drawable.depth, pPix->drawable.pScreen); attribute = GXcopy; ChangeGC(pGC, GCFunction, &attribute, 1); ValidateGC(pTemp, pGC); (* pGC->ops->CopyArea)(pPix, pTemp, pGC, 0, 0, pPix->drawable.width, pPix->drawable.height - rot, 0, 0); ValidateGC(pPix, pGC); (* pGC->ops->CopyArea)(pPix, pPix, pGC, 0, pPix->drawable.height - rot, pPix->drawable.width, rot, 0, 0); (* pGC->ops->CopyArea)(pTemp, pPix, pGC, 0, 0, pPix->drawable.width, pPix->drawable.height - rot, 0, rot); (* pPix->drawable.pScreen->DestroyPixmap)(pTemp); FreeScratchGC(pGC); } }}voidcfbCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot) register PixmapPtr psrcPix, *ppdstPix; int xrot, yrot;{ register PixmapPtr pdstPix = *ppdstPix;#if 0 if (pdstPix && (pdstPix->devKind == psrcPix->devKind) && (pdstPix->drawable.height == psrcPix->drawable.height)) { bcopy((char *)psrcPix->devPrivate.ptr, (char *)pdstPix->devPrivate.ptr, psrcPix->drawable.height * psrcPix->devKind); pdstPix->drawable.width = psrcPix->drawable.width; pdstPix->drawable.depth = psrcPix->drawable.depth; pdstPix->drawable.bitsPerPixel = psrcPix->drawable.bitsPerPixel; pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER; } else#endif { if (pdstPix) cfbDestroyPixmap(pdstPix); *ppdstPix = pdstPix = cfbCopyPixmap(psrcPix); if (!pdstPix) return; } cfbPadPixmap(pdstPix); if (xrot) cfbXRotatePixmap(pdstPix, xrot); if (yrot) cfbYRotatePixmap(pdstPix, yrot);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -