📄 cfbfillsp.c
字号:
{ iline = (ppt->y - ySrc) % stippleHeight; x = ppt->x; pdst = addrlBase + (ppt->y * nlwidth); psrcS = (unsigned long *) pStipple->devPrivate.ptr + (iline * stwidth); if (*pwidth) { width = *pwidth; while(width > 0) { int xtemp, tmpx; register unsigned long *ptemp; register unsigned long *pdsttmp; /* * Do a stripe through the stipple & destination w pixels * wide. w is not more than: * - the width of the destination * - the width of the stipple * - the distance between x and the next word * boundary in the destination * - the distance between x and the next word * boundary in the stipple */ /* width of dest/stipple */ xrem = (x - xSrc) % stippleWidth;#if PSZ == 24 w = 1;#else w = min((stippleWidth - xrem), width); /* dist to word bound in dest */ w = min(w, PPW - (x & PIM)); /* dist to word bound in stip */ w = min(w, MFB_PPW - (x & MFB_PIM));#endif xtemp = (xrem & MFB_PIM); ptemp = (unsigned long *)(psrcS + (xrem >> MFB_PWSH));#if PSZ == 24 tmpx = x & 3; pdsttmp = pdst + ((x * 3)>>2);#else tmpx = x & PIM; pdsttmp = pdst + (x>>PWSH);#endif switch ( pGC->fillStyle ) { case FillOpaqueStippled:#if PSZ == 24 getstipplepixels24(ptemp, xtemp, 0, &bgfill, &tmpDst1, xrem); getstipplepixels24(ptemp, xtemp, 1, &fgfill, &tmpDst2, xrem);#else getstipplepixels(ptemp, xtemp, w, 0, &bgfill, &tmpDst1); getstipplepixels(ptemp, xtemp, w, 1, &fgfill, &tmpDst2);#endif break; case FillStippled: /* Fill tmpSrc with the source pixels */#if PSZ == 24 getbits24(pdsttmp, tmpSrc, x); getstipplepixels24(ptemp, xtemp, 0, &tmpSrc, &tmpDst1, xrem);#else getbits(pdsttmp, tmpx, w, tmpSrc); getstipplepixels(ptemp, xtemp, w, 0, &tmpSrc, &tmpDst1);#endif if (rop != stiprop) {#if PSZ == 24 putbitsrop24(fgfill, 0, &tmpSrc, pGC->planemask, stiprop);#else putbitsrop(fgfill, 0, w, &tmpSrc, pGC->planemask, stiprop);#endif } else { tmpSrc = fgfill; }#if PSZ == 24 getstipplepixels24(ptemp, xtemp, 1, &tmpSrc, &tmpDst2, xrem);#else getstipplepixels(ptemp, xtemp, w, 1, &tmpSrc, &tmpDst2);#endif break; } tmpDst2 |= tmpDst1;#if PSZ == 24 putbitsrop24(tmpDst2, tmpx, pdsttmp, pGC->planemask, rop);#else putbitsrop(tmpDst2, tmpx, w, pdsttmp, pGC->planemask, rop);#endif x += w; width -= w; } } ppt++; pwidth++; } DEALLOCATE_LOCAL(pptFree); DEALLOCATE_LOCAL(pwidthFree);}#endif /* PSZ == 8 */#if PSZ == 8voidcfb8Stipple32FS (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ /* next three parameters are post-clip */ int n; /* number of spans to fill */ DDXPointPtr ppt; /* pointer to list of start points */ int *pwidth; /* pointer to list of n widths */ unsigned long *src; /* pointer to bits in stipple, if needed */ int stippleHeight; /* height of the stipple */ PixmapPtr stipple; int nlwDst; /* width in longwords of the dest pixmap */ int x,y,w; /* current span */ unsigned long startmask; unsigned long endmask; register unsigned long *dst; /* pointer to bits we're writing */ register int nlw; unsigned long *dstTmp; int nlwTmp; unsigned long *pbits; /* pointer to start of pixmap */ register unsigned long xor; register unsigned long mask; register unsigned long bits; /* bits from stipple */ int wEnd; int *pwidthFree; /* copies of the pointers to free */ DDXPointPtr pptFree; cfbPrivGCPtr devPriv; devPriv = cfbGetGCPrivate(pGC); cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask); n = nInit * miFindMaxBand(devPriv->pCompositeClip); if ( n == 0 ) return; pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); if(!pptFree || !pwidthFree) { if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); return; } pwidth = pwidthFree; ppt = pptFree; n = miClipSpans(devPriv->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted); stipple = devPriv->pRotatedPixmap; src = (unsigned long *)stipple->devPrivate.ptr; stippleHeight = stipple->drawable.height; cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits) while (n--) { w = *pwidth++; x = ppt->x; y = ppt->y; ppt++; dst = pbits + (y * nlwDst) + (x >> PWSH); if (((x & PIM) + w) <= PPW) { maskpartialbits(x, w, startmask); endmask = 0; nlw = 0; } else { maskbits (x, w, startmask, endmask, nlw); } bits = src[y % stippleHeight]; RotBitsLeft (bits, (x & ((PGSZ-1) & ~PIM)));#if PPW == 4 if (cfb8StippleRRop == GXcopy) { xor = devPriv->xor; if (w < (PGSZ*2)) { if (startmask) { mask = cfb8PixelMasks[GetBitGroup(bits)]; *dst = (*dst & ~(mask & startmask)) | (xor & (mask & startmask)); dst++; RotBitsLeft (bits, PGSZB); } while (nlw--) { WriteBitGroup (dst,xor,GetBitGroup(bits)) dst++; RotBitsLeft (bits, PGSZB); } if (endmask) { mask = cfb8PixelMasks[GetBitGroup(bits)]; *dst = (*dst & ~(mask & endmask)) | (xor & (mask & endmask)); } } else { /* XXX constants probably not OK here */ wEnd = 7 - (nlw & 7); nlw = (nlw >> 3) + 1; dstTmp = dst; nlwTmp = nlw; if (startmask) { mask = cfb8PixelMasks[GetBitGroup(bits)]; *dstTmp = (*dstTmp & ~(mask & startmask)) | (xor & (mask & startmask)); dstTmp++; RotBitsLeft (bits, PGSZB); } w = 7 - wEnd; while (w--) { dst = dstTmp; dstTmp++; nlw = nlwTmp;#if defined(__GNUC__) && defined(mc68020) mask = cfb8PixelMasks[GetBitGroup(bits)]; xor = xor & mask; mask = ~mask; while (nlw--) { *dst = (*dst & mask) | xor; dst += 8; } xor = devPriv->xor;#else#define SwitchBitsLoop(body) \ while (nlw--) \ { \ body \ dst += 8; \ } SwitchBitGroup(dst, xor, GetBitGroup(bits));#undef SwitchBitsLoop#endif NextBitGroup (bits); } nlwTmp--; w = wEnd + 1; if (endmask) { mask = cfb8PixelMasks[GetBitGroup(bits)]; dst = dstTmp + (nlwTmp << 3); *dst = (*dst & ~(mask & endmask)) | (xor & (mask & endmask)); } while (w--) { nlw = nlwTmp; dst = dstTmp; dstTmp++;#if defined(__GNUC__) && defined(mc68020) mask = cfb8PixelMasks[GetBitGroup(bits)]; xor = xor & mask; mask = ~mask; while (nlw--) { *dst = (*dst & mask) | xor; dst += 8; } xor = devPriv->xor;#else#define SwitchBitsLoop(body) \ while (nlw--) \ { \ body \ dst += 8; \ } SwitchBitGroup(dst, xor, GetBitGroup(bits));#undef SwitchBitsLoop#endif NextBitGroup (bits); } } } else#endif /* PPW == 4 */ { if (startmask) { xor = GetBitGroup(bits); *dst = MaskRRopPixels(*dst, xor, startmask); dst++; RotBitsLeft (bits, PGSZB); } while (nlw--) { RRopBitGroup(dst, GetBitGroup(bits)); dst++; RotBitsLeft (bits, PGSZB); } if (endmask) { xor = GetBitGroup(bits); *dst = MaskRRopPixels(*dst, xor, endmask); } } } DEALLOCATE_LOCAL(pptFree); DEALLOCATE_LOCAL(pwidthFree);}voidcfb8OpaqueStipple32FS (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ /* next three parameters are post-clip */ int n; /* number of spans to fill */ DDXPointPtr ppt; /* pointer to list of start points */ int *pwidth; /* pointer to list of n widths */ unsigned long *src; /* pointer to bits in stipple, if needed */ int stippleHeight; /* height of the stipple */ PixmapPtr stipple; int nlwDst; /* width in longwords of the dest pixmap */ int x,y,w; /* current span */ unsigned long startmask; unsigned long endmask; register unsigned long *dst; /* pointer to bits we're writing */ register int nlw; unsigned long *dstTmp; int nlwTmp; unsigned long *pbits; /* pointer to start of pixmap */ register unsigned long xor; register unsigned long mask; register unsigned long bits; /* bits from stipple */ int wEnd; int *pwidthFree; /* copies of the pointers to free */ DDXPointPtr pptFree; cfbPrivGCPtr devPriv; devPriv = cfbGetGCPrivate(pGC); cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask); n = nInit * miFindMaxBand(devPriv->pCompositeClip); if ( n == 0 ) return; pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); if(!pptFree || !pwidthFree) { if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); return; } pwidth = pwidthFree; ppt = pptFree; n = miClipSpans(devPriv->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted); stipple = devPriv->pRotatedPixmap; src = (unsigned long *)stipple->devPrivate.ptr; stippleHeight = stipple->drawable.height; cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits) while (n--) { w = *pwidth++; x = ppt->x; y = ppt->y; ppt++; dst = pbits + (y * nlwDst) + (x >> PWSH); if (((x & PIM) + w) <= PPW) { maskpartialbits(x, w, startmask); endmask = 0; nlw = 0; } else { maskbits (x, w, startmask, endmask, nlw); } bits = src[y % stippleHeight]; RotBitsLeft (bits, (x & ((PGSZ-1) & ~PIM)));#if PPW == 4 if (cfb8StippleRRop == GXcopy) { xor = devPriv->xor; if (w < PGSZ*2) { if (startmask) { *dst = *dst & ~startmask | GetPixelGroup (bits) & startmask; dst++; RotBitsLeft (bits, PGSZB); } while (nlw--) { *dst++ = GetPixelGroup(bits); RotBitsLeft (bits, PGSZB); } if (endmask) { *dst = *dst & ~endmask | GetPixelGroup (bits) & endmask; } } else { /* XXX consts probably not OK here */ wEnd = 7 - (nlw & 7); nlw = (nlw >> 3) + 1; dstTmp = dst; nlwTmp = nlw; if (startmask) { *dstTmp = *dstTmp & ~startmask | GetPixelGroup (bits) & startmask; dstTmp++; RotBitsLeft (bits, PGSZB); } w = 7 - wEnd; while (w--) { nlw = nlwTmp; dst = dstTmp; dstTmp++; xor = GetPixelGroup (bits); while (nlw--) { *dst = xor; dst += 8; } NextBitGroup (bits); } nlwTmp--; w = wEnd + 1; if (endmask) { dst = dstTmp + (nlwTmp << 3); *dst = (*dst & ~endmask) | GetPixelGroup (bits) & endmask; } while (w--) { nlw = nlwTmp; dst = dstTmp; dstTmp++; xor = GetPixelGroup (bits); while (nlw--) { *dst = xor; dst += 8; } NextBitGroup (bits); } } } else#endif /* PPW == 4 */ { if (startmask) { xor = GetBitGroup(bits); *dst = MaskRRopPixels(*dst, xor, startmask); dst++; RotBitsLeft (bits, PGSZB); } while (nlw--) { RRopBitGroup(dst, GetBitGroup(bits)); dst++; RotBitsLeft (bits, PGSZB); } if (endmask) { xor = GetBitGroup(bits); *dst = MaskRRopPixels(*dst, xor, endmask); } } } DEALLOCATE_LOCAL(pptFree); DEALLOCATE_LOCAL(pwidthFree);}#endif /* PSZ == 8 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -