⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfbfillsp.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	x = ppt->x;	pdst = addrlBase + (ppt->y * nlwidth);        psrcS = (int *) pPrivStipple->bits + (iline * stwidth);	if (*pwidth)	{	    width = *pwidth;	    while(width > 0)	    {	        int xtemp, tmpx;		register unsigned int *ptemp;		register int *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;	        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, 32 - (x & 0x1f));	        xtemp = (xrem & 0x1f);	        ptemp = (unsigned int *)(psrcS + (xrem >> 5));		tmpx = x & PIM;		pdsttmp = pdst + (x>>PWSH);		switch ( pGC->fillStyle ) {		    case FillOpaqueStippled:			getstipplepixels(ptemp, xtemp, w, 0, &bgfill, &tmpDst1);			getstipplepixels(ptemp, xtemp, w, 1, &fgfill, &tmpDst2);			break;		    case FillStippled:			/* Fill tmpSrc with the source pixels */			getbits(pdsttmp, tmpx, w, tmpSrc);			getstipplepixels(ptemp, xtemp, w, 0, &tmpSrc, &tmpDst1);			if (rop != stiprop) {			    putbitsrop(fgfill, 0, w, &tmpSrc, pGC->planemask, stiprop);			} else {			    tmpSrc = fgfill;			}			getstipplepixels(ptemp, xtemp, w, 1, &tmpSrc, &tmpDst2);			break;		}		tmpDst2 |= tmpDst1;		putbitsrop(tmpDst2, tmpx, w, pdsttmp, pGC->planemask, rop);		x += w;		width -= w;	    }	}	ppt++;	pwidth++;    }    DEALLOCATE_LOCAL(pptFree);    DEALLOCATE_LOCAL(pwidthFree);}#endif /* PPW == 4 */#if PPW == 4voidcfb8Stipple32FS (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;    hpPrivPixmapPtr privStipple;    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 = (cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr;    cfb8CheckStipple (pGC->alu, pGC->fgPixel, pGC->planemask);    n = nInit * miFindMaxBand(devPriv->pCompositeClip);    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;    privStipple = (hpPrivPixmapPtr)(stipple->devPrivate.ptr);    src = (unsigned long *)privStipple->bits;    stippleHeight = stipple->drawable.height;    cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)    SET_REGISTERS_FOR_WRITING(pDrawable->pScreen, ~0, GXcopy);#if 0    /* stipples are depth 1 => never in frame buffer otherwise       would need to adjust bits calc below to allow for width of        frame buffer */    if (stipple->devKind == PIXMAP_FRAME_BUFFER)	WAIT_READY_TO_RENDER(stipple->drawable.pScreen);#endif    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 & (31 & ~3)));	if (cfb8StippleRRop == GXcopy)	{	    xor = devPriv->xor;	    if (w < 64)	    {		if (startmask)		{		    mask = cfb8PixelMasks[GetFourBits(bits)];		    *dst = (*dst & ~(mask & startmask)) |			   (xor & (mask & startmask));		    dst++;		    RotBitsLeft (bits, 4);		}		while (nlw--)		{		    WriteFourBits (dst,xor,GetFourBits(bits))		    dst++;		    RotBitsLeft (bits, 4);		}		if (endmask)		{		    mask = cfb8PixelMasks[GetFourBits(bits)];		    *dst = (*dst & ~(mask & endmask)) |			   (xor & (mask & endmask));		}	    }	    else	    {		wEnd = 7 - (nlw & 7);		nlw = (nlw >> 3) + 1;		dstTmp = dst;		nlwTmp = nlw;		if (startmask)		{		    mask = cfb8PixelMasks[GetFourBits(bits)];		    *dstTmp = (*dstTmp & ~(mask & startmask)) |			   (xor & (mask & startmask));		    dstTmp++;		    RotBitsLeft (bits, 4);		}		w = 7 - wEnd;		while (w--)		{		    dst = dstTmp;		    dstTmp++;		    nlw = nlwTmp;#if defined(__GNUC__) && defined(mc68020)		    mask = cfb8PixelMasks[GetFourBits(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;	\    }		    SwitchFourBits(dst, xor, GetFourBits(bits));#undef SwitchBitsLoop#endif		    NextFourBits (bits);		}		nlwTmp--;		w = wEnd + 1;		if (endmask)		{		    mask = cfb8PixelMasks[GetFourBits(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[GetFourBits(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;	\	}		    SwitchFourBits(dst, xor, GetFourBits(bits));#undef SwitchBitsLoop#endif		    NextFourBits (bits);		}	    }	}	else	{	    if (startmask)	    {		xor = GetFourBits(bits);		*dst = MaskRRopPixels(*dst, xor, startmask);		dst++;		RotBitsLeft (bits, 4);	    }	    while (nlw--)	    {		RRopFourBits(dst, GetFourBits(bits));		dst++;		RotBitsLeft (bits, 4);	    }	    if (endmask)	    {		xor = GetFourBits(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;    hpPrivPixmapPtr privStipple;    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 = (cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr;    cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel, pGC->planemask);    n = nInit * miFindMaxBand(devPriv->pCompositeClip);    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;    privStipple = (hpPrivPixmapPtr)(stipple->devPrivate.ptr);    src = (unsigned long *)privStipple->bits;    stippleHeight = stipple->drawable.height;    cfbGetLongWidthAndPointer (pDrawable, nlwDst, pbits)    SET_REGISTERS_FOR_WRITING(pDrawable->pScreen, ~0, GXcopy);#if 0    /* stipples are depth 1 => never in frame buffer otherwise       would need to adjust bits calc below to allow for width of        frame buffer */    if (stipple->devKind == PIXMAP_FRAME_BUFFER)	WAIT_READY_TO_RENDER(stipple->drawable.pScreen);#endif    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 & (31 & ~3)));	if (cfb8StippleRRop == GXcopy)	{	    xor = devPriv->xor;	    if (w < 64)	    {		if (startmask)		{		    *dst = *dst & ~startmask |			    GetFourPixels (bits) & startmask;		    dst++;		    RotBitsLeft (bits, 4);		}		while (nlw--)		{		    *dst++ = GetFourPixels(bits);		    RotBitsLeft (bits, 4);		}		if (endmask)		{		    *dst = *dst & ~endmask |			  GetFourPixels (bits) & endmask;		}	    }	    else	    {		wEnd = 7 - (nlw & 7);		nlw = (nlw >> 3) + 1;		dstTmp = dst;		nlwTmp = nlw;		if (startmask)		{		    *dstTmp = *dstTmp & ~startmask |			   GetFourPixels (bits) & startmask;		    dstTmp++;		    RotBitsLeft (bits, 4);		}		w = 7 - wEnd;		while (w--)		{		    nlw = nlwTmp;		    dst = dstTmp;		    dstTmp++;		    xor = GetFourPixels (bits);		    while (nlw--)		    {			*dst = xor;			dst += 8;		    }		    NextFourBits (bits);		}		nlwTmp--;		w = wEnd + 1;		if (endmask)		{		    dst = dstTmp + (nlwTmp << 3);		    *dst = (*dst & ~endmask) |			   GetFourPixels (bits) & endmask;		}		while (w--)		{		    nlw = nlwTmp;		    dst = dstTmp;		    dstTmp++;		    xor = GetFourPixels (bits);		    while (nlw--)		    {			*dst = xor;			dst += 8;		    }		    NextFourBits (bits);		}	    }	}	else	{	    if (startmask)	    {		xor = GetFourBits(bits);		*dst = MaskRRopPixels(*dst, xor, startmask);		dst++;		RotBitsLeft (bits, 4);	    }	    while (nlw--)	    {		RRopFourBits(dst, GetFourBits(bits));		dst++;		RotBitsLeft (bits, 4);	    }	    if (endmask)	    {		xor = GetFourBits(bits);		*dst = MaskRRopPixels(*dst, xor, endmask);	    }	}    }    DEALLOCATE_LOCAL(pptFree);    DEALLOCATE_LOCAL(pwidthFree);}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -