Example #1
0
static void
ShadowSetSpans(
    DrawablePtr		pDraw,
    GCPtr		pGC,
    char		*pcharsrc,
    DDXPointPtr 	pptInit,
    int			*pwidthInit,
    int			nspans,
    int			fSorted 
){
    SHADOW_GC_OP_PROLOGUE(pGC);

    if(IS_VISIBLE(pDraw) && nspans) {
	DDXPointPtr ppt = pptInit;
	int *pwidth = pwidthInit;
	int i = nspans;
	BoxRec box;
        Bool boxNotEmpty = FALSE;

	box.x1 = ppt->x;
	box.x2 = box.x1 + *pwidth;
	box.y2 = box.y1 = ppt->y;

	while(--i) {
	   ppt++;
	   pwidth++;
	   if(box.x1 > ppt->x) box.x1 = ppt->x;
	   if(box.x2 < (ppt->x + *pwidth)) 
		box.x2 = ppt->x + *pwidth;
	   if(box.y1 > ppt->y) box.y1 = ppt->y;
	   else if(box.y2 < ppt->y) box.y2 = ppt->y;
	}

	box.y2++;

        if(!pGC->miTranslate) {
           TRANSLATE_BOX(box, pDraw);
        }
        TRIM_BOX(box, pGC);

	if(BOX_NOT_EMPTY(box)) {
           if(pPriv->preRefresh)
	      (*pPriv->preRefresh)(pPriv->pScrn, 1, &box);
           boxNotEmpty = TRUE;
        }

	(*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, 
				pwidthInit, nspans, fSorted);

	if(boxNotEmpty && pPriv->postRefresh)
	   (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
    } else
	(*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, pptInit, 
				pwidthInit, nspans, fSorted);

    SHADOW_GC_OP_EPILOGUE(pGC);
}
Example #2
0
static void
SMI_Polylines(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
			  DDXPointPtr pptInit)
{
	XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
	ScrnInfoPtr pScrn = infoRec->pScrn;
	SMIPtr pSmi = SMIPTR(pScrn);

	ENTER_PROC("SMI_Polylines");

	/* Call the original Polylines function. */
	pGC->ops->Polylines = XAAFallbackOps.Polylines;
	(*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
	pGC->ops->Polylines = SMI_Polylines;

	if (IS_VISIBLE(pDraw) && npt)
	{
		/* Allocate a temporary buffer for all segments of the polyline. */
		BoxPtr pBox = xnfcalloc(sizeof(BoxRec), npt);
		int extra = pGC->lineWidth >> 1, box;

		if (npt > 1)
		{
			/* Adjust the extra space required per polyline segment. */
			if (pGC->joinStyle == JoinMiter)
			{
				extra = 6 * pGC->lineWidth;
			}
			else if (pGC->capStyle == CapProjecting)
			{
				extra = pGC->lineWidth;
			}
		}

		for (box = 0; --npt;)
		{
			/* Setup the bounding box for one polyline segment. */
			pBox[box].x1 = pptInit->x;
			pBox[box].y1 = pptInit->y;
			pptInit++;
			pBox[box].x2 = pptInit->x;
			pBox[box].y2 = pptInit->y;
			if (mode == CoordModePrevious)
			{
				pBox[box].x2 += pBox[box].x1;
				pBox[box].y2 += pBox[box].y1;
			}

			/* Sort coordinates. */
			if (pBox[box].x1 > pBox[box].x2)
			{
				int tmp = pBox[box].x1;
				pBox[box].x1 = pBox[box].x2;
				pBox[box].x2 = tmp;
			}
			if (pBox[box].y1 > pBox[box].y2)
			{
				int tmp = pBox[box].y1;
				pBox[box].y1 = pBox[box].y2;
				pBox[box].y2 = tmp;
			}

			/* Add extra space required for each polyline segment. */
			pBox[box].x1 -= extra;
			pBox[box].y1 -= extra;
			pBox[box].x2 += extra + 1;
			pBox[box].y2 += extra + 1;

			/* See if we need to draw this polyline segment. */
			TRANSLATE_BOX(pBox[box], pDraw);
			TRIM_BOX(pBox[box], pGC);
			if (BOX_NOT_EMPTY(pBox[box]))
			{
				box++;
			}
		}

		if (box)
		{
			/* Refresh all polyline segments now. */
			SMI_RefreshArea(pScrn, box, pBox);
		}

		/* Free the temporary buffer. */
		xfree(pBox);
	}