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

📄 cfbline.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	    	    clip1 = 0;	    	    clip2 = 0;    			    if (mfbClipLine (pbox, box,				     &pt1, &pt1Copy, &pt2Copy, 				     adx, ady, signdx, signdy, axis,				     &clip1, &clip2) == 1)		    {		    	if (axis == X_AXIS)			    len = abs(pt2Copy.x - pt1Copy.x);		    	else			    len = abs(pt2Copy.y - pt1Copy.y);    #ifdef POLYSEGMENT		    	if (clip2 != 0 || pGC->capStyle != CapNotLast)			    len++;#else		    	len += (clip2 != 0);#endif		    	if (len)		    	{			    /* unwind bresenham error term to first point */			    if (clip1)			    {			    	clipdx = abs(pt1Copy.x - x1);			    	clipdy = abs(pt1Copy.y - y1);			    	if (axis == X_AXIS)				    err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));			    	else				    err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));			    }			    else			    	err = e;			    cfbBresS   				     (alu, and, xor,				      addrl, nlwidth,				      signdx, signdy, axis, pt1Copy.x, pt1Copy.y,				      err, e1, e2, len);		    	}		    }		    pbox++;		}	    } /* while (nbox--) */	} /* sloped line */    } /* while (nline--) */#ifndef POLYSEGMENT    /* paint the last point if the end style isn't CapNotLast.       (Assume that a projecting, butt, or round cap that is one        pixel wide is the same as the single pixel of the endpoint.)    */    if ((pGC->capStyle != CapNotLast) &&	((ppt->x + xorg != pptInit->x + pDrawable->x) ||	 (ppt->y + yorg != pptInit->y + pDrawable->y) ||	 (ppt == pptInit + 1)))    {	nbox = nboxInit;	pbox = pboxInit;	while (nbox--)	{	    if ((x2 >= pbox->x1) &&		(y2 >= pbox->y1) &&		(x2 <  pbox->x2) &&		(y2 <  pbox->y2))	    {		unsigned long mask;		unsigned long scrbits;		mask = cfbmask[x2 & PIM];		addrl += (y2 * nlwidth) + (x2 >> PWSH);		scrbits = *addrl;		*addrl = (scrbits & ~mask) |			 (DoRRop (scrbits, and, xor) & mask);		break;	    }	    else		pbox++;	}    }#endif}/* * Draw dashed 1-pixel lines. */void#ifdef POLYSEGMENTcfbSegmentSD (pDrawable, pGC, nseg, pSeg)    DrawablePtr	pDrawable;    register GCPtr	pGC;    int		nseg;    register xSegment	*pSeg;#elsecfbLineSD( pDrawable, pGC, mode, npt, pptInit)    DrawablePtr pDrawable;    register GCPtr pGC;    int mode;		/* Origin or Previous */    int npt;		/* number of points */    DDXPointPtr pptInit;#endif{    int nboxInit;    register int nbox;    BoxPtr pboxInit;    register BoxPtr pbox;#ifndef POLYSEGMENT    register DDXPointPtr ppt;	/* pointer to list of translated points */#endif    register unsigned int oc1;		/* outcode of point 1 */    register unsigned int oc2;		/* outcode of point 2 */    unsigned long *addrl;		/* address of destination pixmap */    int nlwidth;		/* width in longwords of destination pixmap */    int xorg, yorg;		/* origin of window */    int adx;		/* abs values of dx and dy */    int ady;    int signdx;		/* sign of dx and dy */    int signdy;    int e, e1, e2;		/* bresenham error and increments */    int len;			/* length of segment */    int axis;			/* major axis */    int x1, x2, y1, y2;    RegionPtr cclip;    cfbRRopRec	    rrops[2];    unsigned char   *pDash;    int		    dashOffset;    int		    numInDashList;    int		    dashIndex;    int		    isDoubleDash;    int		    dashIndexTmp, dashOffsetTmp;    int		    unclippedlen;    cfbPrivGCPtr    devPriv;    devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);     cclip = devPriv->pCompositeClip;    rrops[0].rop = devPriv->rop;    rrops[0].and = devPriv->and;    rrops[0].xor = devPriv->xor;    if (pGC->alu == GXcopy)    {	rrops[1].rop = GXcopy;	rrops[1].and = 0;	rrops[1].xor = PFILL (pGC->bgPixel);    }    else    {    	rrops[1].rop = cfbReduceRasterOp (pGC->alu,					  pGC->bgPixel, pGC->planemask,					  &rrops[1].and, &rrops[1].xor);    }    pboxInit = REGION_RECTS(cclip);    nboxInit = REGION_NUM_RECTS(cclip);    cfbGetLongWidthAndPointer (pDrawable, nlwidth, addrl)    SET_REGISTERS_FOR_WRITING(pDrawable->pScreen, ~0, GXcopy);    /* compute initial dash values */         pDash = (unsigned char *) pGC->dash;    numInDashList = pGC->numInDashList;    isDoubleDash = (pGC->lineStyle == LineDoubleDash);    dashIndex = 0;    dashOffset = 0;    miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,		numInDashList, &dashOffset);    xorg = pDrawable->x;    yorg = pDrawable->y;#ifdef POLYSEGMENT    while (nseg--)#else    ppt = pptInit;    x2 = ppt->x + xorg;    y2 = ppt->y + yorg;    while(--npt)#endif    {	nbox = nboxInit;	pbox = pboxInit;#ifdef POLYSEGMENT	x1 = pSeg->x1 + xorg;	y1 = pSeg->y1 + yorg;	x2 = pSeg->x2 + xorg;	y2 = pSeg->y2 + yorg;	pSeg++;#else	x1 = x2;	y1 = y2;	++ppt;	if (mode == CoordModePrevious)	{	    xorg = x1;	    yorg = y1;	}	x2 = ppt->x + xorg;	y2 = ppt->y + yorg;#endif	adx = x2 - x1;	ady = y2 - y1;	signdx = sign(adx);	signdy = sign(ady);	adx = abs(adx);	ady = abs(ady);	if (adx > ady)	{	    axis = X_AXIS;	    e1 = ady << 1;	    e2 = e1 - (adx << 1);	    e = e1 - adx;	    unclippedlen = adx;	}	else	{	    axis = Y_AXIS;	    e1 = adx << 1;	    e2 = e1 - (ady << 1);	    e = e1 - ady;	    unclippedlen = ady;	}	/* we have bresenham parameters and two points.	   all we have to do now is clip and draw.	*/	while(nbox--)	{	    oc1 = 0;	    oc2 = 0;	    OUTCODES(oc1, x1, y1, pbox);	    OUTCODES(oc2, x2, y2, pbox);	    if ((oc1 | oc2) == 0)	    {#ifdef POLYSEGMENT		if (pGC->capStyle != CapNotLast)		    unclippedlen++;		dashIndexTmp = dashIndex;		dashOffsetTmp = dashOffset;		cfbBresD (rrops,		      &dashIndexTmp, pDash, numInDashList,		      &dashOffsetTmp, isDoubleDash,		      addrl, nlwidth,		      signdx, signdy, axis, x1, y1,		      e, e1, e2, unclippedlen);		break;#else		cfbBresD (rrops,		      &dashIndex, pDash, numInDashList,		      &dashOffset, isDoubleDash,		      addrl, nlwidth,		      signdx, signdy, axis, x1, y1,		      e, e1, e2, unclippedlen);		goto dontStep;#endif	    }	    else if (oc1 & oc2)	    {		pbox++;	    }	    else /* have to clip */	    {		/*		 * let the mfb helper routine do our work;		 * better than duplicating code...		 */		BoxRec box;		DDXPointRec pt1Copy;	/* clipped start point */		DDXPointRec pt2Copy;	/* clipped end point */		int err;			/* modified bresenham error term */		int clip1, clip2;		/* clippedness of the endpoints */	    		int clipdx, clipdy;		/* difference between clipped and					       unclipped start point */		DDXPointRec	pt1;    		pt1.x = pt1Copy.x = x1;		pt1.y = pt1Copy.y = y1;		pt2Copy.x = x2;		pt2Copy.y = y2;		box.x1 = pbox->x1;		box.y1 = pbox->y1;		box.x2 = pbox->x2-1;		box.y2 = pbox->y2-1;		clip1 = 0;		clip2 = 0;    		if (mfbClipLine (pbox, box,				       &pt1, &pt1Copy, &pt2Copy, 				       adx, ady, signdx, signdy, axis,				       &clip1, &clip2) == 1)		{    		    dashIndexTmp = dashIndex;		    dashOffsetTmp = dashOffset;		    if (clip1)		    {		    	int dlen;    		    	if (axis == X_AXIS)			    dlen = abs(pt1Copy.x - x1);		    	else			    dlen = abs(pt1Copy.y - y1);		    	miStepDash (dlen, &dashIndexTmp, pDash,				    numInDashList, &dashOffsetTmp);		    }		    if (axis == X_AXIS)		    	len = abs(pt2Copy.x - pt1Copy.x);		    else		    	len = abs(pt2Copy.y - pt1Copy.y);    #ifdef POLYSEGMENT		    if (clip2 != 0 || pGC->capStyle != CapNotLast)		    	len++;#else		    len += (clip2 != 0);#endif		    if (len)		    {		    	/* unwind bresenham error term to first point */		    	if (clip1)		    	{			    clipdx = abs(pt1Copy.x - x1);			    clipdy = abs(pt1Copy.y - y1);			    if (axis == X_AXIS)			    	err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));			    else			    	err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));		    	}		    	else			    err = e;		    	cfbBresD (rrops,			      	  &dashIndexTmp, pDash, numInDashList,			      	  &dashOffsetTmp, isDoubleDash,			      	  addrl, nlwidth,			      	  signdx, signdy, axis, pt1Copy.x, pt1Copy.y,			      	  err, e1, e2, len);		    }		}		pbox++;	    }	} /* while (nbox--) */#ifndef POLYSEGMENT	/*	 * walk the dash list around to the next line	 */	miStepDash (unclippedlen, &dashIndex, pDash,		    numInDashList, &dashOffset);dontStep:	;#endif    } /* while (nline--) */#ifndef POLYSEGMENT    /* paint the last point if the end style isn't CapNotLast.       (Assume that a projecting, butt, or round cap that is one        pixel wide is the same as the single pixel of the endpoint.)    */    if ((pGC->capStyle != CapNotLast) &&        ((dashIndex & 1) == 0 || isDoubleDash) &&	((ppt->x + xorg != pptInit->x + pDrawable->x) ||	 (ppt->y + yorg != pptInit->y + pDrawable->y) ||	 (ppt == pptInit + 1)))    {	nbox = nboxInit;	pbox = pboxInit;	while (nbox--)	{	    if ((x2 >= pbox->x1) &&		(y2 >= pbox->y1) &&		(x2 <  pbox->x2) &&		(y2 <  pbox->y2))	    {		unsigned long	mask;		int		pix;		pix = 0;		if (dashIndex & 1)		    pix = 1;		mask = cfbmask[x2 & PIM];		addrl += (y2 * nlwidth) + (x2 >> PWSH);		*addrl = DoMaskRRop (*addrl, rrops[pix].and, rrops[pix].xor, mask);		break;	    }	    else		pbox++;	}    }#endif}

⌨️ 快捷键说明

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