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

📄 cfbtileodd.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Fill odd tiled rectangles and spans. * no depth dependencies. *//*Copyright 1989 by the Massachusetts Institute of TechnologyPermission to use, copy, modify, and distribute this software and itsdocumentation for any purpose and without fee is hereby granted,provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear insupporting documentation, and that the name of M.I.T. not be used inadvertising or publicity pertaining to distribution of the softwarewithout specific, written prior permission.  M.I.T. makes norepresentations about the suitability of this software for anypurpose.  It is provided "as is" without express or implied warranty.*//* $XConsortium: cfbtileodd.c,v 1.13 91/07/10 17:26:10 keith Exp $ */#include "X.h"#include "Xmd.h"#include "servermd.h"#include "gcstruct.h"#include "window.h"#include "pixmapstr.h"#include "scrnintstr.h"#include "windowstr.h"#include "cfb.h"#include "cfbmskbits.h"#include "cfb8bit.h"#include "mergerop.h"#define LastTileBits {\    tmp = bits; \    if (tileEndPart) \	bits = (*pSrc & tileEndMask) | BitRight (*pSrcLine, tileEndLeftShift); \    else \	bits = *pSrc; \}#define ResetTileBits {\    pSrc = pSrcLine; \    nlwSrc = widthSrc;\    if (tileEndPart) { \	if (PPW - xoff + tileEndPart <= PPW) {\	    bits = *pSrc++; \	    nlwSrc--; \	} else \	    bits = BitLeft(tmp, tileEndLeftShift) | \		   BitRight(bits, tileEndRightShift); \	xoff = (xoff + xoffStep) & PIM; \	leftShift = xoff << (5-PWSH); \	rightShift = 32 - leftShift; \    }\}#define NextTileBits {\    if (nlwSrc == 1) {\	LastTileBits\    } else { \    	if (nlwSrc == 0) {\	    ResetTileBits\    	} \	if (nlwSrc == 1) {\	    LastTileBits\	} else {\	    tmp = bits; \	    bits = *pSrc++; \	}\    }\    nlwSrc--; \}voidMROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, planemask)    DrawablePtr	    pDrawable;    int		    nBox;	/* number of boxes to fill */    register BoxPtr pBox;	/* pointer to list of boxes to fill */    PixmapPtr	    tile;	/* tile */    int		    xrot, yrot;    int		    alu;    unsigned long   planemask;{    hpPrivPixmapPtr tilePriv;    int tileWidth;	/* width of tile in pixels */    int tileHeight;	/* height of the tile */    int widthSrc;    int strideSrc;    int widthDst;		/* width in longwords of the dest pixmap */    int w;		/* width of current box */    int h;		/* height of current box */    unsigned long startmask;    unsigned long endmask;	/* masks for reggedy bits at either end of line */    int nlwMiddle;	/* number of longwords between sides of boxes */    int nlwSrc;		/* number of whole longwords in source */        register int nlw;	/* loop version of nlwMiddle */    int srcy;		/* current tile y position */    int srcx;		/* current tile x position */    int xoffDst, xoffSrc;    int leftShift, rightShift;    MROP_DECLARE_REG()    unsigned long *pDstBase;	/* pointer to start of dest */    unsigned long *pDstLine;	/* poitner to start of dest box */    unsigned long *pSrcBase;	/* pointer to start of source */    unsigned long *pSrcLine;	/* pointer to start of source line */    register unsigned long *pDst;    register unsigned long *pSrc;    register unsigned long bits, tmp;    register int	   nlwPart;    int xoffStart, xoff;    int leftShiftStart, rightShiftStart, nlwSrcStart;    unsigned long tileEndMask;    int tileEndLeftShift, tileEndRightShift;    int	xoffStep;    int tileEndPart;    int needFirst;    unsigned long   narrow[2];    unsigned long   narrowMask;    int	    narrowShift;    Bool    narrowTile;    MROP_INITIALIZE (alu, planemask)    tileHeight = tile->drawable.height;    tileWidth = tile->drawable.width;    tilePriv = (hpPrivPixmapPtr)tile->devPrivate.ptr;    if (tile->devKind == PIXMAP_FRAME_BUFFER)        widthSrc = tilePriv->pChunk->w >> 2;    else        widthSrc = tilePriv->stride >> 2;    strideSrc = tilePriv->stride >> 2;    narrowTile = FALSE;    if (widthSrc == 1)    {	narrowShift = tileWidth;	narrowMask = cfbendpartial [tileWidth];	tileWidth *= 2;	widthSrc = 2;	narrowTile = TRUE;    }    pSrcBase = (unsigned long *)tilePriv->bits;    cfbGetLongWidthAndPointer (pDrawable, widthDst, pDstBase)    SET_REGISTERS_FOR_WRITING(pDrawable->pScreen, ~0, GXcopy);    if (tile->devKind == PIXMAP_FRAME_BUFFER)	WAIT_READY_TO_RENDER(tile->drawable.pScreen);    tileEndPart = tileWidth & PIM;    tileEndMask = cfbendpartial[tileEndPart];    tileEndLeftShift = (tileEndPart) << (5-PWSH);    tileEndRightShift = 32 - tileEndLeftShift;    xoffStep = PPW - tileEndPart;    /*     * current assumptions: tile > 32 bits wide.     */    while (nBox--)    {	w = pBox->x2 - pBox->x1;	h = pBox->y2 - pBox->y1;	modulus (pBox->x1 - xrot, tileWidth, srcx);	modulus (pBox->y1 - yrot, tileHeight, srcy);	xoffDst = pBox->x1 & PIM;	if (xoffDst + w < PPW)	{	    maskpartialbits(pBox->x1, w, startmask);	    endmask = 0;	    nlwMiddle = 0;	}	else	{	    maskbits (pBox->x1, w, startmask, endmask, nlwMiddle)	}	pDstLine = pDstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);	pSrcLine = pSrcBase + (srcy * strideSrc);	xoffSrc = srcx & PIM;	if (xoffSrc >= xoffDst)	{	    xoffStart = xoffSrc - xoffDst;	    needFirst = 1;	}	else	{	    xoffStart = PPW - (xoffDst - xoffSrc);	    needFirst = 0;	}	leftShiftStart = (xoffStart) << (5-PWSH);	rightShiftStart = 32 - leftShiftStart;	nlwSrcStart = widthSrc - (srcx >> PWSH);	while (h--)	{	    /* XXX only works when narrowShift >= PPW/2 */	    if (narrowTile)	    {		tmp = pSrcBase[srcy] & narrowMask; /* source width == 1 */		narrow[0] = tmp | SCRRIGHT (tmp, narrowShift);		narrow[1] = SCRLEFT (tmp, PPW - narrowShift) |			    SCRRIGHT(tmp, 2 * narrowShift - PPW);		pSrcLine = narrow;	    }	    xoff = xoffStart;	    leftShift = leftShiftStart;	    rightShift = rightShiftStart;	    nlwSrc = nlwSrcStart;	    pSrc = pSrcLine + (srcx >> PWSH);	    pDst = pDstLine;	    bits = 0;	    if (needFirst)	    {		NextTileBits	    }	    if (startmask)	    {		NextTileBits		tmp = BitLeft(tmp, leftShift); 		if (rightShift != 32)		    tmp |= BitRight(bits,rightShift);		*pDst = MROP_MASK (tmp, *pDst, startmask);		++pDst;	    }	    nlw = nlwMiddle;	    while (nlw)	    {#if MROP == Mcopy		if (nlwSrc > 1)		{		    nlwPart = nlw;		    if (nlwPart >= nlwSrc)			nlwPart = nlwSrc - 1;		    nlw -= nlwPart;		    nlwSrc -= nlwPart;		    if (rightShift != 32)		    {			while (nlwPart--)			{			    tmp = bits;			    bits = *pSrc++;			    *pDst = MROP_SOLID(BitLeft(tmp, leftShift) |					      BitRight (bits, rightShift),					      *pDst);			    ++pDst;			}		    }		    else		    {			if (nlwPart)			{			    *pDst = MROP_SOLID (bits, *pDst);			    ++pDst;			    nlwPart--;			    while (nlwPart--)			    {				*pDst = MROP_SOLID(*pSrc, *pDst);				++pDst; ++pSrc;			    }			    bits = *pSrc++;			}		    }		}		else#endif		{		    NextTileBits		    if (rightShift != 32)		    {			*pDst = MROP_SOLID(BitLeft(tmp, leftShift) |					   BitRight(bits, rightShift),					   *pDst);		    }		    else		    {			*pDst = MROP_SOLID (tmp, *pDst);		    }		    ++pDst;		    nlw--;		}	    }	    if (endmask)	    {		NextTileBits		if (rightShift == 32)		    bits = 0;		*pDst = MROP_MASK (BitLeft(tmp, leftShift) |				   BitRight(bits,rightShift),				   *pDst, endmask);	    }	    pDstLine += widthDst;	    pSrcLine += strideSrc;	    if (++srcy == tileHeight)	    {		srcy = 0;		pSrcLine = pSrcBase;	    }	}	pBox++;    }}voidMROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, planemask)    DrawablePtr	pDrawable;    int		n;    DDXPointPtr	ppt;    int		*pwidth;    PixmapPtr	tile;    int		xrot, yrot;    int		alu;    unsigned long   planemask;{    hpPrivPixmapPtr tilePriv;    int tileWidth;	/* width of tile in pixels */    int tileHeight;	/* height of the tile */    int widthSrc;    int strideSrc;    int widthDst;		/* width in longwords of the dest pixmap */    int w;		/* width of current span */    unsigned long startmask;    unsigned long endmask;	/* masks for reggedy bits at either end of line */    int nlwSrc;		/* number of whole longwords in source */        register int nlw;	/* loop version of nlwMiddle */    int srcy;		/* current tile y position */    int srcx;		/* current tile x position */    int xoffDst, xoffSrc;    int leftShift, rightShift;    MROP_DECLARE_REG()    unsigned long *pDstBase;	/* pointer to start of dest */    unsigned long *pDstLine;	/* poitner to start of dest box */    unsigned long *pSrcBase;	/* pointer to start of source */    unsigned long *pSrcLine;	/* pointer to start of source line */    register unsigned long *pDst;    register unsigned long *pSrc;    register unsigned long bits, tmp;    register int	   nlwPart;    int xoffStart, xoff;    int leftShiftStart, rightShiftStart, nlwSrcStart;    unsigned long tileEndMask;    int tileEndLeftShift, tileEndRightShift;    int	xoffStep;    int tileEndPart;    int needFirst;    unsigned long   narrow[2];    unsigned long   narrowMask;    int	    narrowShift;    Bool    narrowTile;    MROP_INITIALIZE (alu, planemask)    tileHeight = tile->drawable.height;    tileWidth = tile->drawable.width;    tilePriv = (hpPrivPixmapPtr)tile->devPrivate.ptr;    if (tile->devKind == PIXMAP_FRAME_BUFFER)	widthSrc = tilePriv->pChunk->w >> 2;    else	widthSrc = tilePriv->stride >> 2;    strideSrc = tilePriv->stride >> 2;    narrowTile = FALSE;    if (widthSrc == 1)    {	narrowShift = tileWidth;	narrowMask = cfbendpartial [tileWidth];	tileWidth *= 2;	widthSrc = 2;	narrowTile = TRUE;    }    pSrcBase = (unsigned long *)tilePriv->bits;    cfbGetLongWidthAndPointer (pDrawable, widthDst, pDstBase)    SET_REGISTERS_FOR_WRITING(pDrawable->pScreen, ~0, GXcopy);    if (tile->devKind == PIXMAP_FRAME_BUFFER)	WAIT_READY_TO_RENDER(tile->drawable.pScreen);    tileEndPart = tileWidth & PIM;    tileEndMask = cfbendpartial[tileEndPart];    tileEndLeftShift = (tileEndPart) << (5-PWSH);    tileEndRightShift = 32 - tileEndLeftShift;    xoffStep = PPW - tileEndPart;    while (n--)    {	w = *pwidth++;	modulus (ppt->x - xrot, tileWidth, srcx);	modulus (ppt->y - yrot, tileHeight, srcy);	xoffDst = ppt->x & PIM;	if (xoffDst + w < PPW)	{	    maskpartialbits(ppt->x, w, startmask);	    endmask = 0;	    nlw = 0;	}	else	{	    maskbits (ppt->x, w, startmask, endmask, nlw)	}	pDstLine = pDstBase + (ppt->y * widthDst) + (ppt->x >> PWSH);	pSrcLine = pSrcBase + (srcy * strideSrc);	xoffSrc = srcx & PIM;	if (xoffSrc >= xoffDst)	{	    xoffStart = xoffSrc - xoffDst;	    needFirst = 1;	}	else	{	    xoffStart = PPW - (xoffDst - xoffSrc);	    needFirst = 0;	}	leftShiftStart = (xoffStart) << (5-PWSH);	rightShiftStart = 32 - leftShiftStart;	nlwSrcStart = widthSrc - (srcx >> PWSH);	/* XXX only works when narrowShift >= PPW/2 */	if (narrowTile)	{	    tmp = pSrcBase[srcy] & narrowMask;	/* source width == 1 */	    narrow[0] = tmp | SCRRIGHT (tmp, narrowShift);	    narrow[1] = SCRLEFT (tmp, PPW - narrowShift) |			SCRRIGHT(tmp, 2 * narrowShift - PPW);	    pSrcLine = narrow;	}	xoff = xoffStart;	leftShift = leftShiftStart;	rightShift = rightShiftStart;	nlwSrc = nlwSrcStart;	pSrc = pSrcLine + (srcx >> PWSH);	pDst = pDstLine;	bits = 0;	if (needFirst)	{	    NextTileBits	}	if (startmask)	{	    NextTileBits	    tmp = BitLeft(tmp, leftShift);	    if (rightShift != 32)		tmp |= BitRight(bits,rightShift);	    *pDst = MROP_MASK (tmp, *pDst, startmask);	    ++pDst;	}	while (nlw)	{#if MROP == Mcopy	    if (nlwSrc > 1)	    {		nlwPart = nlw;		if (nlwPart >= nlwSrc)		    nlwPart = nlwSrc - 1;		nlw -= nlwPart;		nlwSrc -= nlwPart;		if (rightShift != 32)		{		    while (nlwPart--)		    {			tmp = bits;			bits = *pSrc++;			*pDst = MROP_SOLID(BitLeft(tmp, leftShift) |					  BitRight (bits, rightShift),					  *pDst);			++pDst;		    }		}		else		{		    if (nlwPart)		    {			*pDst = MROP_SOLID (bits, *pDst);			++pDst;			nlwPart--;			while (nlwPart--)			{			    *pDst = MROP_SOLID(*pSrc, *pDst);			    ++pDst; ++pSrc;			}			bits = *pSrc++;		    }		}	    }	    else#endif	    {		NextTileBits		if (rightShift != 32)		{		    *pDst = MROP_SOLID(BitLeft(tmp, leftShift) |				       BitRight(bits, rightShift),				       *pDst);		    ++pDst;		}		else		{		    *pDst = MROP_SOLID (tmp, *pDst);		    ++pDst;		}		nlw--;	    }	}	if (endmask)	{	    NextTileBits	    if (rightShift == 32)		bits = 0;	    *pDst = MROP_MASK (BitLeft(tmp, leftShift) |			       BitRight(bits,rightShift),			       *pDst, endmask);	}	ppt++;    }}# include "fastblt.h"#define IncSrcPtr   psrc++; if (!--srcRemaining) { srcRemaining = widthSrc; psrc = psrcStart; }MROP_NAME(cfbFillBoxTile32s) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, planemask)    DrawablePtr	    pDrawable;    int		    nBox;	/* number of boxes to fill */    register BoxPtr pBox;	/* pointer to list of boxes to fill */    PixmapPtr	    tile;	/* tile */    int		    xrot, yrot;    int		    alu;    unsigned long   planemask;{    hpPrivPixmapPtr tilePriv;    int	tileWidth;	/* width of tile */    int tileHeight;	/* height of the tile */    int	widthSrc;	/* width in longwords of the source tile */    int strideSrc;    int widthDst;	/* width in longwords of the dest pixmap */    int w;		/* width of current box */    int h;		/* height of current box */    unsigned long startmask;    unsigned long endmask;	/* masks for reggedy bits at either end of line */    int nlMiddle;	/* number of longwords between sides of boxes */        register int nl;	/* loop version of nlMiddle */    int srcy;		/* current tile y position */    int srcx;		/* current tile x position */    int	srcRemaining;	/* number of longwords remaining in source */    int xoffDst, xoffSrc;

⌨️ 快捷键说明

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