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

📄 cfb8line.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	    {# ifndef POLYSEGMENT		t = addrb + x1_or_len;# else		if (capStyle)		    x1_or_len++;# endif	    }	    y1_or_e1 = ((int) addrb) & 3;	    addrb = addrb - y1_or_e1;	    if (y1_or_e1 + x1_or_len <= PPW)	    {		if (x1_or_len)		{		    maskpartialbits(y1_or_e1, x1_or_len, e)		    RROP_SOLID_MASK((int *) addrb, e);		}	    }	    else	    {	    	maskbits(y1_or_e1, x1_or_len, e, e3, x1_or_len)	    	if (e)	    	{		    RROP_SOLID_MASK((int *) addrb, e);		    addrb += 4;	    	}		RROP_SPAN(addrb, x1_or_len)	    	if (e3)		    RROP_SOLID_MASK((int *) addrb, e3);	    }# ifndef POLYSEGMENT	    addrb = t;# endif	}#endif    }#ifdef POLYSEGMENT    if (nseg >= 0)	return (xSegment *) ppt - pSegInit;#else    if (npt)	return ((DDXPointPtr) ppt - pptInit) - 1;#endif#ifndef POLYSEGMENT# ifndef ORIGIN#  define C2  c2# else#  define C2  ppt[-1]# endif    if (pGC->capStyle != CapNotLast && C2 != *((int *) pptInit))    {# ifdef REARRANGE	RROP_DECLARE	RROP_FETCH_GCPRIV(devPriv);# endif	RROP_SOLID (addrb);    }#endif    return -1;}#endif /* INCLUDE_DRAW */#ifdef INCLUDE_OTHERSextern void cfb8ClippedLineCopy(), cfb8ClippedLineXor(), cfb8ClippedLineGeneral(); #ifdef POLYSEGMENTextern int cfb8SegmentSS1RectCopy(), cfb8SegmentSS1RectXor(), cfb8SegmentSS1RectGeneral(); #ifdef FAST_MULextern int cfb8SegmentSS1RectShiftCopy();#endifvoidcfb8SegmentSS1Rect (pDrawable, pGC, nseg, pSegInit)    DrawablePtr	    pDrawable;    GCPtr	    pGC;    int		    nseg;    xSegment	    *pSegInit;{    int	    (*func)();    void    (*clip)();    int	    drawn;    cfbPrivGCPtr    devPriv;    devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);     switch (devPriv->rop)    {    case GXcopy:	func = cfb8SegmentSS1RectCopy;	clip = cfb8ClippedLineCopy;#ifdef FAST_MUL	if (cfbGetByteWidth (pDrawable) == WIDTH_FAST)	    func = cfb8SegmentSS1RectShiftCopy;#endif	break;    case GXxor:	func = cfb8SegmentSS1RectXor;	clip = cfb8ClippedLineXor;	break;    default:	func = cfb8SegmentSS1RectGeneral;	clip = cfb8ClippedLineGeneral;	break;    }    while (nseg)    {	drawn = (*func) (pDrawable, pGC, nseg, pSegInit);	if (drawn == -1)	    break;	(*clip) (pDrawable, pGC,			 pSegInit[drawn-1].x1, pSegInit[drawn-1].y1,			 pSegInit[drawn-1].x2, pSegInit[drawn-1].y2,			 &devPriv->pCompositeClip->extents,			 pGC->capStyle == CapNotLast);	pSegInit += drawn;	nseg -= drawn;    }}#else /* POLYSEGMENT */extern int cfb8LineSS1RectCopy(), cfb8LineSS1RectXor(), cfb8LineSS1RectGeneral(); extern int cfb8LineSS1RectPreviousCopy();voidcfb8LineSS1Rect (pDrawable, pGC, mode, npt, pptInit)    DrawablePtr	pDrawable;    GCPtr	pGC;    int		mode;    int		npt;    DDXPointPtr	pptInit;{    int	    (*func)();    void    (*clip)();    int	    drawn;    cfbPrivGCPtr    devPriv;    devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);     switch (devPriv->rop)    {    case GXcopy:	func = cfb8LineSS1RectCopy;	clip = cfb8ClippedLineCopy;	if (mode == CoordModePrevious)	    func = cfb8LineSS1RectPreviousCopy;	break;    case GXxor:	func = cfb8LineSS1RectXor;	clip = cfb8ClippedLineXor;	break;    default:	func = cfb8LineSS1RectGeneral;	clip = cfb8ClippedLineGeneral;	break;    }    while (npt > 1)    {	drawn = (*func) (pDrawable, pGC, mode, npt, pptInit);	if (drawn == -1)	    break;	(*clip) (pDrawable, pGC,			 pptInit[drawn-1].x, pptInit[drawn-1].y,			 pptInit[drawn].x, pptInit[drawn].y,			 &devPriv->pCompositeClip->extents,			 drawn != npt - 1 || pGC->capStyle == CapNotLast);	pptInit += drawn;	npt -= drawn;    }}#define round(dividend, divisor) \( (((dividend)<<1) + (divisor)) / ((divisor)<<1) )#define ceiling(m,n)  (((m)-1)/(n) + 1)#define SignTimes(sign,n)   (((sign) < 0) ? -(n) : (n))cfbClipPoint (oc, xp, yp, dx, dy, boxp)    int	oc;    int	*xp, *yp;    BoxPtr  boxp;{    int	x, y;    int	adx, ady, signdx, signdy;    int	utmp;        signdx = 1;    if (dx < 0)    {    	signdx = -1;    	dx = -dx;    }    signdy = 1;    if (dy  < 0)    {    	signdy = -1;    	dy = -dy;    }    if (oc & (OUT_LEFT | OUT_RIGHT))    {    	if (oc & OUT_LEFT)    	{	    x = boxp->x1;	    utmp = x - *xp;    	}    	else    	{	    x = boxp->x2 - 1;	    utmp = *xp - x;    	}    	utmp *= dy;	if (dy > dx)	{	    utmp = (utmp << 1) - dy + 1;	    y = *yp + SignTimes(signdy, ceiling(utmp, (dx << 1)));	}	else	{    	    y = *yp + SignTimes(signdy, round(utmp, dx));	}	oc = 0;	OUTCODES (oc, x, y, boxp);    }    if (oc & (OUT_ABOVE | OUT_BELOW))    {    	if (oc & OUT_ABOVE)    	{    	    y = boxp->y1;    	    utmp = y - *yp;    	}    	else    	{    	    y = boxp->y2 - 1;    	    utmp = *yp - y;    	}	utmp *= dx;	if (dx > dy)	{	    utmp = (utmp << 1) - dx + 1;	    x = *xp + SignTimes(signdx, ceiling(utmp, (dy << 1)));	}	else	{	    x = *xp + SignTimes(signdx, round(utmp, dy));	}	oc = 0;	OUTCODES (oc, x, y, boxp);    }    *xp = x;    *yp = y;    return oc;}#endif /* else POLYSEGMENT */#endif /* INCLUDE_OTHERS */#if !defined(POLYSEGMENT) && !defined (PREVIOUS)voidRROP_NAME (cfb8ClippedLine) (pDrawable, pGC, x1, y1, x2, y2, boxp, shorten)    DrawablePtr	pDrawable;    GCPtr	pGC;    int		x1, y1, x2, y2;    BoxPtr	boxp;    Bool	shorten;{    int		    oc1, oc2;    int		    signdx, signdy, axis, e, e1, e3, len;    int		    adx, ady;    unsigned char   *addr;    int		    nwidth;    int		    stepx, stepy;    int		    xorg, yorg;    cfbGetByteWidthAndPointer(pDrawable, nwidth, addr);    SET_REGISTERS_FOR_WRITING(pDrawable->pScreen, ~0, GXcopy);    xorg = pDrawable->x;    yorg = pDrawable->y;    x1 += xorg;    y1 += yorg;    x2 += xorg;    y2 += yorg;    oc1 = 0;    oc2 = 0;    OUTCODES (oc1, x1, y1, boxp);    OUTCODES (oc2, x2, y2, boxp);    if (oc1 & oc2)	return;    signdx = 1;    stepx = 1;    if ((adx = x2 - x1) < 0)    {	adx = -adx;	signdx = -1;	stepx = -1;    }    signdy = 1;    stepy = nwidth;    if ((ady = y2 - y1) < 0)    {	ady = -ady;	signdy = -1;	stepy = -nwidth;    }    axis = X_AXIS;    if (adx <= ady)    {	int	t;	t = adx;	adx = ady;	ady = t;	t = stepx;	stepx = stepy;	stepy = t;		axis = Y_AXIS;    }    e1 = ady << 1;    e3 = - (adx << 1);    e = - adx;    len = adx;    if (oc2)    {	int xt = x2, yt = y2;	int	dx = x2 - x1, dy = y2 - y1;	int change;	oc2 = cfbClipPoint (oc2, &xt, &yt, -dx, -dy, boxp);	if (axis == Y_AXIS)	    change = y2 - yt;	else	    change = x2 - xt;	if (change < 0)	    change = -change;	len -= change;    } else if (shorten)	len--;    if (oc1)    {	int	xt = x1, yt = y1;	int	dx = x2 - x1, dy = y2 - y1;	int	changex, changey;	oc1 = cfbClipPoint (oc1, &xt, &yt, dx, dy, boxp);	changex = x1 - xt;	if (changex < 0)	    changex = -changex;	changey = y1 - yt;	if (changey < 0)	    changey = -changey;	if (axis == X_AXIS)	{	    len -= changex;	    e = e + changey * e3 + changex * e1;	}	else	{	    len -= changey;	    e = e + changex * e3 + changey * e1;	}	x1 = xt;	y1 = yt;    }    if (oc1 | oc2 || len < 0)	return;    {    register unsigned char	*addrb;    RROP_DECLARE    RROP_FETCH_GC(pGC);    addrb = addr + (y1 * nwidth) + x1;#ifndef REARRANGE    if (!ady)    {#define body	{ RROP_SOLID(addrb); addrb += stepx; }	while (len >= 4)	{	    body body body body	    len -= 4;	}	switch (len)	{	case  3: body case 2: body case 1: body	}#undef body    }    else#endif    {#define body {\	    RROP_SOLID(addrb); \	    addrb += stepx; \	    e += e1; \	    if (e >= 0) \	    { \		addrb += stepy; \		e += e3; \	     } \	}#ifdef LARGE_INSTRUCTION_CACHE	while ((len -= 4) >= 0)	{	    body body body body	}	switch (len)	{	case  -1: body case -2: body case -3: body	}#else	IMPORTANT_START	while ((len -= 2) >= 0)	{	    body body	}	if (len & 1)	    body;	IMPORTANT_END#endif    }    RROP_SOLID(addrb);#undef body    }}#endif /* !POLYSEGMENT && !PREVIOUS */

⌨️ 快捷键说明

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