mfbfillsp.c

来自「早期freebsd实现」· C语言 代码 · 共 1,080 行 · 第 1/3 页

C
1,080 行
字号
            	    if ( ((ppt->x & 0x1f) + *pwidth) < 32)            	    {	            	maskpartialbits(ppt->x, *pwidth, startmask);			*addrl = DoMaskMergeRop (src, *addrl, startmask);            	    }            	    else            	    {	            	maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);	            	if (startmask)	            	{			    *addrl = DoMaskMergeRop (src, *addrl, startmask);		    	    addrl++;	            	}	            	while (nlmiddle--)	            	{			    *addrl = DoMergeRop (src, *addrl);		    	    addrl++;	            	}	            	if (endmask)			    *addrl = DoMaskMergeRop (src, *addrl, endmask);            	    }	    	}	    	pwidth++;	    	ppt++;	    }	}	break;    }    DEALLOCATE_LOCAL(pptFree);    DEALLOCATE_LOCAL(pwidthFree);}/* Fill spans with tiles that aren't 32 bits wide */voidmfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)DrawablePtr pDrawable;GC		*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;{    int		iline;		/* first line of tile to use */				/* next three parameters are post-clip */    int n;			/* number of spans to fill */    register DDXPointPtr ppt;	/* pointer to list of start points */    register int *pwidth;	/* pointer to list of n widths */    unsigned int *addrlBase;	/* pointer to start of bitmap */    int		 nlwidth;	/* width in longwords of bitmap */    register unsigned int *pdst;/* pointer to current word in bitmap */    register unsigned int *psrc;/* pointer to current word in tile */    register int nlMiddle;    register int rop, nstart;    unsigned int startmask;    PixmapPtr	pTile;		/* pointer to tile we want to fill with */    hpPrivPixmapPtr pPrivTile;    int		w, width, x, xSrc, ySrc, srcStartOver, nend;    int 	tlwidth, rem, tileWidth, tileHeight, endinc;    unsigned int      endmask, *psrcT;    int *pwidthFree;		/* copies of the pointers to free */    DDXPointPtr pptFree;    if (!(pGC->planemask & 1))	return;    n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->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(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,		    pptInit, pwidthInit, nInit, 		    ppt, pwidth, fSorted);    if (pGC->fillStyle == FillTiled)    {	pTile = pGC->tile.pixmap;	rop = pGC->alu;    }    else    {	pTile = pGC->stipple;	rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;    }    pPrivTile = (hpPrivPixmapPtr) pTile->devPrivate.ptr;    tlwidth = pPrivTile->stride >> 2;     xSrc = pDrawable->x;    ySrc = pDrawable->y;    if (pDrawable->type == DRAWABLE_WINDOW)    {	addrlBase = (unsigned int *) getPrivScreenPtr(pDrawable->pScreen)->bits;	nlwidth = (int) getPrivScreenPtr(pDrawable->pScreen)->stride >> 2;    }    else    {	addrlBase = (unsigned int *) getPrivPixmapPtr(pDrawable)->bits;	nlwidth = (int) getPrivPixmapPtr(pDrawable)->stride >> 2;    }    tileWidth = pTile->drawable.width;    tileHeight = pTile->drawable.height;    /* this replaces rotating the tile. Instead we just adjust the offset     * at which we start grabbing bits from the tile.     * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,     * so that iline and rem always stay within the tile bounds.     */    xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;    ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;    while (n--)    {	iline = (ppt->y - ySrc) % tileHeight;        pdst = addrlBase + (ppt->y * nlwidth) + (ppt->x >> 5);        psrcT = (unsigned int *) pPrivTile->bits + (iline * tlwidth);	x = ppt->x;	if (*pwidth)	{	    width = *pwidth;	    while(width > 0)	    {		psrc = psrcT;	        w = min(tileWidth, width);		if((rem = (x - xSrc)  % tileWidth) != 0)		{		    /* if we're in the middle of the tile, get		       as many bits as will finish the span, or		       as many as will get to the left edge of the tile,		       or a longword worth, starting at the appropriate		       offset in the tile.		    */		    w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_UNIT);		    endinc = rem / BITMAP_SCANLINE_UNIT;		    getandputrop((psrc+endinc), (rem&0x1f), (x & 0x1f), w, pdst, rop);		    if((x & 0x1f) + w >= 0x20)			pdst++;		}		else if(((x & 0x1f) + w) < 32)		{		    /* doing < 32 bits is easy, and worth special-casing */		    putbitsrop(*psrc, x & 0x1f, w, pdst, rop);		}		else		{		    /* start at the left edge of the tile,		       and put down as much as we can		    */		    maskbits(x, w, startmask, endmask, nlMiddle);	            if (startmask)		        nstart = 32 - (x & 0x1f);	            else		        nstart = 0;	            if (endmask)	                nend = (x + w)  & 0x1f;	            else		        nend = 0;	            srcStartOver = nstart > 31;		    if(startmask)		    {			putbitsrop(*psrc, (x & 0x1f), nstart, pdst, rop);			pdst++;			if(srcStartOver)			    psrc++;		    }		     		    while(nlMiddle--)		    {			    getandputrop0(psrc, nstart, 32, pdst, rop);			    pdst++;			    psrc++;		    }		    if(endmask)		    {			getandputrop0(psrc, nstart, nend, pdst, rop);		    }		 }		 x += w;		 width -= w;	    }	}	ppt++;	pwidth++;    }    DEALLOCATE_LOCAL(pptFree);    DEALLOCATE_LOCAL(pwidthFree);}/* Fill spans with stipples that aren't 32 bits wide */voidmfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)DrawablePtr pDrawable;GC		*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 */    register DDXPointPtr ppt;	/* pointer to list of start points */    register int *pwidth;	/* pointer to list of n widths */    int		iline;		/* first line of tile to use */    int		*addrlBase;	/* pointer to start of bitmap */    int		 nlwidth;	/* width in longwords of bitmap */    register int *pdst;		/* pointer to current word in bitmap */    register int *psrc;		/* pointer to current word in tile */    register int nlMiddle;    register int rop, nstart;    int startmask;    PixmapPtr	pTile;		/* pointer to tile we want to fill with */    hpPrivPixmapPtr pPrivTile;    int		w, width,  x, xSrc, ySrc, srcStartOver, nend;    int 	endmask, tlwidth, rem, tileWidth, *psrcT, endinc;    int		tileHeight;    int *pwidthFree;		/* copies of the pointers to free */    DDXPointPtr pptFree;    if (!(pGC->planemask & 1))	return;    n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->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(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip,		    pptInit, pwidthInit, nInit, 		    ppt, pwidth, fSorted);    pTile = pGC->stipple;    pPrivTile = (hpPrivPixmapPtr) pTile->devPrivate.ptr;    rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;    tlwidth = pPrivTile->stride >> 2;    xSrc = pDrawable->x;    ySrc = pDrawable->y;    if (pDrawable->type == DRAWABLE_WINDOW)    {	addrlBase = (int *) getPrivScreenPtr(pDrawable->pScreen)->bits;	nlwidth = (int) getPrivScreenPtr(pDrawable->pScreen)->stride >> 2;    }    else    {	addrlBase = (int *) getPrivPixmapPtr(pDrawable)->bits;	nlwidth = (int) getPrivPixmapPtr(pDrawable)->stride >> 2;    }    tileWidth = pTile->drawable.width;    tileHeight = pTile->drawable.height;    /* this replaces rotating the stipple.  Instead, we just adjust the offset     * at which we start grabbing bits from the stipple.     * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,     * so that iline and rem always stay within the tile bounds.     */    xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;    ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;    while (n--)    {	iline = (ppt->y - ySrc) % tileHeight;        pdst = addrlBase + (ppt->y * nlwidth) + (ppt->x >> 5);        psrcT = (int *) pPrivTile->bits + (iline * tlwidth);	x = ppt->x;	if (*pwidth)	{	    width = *pwidth;	    while(width > 0)	    {		psrc = psrcT;	        w = min(tileWidth, width);		if((rem = (x - xSrc) % tileWidth) != 0)		{		    /* if we're in the middle of the tile, get		       as many bits as will finish the span, or		       as many as will get to the left edge of the tile,		       or a longword worth, starting at the appropriate		       offset in the tile.		    */		    w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_UNIT);		    endinc = rem / BITMAP_SCANLINE_UNIT;		    getandputrrop((psrc + endinc), (rem & 0x1f), (x & 0x1f),				 w, pdst, rop)		    if((x & 0x1f) + w >= 0x20)			pdst++;		}		else if(((x & 0x1f) + w) < 32)		{		    /* doing < 32 bits is easy, and worth special-casing */		    putbitsrrop(*psrc, x & 0x1f, w, pdst, rop);		}		else		{		    /* start at the left edge of the tile,		       and put down as much as we can		    */		    maskbits(x, w, startmask, endmask, nlMiddle);	            if (startmask)		        nstart = 32 - (x & 0x1f);	            else		        nstart = 0;	            if (endmask)	                nend = (x + w)  & 0x1f;	            else		        nend = 0;	            srcStartOver = nstart > 31;		    if(startmask)		    {			putbitsrrop(*psrc, (x & 0x1f), nstart, pdst, rop);			pdst++;			if(srcStartOver)			    psrc++;		    }		     		    while(nlMiddle--)		    {			    getandputrrop0(psrc, nstart, 32, pdst, rop);			    pdst++;			    psrc++;		    }		    if(endmask)		    {			getandputrrop0(psrc, nstart, nend, pdst, rop);		    }		 }		 x += w;		 width -= w;	    }	}	ppt++;	pwidth++;    }    DEALLOCATE_LOCAL(pptFree);    DEALLOCATE_LOCAL(pwidthFree);}

⌨️ 快捷键说明

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