From 4c61bf84b11e26e6f22648668c95ea760a379163 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 11 Jun 2010 12:14:52 +0000 Subject: xserver git update 11/6/2010 --- xorg-server/hw/xfree86/xaa/xaaBitBlt.c | 34 +- xorg-server/hw/xfree86/xaa/xaaCpyArea.c | 16 +- xorg-server/hw/xfree86/xaa/xaaCpyPlane.c | 12 +- xorg-server/hw/xfree86/xaa/xaaCpyWin.c | 16 +- xorg-server/hw/xfree86/xaa/xaaDashLine.c | 668 ++++---- xorg-server/hw/xfree86/xaa/xaaFillArc.c | 426 +++--- xorg-server/hw/xfree86/xaa/xaaFillPoly.c | 1924 +++++++++++------------ xorg-server/hw/xfree86/xaa/xaaFillRect.c | 2190 +++++++++++++-------------- xorg-server/hw/xfree86/xaa/xaaGC.c | 3 +- xorg-server/hw/xfree86/xaa/xaaImage.c | 4 +- xorg-server/hw/xfree86/xaa/xaaInit.c | 25 +- xorg-server/hw/xfree86/xaa/xaaLine.c | 788 +++++----- xorg-server/hw/xfree86/xaa/xaaLineMisc.c | 3 +- xorg-server/hw/xfree86/xaa/xaaNonTEText.c | 24 +- xorg-server/hw/xfree86/xaa/xaaOverlay.c | 18 +- xorg-server/hw/xfree86/xaa/xaaOverlayDF.c | 37 +- xorg-server/hw/xfree86/xaa/xaaPCache.c | 22 +- xorg-server/hw/xfree86/xaa/xaaPict.c | 40 +- xorg-server/hw/xfree86/xaa/xaaRect.c | 272 ++-- xorg-server/hw/xfree86/xaa/xaaSpans.c | 1764 ++++++++++----------- xorg-server/hw/xfree86/xaa/xaaStateChange.c | 5 +- xorg-server/hw/xfree86/xaa/xaaTEText.c | 15 +- xorg-server/hw/xfree86/xaa/xaaWideLine.c | 1842 +++++++++++----------- xorg-server/hw/xfree86/xaa/xaaWrapper.c | 13 +- xorg-server/hw/xfree86/xaa/xaawrap.h | 158 +- 25 files changed, 5159 insertions(+), 5160 deletions(-) (limited to 'xorg-server/hw/xfree86/xaa') diff --git a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c index b1fda1cd6..cc7e810ca 100644 --- a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c +++ b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c @@ -118,8 +118,8 @@ XAABitBlt( fastExpose = 0; } } else { - REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); - REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip); + RegionInit(&rgnDst, &fastBox, 1); + RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip); } dstx += pDstDrawable->x; @@ -128,9 +128,9 @@ XAABitBlt( if (pDstDrawable->type == DRAWABLE_WINDOW) { if (!((WindowPtr)pDstDrawable)->realized) { if (!fastClip) - REGION_UNINIT(pGC->pScreen, &rgnDst); + RegionUninit(&rgnDst); if (freeSrcClip) - REGION_DESTROY(pGC->pScreen, prgnSrcClip); + RegionDestroy(prgnSrcClip); return NULL; } } @@ -153,8 +153,8 @@ XAABitBlt( blown region and call intersect */ cclip = pGC->pCompositeClip; - if (REGION_NUM_RECTS(cclip) == 1) { - BoxPtr pBox = REGION_RECTS(cclip); + if (RegionNumRects(cclip) == 1) { + BoxPtr pBox = RegionRects(cclip); if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1; if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2; @@ -163,37 +163,37 @@ XAABitBlt( /* Check to see if the region is empty */ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) { - REGION_NULL(pGC->pScreen, &rgnDst); + RegionNull(&rgnDst); } else { - REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1); + RegionInit(&rgnDst, &fastBox, 1); } } else { /* We must turn off fastClip now, since we must create a full blown region. It is intersected with the composite clip below. */ fastClip = 0; - REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1); + RegionInit(&rgnDst, &fastBox,1); } } else { - REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy); + RegionTranslate(&rgnDst, -dx, -dy); } if (!fastClip) { - REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, + RegionIntersect(&rgnDst, &rgnDst, pGC->pCompositeClip); } /* Do bit blitting */ - numRects = REGION_NUM_RECTS(&rgnDst); + numRects = RegionNumRects(&rgnDst); if (numRects && width && height) { if(!(pptSrc = (DDXPointPtr)malloc(numRects * sizeof(DDXPointRec)))) { - REGION_UNINIT(pGC->pScreen, &rgnDst); + RegionUninit(&rgnDst); if (freeSrcClip) - REGION_DESTROY(pGC->pScreen, prgnSrcClip); + RegionDestroy(prgnSrcClip); return NULL; } - pbox = REGION_RECTS(&rgnDst); + pbox = RegionRects(&rgnDst); ppt = pptSrc; for (i = numRects; --i >= 0; pbox++, ppt++) { ppt->x = pbox->x1 + dx; @@ -214,8 +214,8 @@ XAABitBlt( (int)origSource.height, origDest.x, origDest.y, bitPlane); } - REGION_UNINIT(pGC->pScreen, &rgnDst); + RegionUninit(&rgnDst); if (freeSrcClip) - REGION_DESTROY(pGC->pScreen, prgnSrcClip); + RegionDestroy(prgnSrcClip); return prgnExposed; } diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c index eefd8d38d..5e594633d 100644 --- a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c +++ b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c @@ -95,8 +95,8 @@ XAADoBitBlt( ((pSrc->type == DRAWABLE_WINDOW) && (pDst->type == DRAWABLE_WINDOW))); - pbox = REGION_RECTS(prgnDst); - nbox = REGION_NUM_RECTS(prgnDst); + pbox = RegionRects(prgnDst); + nbox = RegionNumRects(prgnDst); pboxNew1 = NULL; pptNew1 = NULL; @@ -148,8 +148,8 @@ XAADoBitBlt( pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox); pptNew2 = (DDXPointPtr)malloc(sizeof(DDXPointRec) * nbox); if(!pboxNew2 || !pptNew2) { - if (pptNew2) free(pptNew2); - if (pboxNew2) free(pboxNew2); + free(pptNew2); + free(pboxNew2); if (pboxNew1) { free(pptNew1); free(pboxNew1); @@ -204,8 +204,8 @@ XAADoImageWrite( int srcwidth; unsigned char* psrcBase; /* start of image */ unsigned char* srcPntr; /* index into the image */ - BoxPtr pbox = REGION_RECTS(prgnDst); - int nbox = REGION_NUM_RECTS(prgnDst); + BoxPtr pbox = RegionRects(prgnDst); + int nbox = RegionNumRects(prgnDst); XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); int Bpp = pSrc->bitsPerPixel >> 3; @@ -233,8 +233,8 @@ XAADoImageRead( int dstwidth; unsigned char* pdstBase; /* start of image */ unsigned char* dstPntr; /* index into the image */ - BoxPtr pbox = REGION_RECTS(prgnDst); - int nbox = REGION_NUM_RECTS(prgnDst); + BoxPtr pbox = RegionRects(prgnDst); + int nbox = RegionNumRects(prgnDst); XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both src and dst have same bpp */ diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c index 358cb6fb2..2d036c936 100644 --- a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c +++ b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c @@ -76,8 +76,8 @@ XAACopyPlane1toNColorExpand( DDXPointPtr pptSrc ) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - BoxPtr pbox = REGION_RECTS(rgnDst); - int numrects = REGION_NUM_RECTS(rgnDst); + BoxPtr pbox = RegionRects(rgnDst); + int numrects = RegionNumRects(rgnDst); unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr; int srcwidth = ((PixmapPtr)pSrc)->devKind; @@ -101,8 +101,8 @@ XAACopyPlaneNtoNColorExpand( DDXPointPtr pptSrc ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - BoxPtr pbox = REGION_RECTS(rgnDst); - int numrects = REGION_NUM_RECTS(rgnDst); + BoxPtr pbox = RegionRects(rgnDst); + int numrects = RegionNumRects(rgnDst); unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr; unsigned char *data, *srcPtr, *dataPtr; int srcwidth = ((PixmapPtr)pSrc)->devKind; @@ -168,14 +168,14 @@ XAAPushPixelsSolidColorExpansion( int xOrg, int yOrg ) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip); + int MaxBoxes = RegionNumRects(pGC->pCompositeClip); BoxPtr pbox, pClipBoxes; int nboxes, srcx, srcy; xRectangle TheRect; unsigned char *src = pBitMap->devPrivate.ptr; int srcwidth = pBitMap->devKind; - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; TheRect.x = xOrg; diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c index 34f460f24..d8608b095 100644 --- a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c +++ b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c @@ -47,20 +47,20 @@ XAACopyWindow( return; } - pwinRoot = WindowTable[pScreen->myNum]; + pwinRoot = pScreen->root; - REGION_NULL(pScreen, &rgnDst); + RegionNull(&rgnDst); dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; - REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); - REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc); + RegionTranslate(prgnSrc, -dx, -dy); + RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc); - pbox = REGION_RECTS(&rgnDst); - nbox = REGION_NUM_RECTS(&rgnDst); + pbox = RegionRects(&rgnDst); + nbox = RegionNumRects(&rgnDst); if(!nbox || !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) { - REGION_UNINIT(pScreen, &rgnDst); + RegionUninit(&rgnDst); return; } ppt = pptSrc; @@ -78,5 +78,5 @@ XAACopyWindow( &(infoRec->ScratchGC), &rgnDst, pptSrc); free(pptSrc); - REGION_UNINIT(pScreen, &rgnDst); + RegionUninit(&rgnDst); } diff --git a/xorg-server/hw/xfree86/xaa/xaaDashLine.c b/xorg-server/hw/xfree86/xaa/xaaDashLine.c index 63233e05d..adae2e583 100644 --- a/xorg-server/hw/xfree86/xaa/xaaDashLine.c +++ b/xorg-server/hw/xfree86/xaa/xaaDashLine.c @@ -1,334 +1,334 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include - -#include -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "miline.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - - -void -#ifdef POLYSEGMENT -XAAPolySegmentDashed( - DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pSeg -#else -XAAPolyLinesDashed( - DrawablePtr pDrawable, - GCPtr pGC, - int mode, /* Origin or Previous */ - int npt, /* number of points */ - DDXPointPtr pptInit -#endif -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, - XAAGetGCKey()); - BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); - int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - int xorg = pDrawable->x; - int yorg = pDrawable->y; - int nbox; - BoxPtr pbox; -#ifndef POLYSEGMENT - DDXPointPtr ppt; -#endif - unsigned int oc1, oc2; - int dmin, dmaj, e, octant; - int x1, x2, y1, y2, tmp, len, offset; - int PatternLength, PatternOffset; - - if(!nboxInit) - return; - - if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) { - int minValX = infoRec->DashedLineLimits.x1; - int maxValX = infoRec->DashedLineLimits.x2; - int minValY = infoRec->DashedLineLimits.y1; - int maxValY = infoRec->DashedLineLimits.y2; -#ifdef POLYSEGMENT - int n = nseg; - xSegment *s = pSeg; - - while (n--) -#else - int n = npt; - int xorgtmp = xorg; - int yorgtmp = yorg; - - ppt = pptInit; - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; - while (--n) -#endif - { -#ifdef POLYSEGMENT - x1 = s->x1 + xorg; - y1 = s->y1 + yorg; - x2 = s->x2 + xorg; - y2 = s->y2 + yorg; - s++; -#else - x1 = x2; - y1 = y2; - ++ppt; - if (mode == CoordModePrevious) { - xorgtmp = x1; - yorgtmp = y1; - } - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; -#endif - if (x1 > maxValX || x1 < minValX || - x2 > maxValX || x2 < minValX || - y1 > maxValY || y1 < minValY || - y2 > maxValY || y2 < minValY) { -#ifdef POLYSEGMENT - XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); -#else - XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); -#endif - return; - } - } - } - - PatternLength = pGCPriv->DashLength; - PatternOffset = pGC->dashOffset % PatternLength; - - (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel, - (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1, - pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern); - - -#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 - - - if (infoRec->SubsequentDashedBresenhamLine) { - if((dmaj = x2 - x1) < 0) { - dmaj = -dmaj; - octant = XDECREASING; - } else octant = 0; - - if((dmin = y2 - y1) < 0) { - dmin = -dmin; - octant |= YDECREASING; - } - - if(dmin >= dmaj){ - tmp = dmin; dmin = dmaj; dmaj = tmp; - octant |= YMAJOR; - } - - e = -dmaj - ((bias >> octant) & 1); - len = dmaj; - dmin <<= 1; - dmaj <<= 1; - } else { /* Muffle compiler */ - dmin = dmaj = e = octant = len = 0; - } - - while(nbox--) { - oc1 = oc2 = 0; - OUTCODES(oc1, x1, y1, pbox); - OUTCODES(oc2, x2, y2, pbox); - if (!(oc1 | oc2)) { /* uncliped */ - if(infoRec->SubsequentDashedTwoPointLine) { - (*infoRec->SubsequentDashedTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST, PatternOffset); - } else { - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant, PatternOffset); - } - break; - } else if (oc1 & oc2) { /* completely clipped */ - pbox++; - } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) { - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); - - if(infoRec->SubsequentDashedBresenhamLine) { - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant, PatternOffset); - } else { - (*infoRec->SubsequentDashedTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST, PatternOffset - ); - } - (*infoRec->DisableClipping)(infoRec->pScrn); - pbox++; - } else { - int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; - int clip1 = 0, clip2 = 0; - int err, adx, ady; - - if(octant & YMAJOR) { - ady = dmaj >> 1; - adx = dmin >> 1; - } else { - ady = dmin >> 1; - adx = dmaj >> 1; - } - - if (miZeroClipLine(pbox->x1, pbox->y1, - pbox->x2 - 1, pbox->y2 - 1, - &new_x1, &new_y1, &new_x2, &new_y2, - adx, ady, &clip1, &clip2, - octant, bias, oc1, oc2) == -1) - { - pbox++; - continue; - } - - if (octant & YMAJOR) - len = abs(new_y2 - new_y1); - else - len = abs(new_x2 - new_x1); -#ifdef POLYSEGMENT - if (clip2 != 0 || pGC->capStyle != CapNotLast) - len++; -#else - len += (clip2 != 0); -#endif - if (len) { - int abserr, clipdx, clipdy; - /* unwind bresenham error term to first point */ - if (clip1) { - clipdx = abs(new_x1 - x1); - clipdy = abs(new_y1 - y1); - - if (octant & YMAJOR) - err = e + clipdy*dmin - clipdx*dmaj; - else - err = e + clipdx*dmin - clipdy*dmaj; - } else - err = e; - -#define range infoRec->DashedBresenhamLineErrorTermBits - abserr = abs(err); - while((abserr & range) || - (dmaj & range) || - (dmin & range)) { - dmin >>= 1; - dmaj >>= 1; - abserr >>= 1; - err /= 2; - } - - if(octant & YMAJOR) - offset = abs(new_y1 - y1); - else - offset = abs(new_x1 - x1); - - offset += PatternOffset; - offset %= PatternLength; - - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, new_x1, new_y1, - dmaj, dmin, err, len, octant, offset); - } - pbox++; - } - } /* while (nbox--) */ -#ifndef POLYSEGMENT - len = abs(y2 - y1); - tmp = abs(x2 - x1); - PatternOffset += (len > tmp) ? len : tmp; - PatternOffset %= PatternLength; -#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) && - ((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)) - { - if(infoRec->SubsequentDashedTwoPointLine) { - (*infoRec->SubsequentDashedTwoPointLine)( - infoRec->pScrn, x2, y2, x2, y2, 0, - PatternOffset); - } else { - (*infoRec->SubsequentDashedBresenhamLine)( - infoRec->pScrn, x2, y2, 2, 0, -1, - 1, 0, PatternOffset); - } - break; - } else - pbox++; - } - } -#endif - - SET_SYNC_FLAG(infoRec); -} - + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include + +#include +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "miline.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +void +#ifdef POLYSEGMENT +XAAPolySegmentDashed( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg +#else +XAAPolyLinesDashed( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, /* Origin or Previous */ + int npt, /* number of points */ + DDXPointPtr pptInit +#endif +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates, + XAAGetGCKey()); + BoxPtr pboxInit = RegionRects(pGC->pCompositeClip); + int nboxInit = RegionNumRects(pGC->pCompositeClip); + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + int xorg = pDrawable->x; + int yorg = pDrawable->y; + int nbox; + BoxPtr pbox; +#ifndef POLYSEGMENT + DDXPointPtr ppt; +#endif + unsigned int oc1, oc2; + int dmin, dmaj, e, octant; + int x1, x2, y1, y2, tmp, len, offset; + int PatternLength, PatternOffset; + + if(!nboxInit) + return; + + if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) { + int minValX = infoRec->DashedLineLimits.x1; + int maxValX = infoRec->DashedLineLimits.x2; + int minValY = infoRec->DashedLineLimits.y1; + int maxValY = infoRec->DashedLineLimits.y2; +#ifdef POLYSEGMENT + int n = nseg; + xSegment *s = pSeg; + + while (n--) +#else + int n = npt; + int xorgtmp = xorg; + int yorgtmp = yorg; + + ppt = pptInit; + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; + while (--n) +#endif + { +#ifdef POLYSEGMENT + x1 = s->x1 + xorg; + y1 = s->y1 + yorg; + x2 = s->x2 + xorg; + y2 = s->y2 + yorg; + s++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) { + xorgtmp = x1; + yorgtmp = y1; + } + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; +#endif + if (x1 > maxValX || x1 < minValX || + x2 > maxValX || x2 < minValX || + y1 > maxValY || y1 < minValY || + y2 > maxValY || y2 < minValY) { +#ifdef POLYSEGMENT + XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); +#else + XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); +#endif + return; + } + } + } + + PatternLength = pGCPriv->DashLength; + PatternOffset = pGC->dashOffset % PatternLength; + + (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel, + (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1, + pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern); + + +#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 + + + if (infoRec->SubsequentDashedBresenhamLine) { + if((dmaj = x2 - x1) < 0) { + dmaj = -dmaj; + octant = XDECREASING; + } else octant = 0; + + if((dmin = y2 - y1) < 0) { + dmin = -dmin; + octant |= YDECREASING; + } + + if(dmin >= dmaj){ + tmp = dmin; dmin = dmaj; dmaj = tmp; + octant |= YMAJOR; + } + + e = -dmaj - ((bias >> octant) & 1); + len = dmaj; + dmin <<= 1; + dmaj <<= 1; + } else { /* Muffle compiler */ + dmin = dmaj = e = octant = len = 0; + } + + while(nbox--) { + oc1 = oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if (!(oc1 | oc2)) { /* uncliped */ + if(infoRec->SubsequentDashedTwoPointLine) { + (*infoRec->SubsequentDashedTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST, PatternOffset); + } else { + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant, PatternOffset); + } + break; + } else if (oc1 & oc2) { /* completely clipped */ + pbox++; + } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) { + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); + + if(infoRec->SubsequentDashedBresenhamLine) { + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant, PatternOffset); + } else { + (*infoRec->SubsequentDashedTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST, PatternOffset + ); + } + (*infoRec->DisableClipping)(infoRec->pScrn); + pbox++; + } else { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int err, adx, ady; + + if(octant & YMAJOR) { + ady = dmaj >> 1; + adx = dmin >> 1; + } else { + ady = dmin >> 1; + adx = dmaj >> 1; + } + + if (miZeroClipLine(pbox->x1, pbox->y1, + pbox->x2 - 1, pbox->y2 - 1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + + if (octant & YMAJOR) + len = abs(new_y2 - new_y1); + else + len = abs(new_x2 - new_x1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) { + int abserr, clipdx, clipdy; + /* unwind bresenham error term to first point */ + if (clip1) { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + + if (octant & YMAJOR) + err = e + clipdy*dmin - clipdx*dmaj; + else + err = e + clipdx*dmin - clipdy*dmaj; + } else + err = e; + +#define range infoRec->DashedBresenhamLineErrorTermBits + abserr = abs(err); + while((abserr & range) || + (dmaj & range) || + (dmin & range)) { + dmin >>= 1; + dmaj >>= 1; + abserr >>= 1; + err /= 2; + } + + if(octant & YMAJOR) + offset = abs(new_y1 - y1); + else + offset = abs(new_x1 - x1); + + offset += PatternOffset; + offset %= PatternLength; + + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, new_x1, new_y1, + dmaj, dmin, err, len, octant, offset); + } + pbox++; + } + } /* while (nbox--) */ +#ifndef POLYSEGMENT + len = abs(y2 - y1); + tmp = abs(x2 - x1); + PatternOffset += (len > tmp) ? len : tmp; + PatternOffset %= PatternLength; +#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) && + ((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)) + { + if(infoRec->SubsequentDashedTwoPointLine) { + (*infoRec->SubsequentDashedTwoPointLine)( + infoRec->pScrn, x2, y2, x2, y2, 0, + PatternOffset); + } else { + (*infoRec->SubsequentDashedBresenhamLine)( + infoRec->pScrn, x2, y2, 2, 0, -1, + 1, 0, PatternOffset); + } + break; + } else + pbox++; + } + } +#endif + + SET_SYNC_FLAG(infoRec); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaFillArc.c b/xorg-server/hw/xfree86/xaa/xaaFillArc.c index d83922ce0..824d2af1d 100644 --- a/xorg-server/hw/xfree86/xaa/xaaFillArc.c +++ b/xorg-server/hw/xfree86/xaa/xaaFillArc.c @@ -1,213 +1,213 @@ -/* - * Copyright 1996 The XFree86 Project - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). - */ - -/* - * Filled solid arcs, based on cfbfillarc.c. - * - * Fill arc using calls to low-level span fill. Because the math for - * each span can be done concurrently with the drawing of the span - * with a graphics coprocessor operation, this is faster than just - * using miPolyFillArc, which first calculates all the spans and then - * calls FillSpans. - * - * Clipped arcs are dispatched to FillSpans. - */ -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" -#include "mifillarc.h" -#include "mi.h" - -/* - * This is based on the integer-math versions from mi. Perhaps on a - * Pentium, the floating-point (double)-math version is faster. - */ - -static void -XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - register int x, y, e; - int yk, xk, ym, xm, dx, dy, xorg, yorg; - int slw; - miFillArcRec info; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - miFillArcSetup(arc, &info); - MIFILLARCSETUP(); - if (pGC->miTranslate) - { - xorg += pDraw->x; - yorg += pDraw->y; - } - while (y > 0) - { - MIFILLARCSTEP(slw); - if (slw > 0) { - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x, - yorg - y, slw, 1); - if (miFillArcLower(slw)) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - xorg - x, yorg + y + dy, slw, 1); - } - } - - SET_SYNC_FLAG(infoRec); -} - - -#define ADDSPAN(l,r) \ - if (r >= l) \ - (*infoRec->SubsequentSolidFillRect)( \ - infoRec->pScrn, l, ya, r - l + 1, 1); - -#define ADDSLICESPANS(flip) \ - if (!flip) \ - { \ - ADDSPAN(xl, xr); \ - } \ - else \ - { \ - xc = xorg - x; \ - ADDSPAN(xc, xr); \ - xc += slw - 1; \ - ADDSPAN(xl, xc); \ - } - -static void -XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; - register int x, y, e; - miFillArcRec info; - miArcSliceRec slice; - int ya, xl, xr, xc; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - miFillArcSetup(arc, &info); - miFillArcSliceSetup(arc, &slice, pGC); - MIFILLARCSETUP(); - slw = arc->height; - if (slice.flip_top || slice.flip_bot) - slw += (arc->height >> 1) + 1; - if (pGC->miTranslate) - { - xorg += pDraw->x; - yorg += pDraw->y; - slice.edge1.x += pDraw->x; - slice.edge2.x += pDraw->x; - } - while (y > 0) - { - MIFILLARCSTEP(slw); - MIARCSLICESTEP(slice.edge1); - MIARCSLICESTEP(slice.edge2); - if (miFillSliceUpper(slice)) - { - ya = yorg - y; - MIARCSLICEUPPER(xl, xr, slice, slw); - - ADDSLICESPANS(slice.flip_top); - } - if (miFillSliceLower(slice)) - { - ya = yorg + y + dy; - MIARCSLICELOWER(xl, xr, slice, slw); - ADDSLICESPANS(slice.flip_bot); - } - } - - SET_SYNC_FLAG(infoRec); -} - - -void -XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs) -{ - register xArc *arc; - register int i; - int x2, y2; - BoxRec box; - RegionPtr cclip; - - cclip = pGC->pCompositeClip; - - if(!REGION_NUM_RECTS(cclip)) - return; - - for (arc = parcs, i = narcs; --i >= 0; arc++) - { - if (miFillArcEmpty(arc)) - continue; - if (miCanFillArc(arc)) - { - box.x1 = arc->x + pDraw->x; - box.y1 = arc->y + pDraw->y; - /* - * Because box.x2 and box.y2 get truncated to 16 bits, and the - * RECT_IN_REGION test treats the resulting number as a signed - * integer, the RECT_IN_REGION test alone can go the wrong way. - * This can result in a server crash because the rendering - * routines in this file deal directly with cpu addresses - * of pixels to be stored, and do not clip or otherwise check - * that all such addresses are within their respective pixmaps. - * So we only allow the RECT_IN_REGION test to be used for - * values that can be expressed correctly in a signed short. - */ - x2 = box.x1 + (int)arc->width + 1; - box.x2 = x2; - y2 = box.y1 + (int)arc->height + 1; - box.y2 = y2; - if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) && - (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) ) - { - if ((arc->angle2 >= FULLCIRCLE) || - (arc->angle2 <= -FULLCIRCLE)) - XAAFillEllipseSolid(pDraw, pGC, arc); - else - XAAFillArcSliceSolid(pDraw, pGC, arc); - continue; - } - } - miPolyFillArc(pDraw, pGC, 1, arc); - } -} +/* + * Copyright 1996 The XFree86 Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net). + */ + +/* + * Filled solid arcs, based on cfbfillarc.c. + * + * Fill arc using calls to low-level span fill. Because the math for + * each span can be done concurrently with the drawing of the span + * with a graphics coprocessor operation, this is faster than just + * using miPolyFillArc, which first calculates all the spans and then + * calls FillSpans. + * + * Clipped arcs are dispatched to FillSpans. + */ +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" +#include "mifillarc.h" +#include "mi.h" + +/* + * This is based on the integer-math versions from mi. Perhaps on a + * Pentium, the floating-point (double)-math version is faster. + */ + +static void +XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + register int x, y, e; + int yk, xk, ym, xm, dx, dy, xorg, yorg; + int slw; + miFillArcRec info; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + miFillArcSetup(arc, &info); + MIFILLARCSETUP(); + if (pGC->miTranslate) + { + xorg += pDraw->x; + yorg += pDraw->y; + } + while (y > 0) + { + MIFILLARCSTEP(slw); + if (slw > 0) { + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x, + yorg - y, slw, 1); + if (miFillArcLower(slw)) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + xorg - x, yorg + y + dy, slw, 1); + } + } + + SET_SYNC_FLAG(infoRec); +} + + +#define ADDSPAN(l,r) \ + if (r >= l) \ + (*infoRec->SubsequentSolidFillRect)( \ + infoRec->pScrn, l, ya, r - l + 1, 1); + +#define ADDSLICESPANS(flip) \ + if (!flip) \ + { \ + ADDSPAN(xl, xr); \ + } \ + else \ + { \ + xc = xorg - x; \ + ADDSPAN(xc, xr); \ + xc += slw - 1; \ + ADDSPAN(xl, xc); \ + } + +static void +XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int yk, xk, ym, xm, dx, dy, xorg, yorg, slw; + register int x, y, e; + miFillArcRec info; + miArcSliceRec slice; + int ya, xl, xr, xc; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + miFillArcSetup(arc, &info); + miFillArcSliceSetup(arc, &slice, pGC); + MIFILLARCSETUP(); + slw = arc->height; + if (slice.flip_top || slice.flip_bot) + slw += (arc->height >> 1) + 1; + if (pGC->miTranslate) + { + xorg += pDraw->x; + yorg += pDraw->y; + slice.edge1.x += pDraw->x; + slice.edge2.x += pDraw->x; + } + while (y > 0) + { + MIFILLARCSTEP(slw); + MIARCSLICESTEP(slice.edge1); + MIARCSLICESTEP(slice.edge2); + if (miFillSliceUpper(slice)) + { + ya = yorg - y; + MIARCSLICEUPPER(xl, xr, slice, slw); + + ADDSLICESPANS(slice.flip_top); + } + if (miFillSliceLower(slice)) + { + ya = yorg + y + dy; + MIARCSLICELOWER(xl, xr, slice, slw); + ADDSLICESPANS(slice.flip_bot); + } + } + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs) +{ + register xArc *arc; + register int i; + int x2, y2; + BoxRec box; + RegionPtr cclip; + + cclip = pGC->pCompositeClip; + + if(!RegionNumRects(cclip)) + return; + + for (arc = parcs, i = narcs; --i >= 0; arc++) + { + if (miFillArcEmpty(arc)) + continue; + if (miCanFillArc(arc)) + { + box.x1 = arc->x + pDraw->x; + box.y1 = arc->y + pDraw->y; + /* + * Because box.x2 and box.y2 get truncated to 16 bits, and the + * RECT_IN_REGION test treats the resulting number as a signed + * integer, the RECT_IN_REGION test alone can go the wrong way. + * This can result in a server crash because the rendering + * routines in this file deal directly with cpu addresses + * of pixels to be stored, and do not clip or otherwise check + * that all such addresses are within their respective pixmaps. + * So we only allow the RECT_IN_REGION test to be used for + * values that can be expressed correctly in a signed short. + */ + x2 = box.x1 + (int)arc->width + 1; + box.x2 = x2; + y2 = box.y1 + (int)arc->height + 1; + box.y2 = y2; + if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) && + (RegionContainsRect(cclip, &box) == rgnIN) ) + { + if ((arc->angle2 >= FULLCIRCLE) || + (arc->angle2 <= -FULLCIRCLE)) + XAAFillEllipseSolid(pDraw, pGC, arc); + else + XAAFillArcSliceSolid(pDraw, pGC, arc); + continue; + } + } + miPolyFillArc(pDraw, pGC, 1, arc); + } +} diff --git a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c index 6f11e35ff..b8347b336 100644 --- a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c +++ b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c @@ -1,962 +1,962 @@ - -/* - * Copyright 1996 The XFree86 Project - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -/* - * Written by Mark Vojkovich. Loosly based on an original version - * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which - * only did solid rectangles and didn't have trapezoid support. - * - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "mi.h" -#include "micoord.h" - -#include "xaa.h" -#include "xaalocal.h" - -#define POLY_USE_MI 0 -#define POLY_FULLY_CLIPPED 1 -#define POLY_IS_EASY 2 - - -#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\ - x = intToX(vertex); \ - if ((dy = intToY(c) - y)) { \ - DX = dx = intToX(c) - x; \ - step = 0; \ - if (dx >= 0) \ - { \ - e = 0; \ - sign = 1; \ - if (dx >= dy) {\ - step = dx / dy; \ - dx %= dy; \ - } \ - } \ - else \ - { \ - e = 1 - dy; \ - sign = -1; \ - dx = -dx; \ - if (dx >= dy) { \ - step = - (dx / dy); \ - dx %= dy; \ - } \ - } \ - } \ - x += origin; \ - vertex = c; \ -} - -#define Step(x,dx,dy,e,sign,step) {\ - x += step; \ - if ((e += dx) > 0) \ - { \ - x += sign; \ - e -= dy; \ - } \ -} - -#define FixError(x, dx, dy, e, sign, step, h) { \ - e += (h) * dx; \ - x += (h) * step; \ - if(e > 0) { \ - x += e * sign/dy; \ - e %= dy; \ - if(e) { \ - x += sign; \ - e -= dy; \ - } \ - } \ -} - - -/* - XAAIsEasyPoly - - - Checks CoordModeOrigin one rect polygons to see if we need - to use Mi. - Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY - as well as the pointer to the "top" point and the y - extents. -*/ - -int -XAAIsEasyPolygon( - DDXPointPtr ptsIn, - int count, - BoxPtr extents, - int origin, - DDXPointPtr *topPoint, /* return */ - int *topY, int *bottomY, /* return */ - int shape -){ - int c = 0, vertex1, vertex2; - - *topY = 32767; - *bottomY = 0; - - origin -= (origin & 0x8000) << 1; - vertex1 = extents->x1 - origin; - vertex2 = extents->x2 - origin /* - 0x00010001 */; - /* I think this was an error in cfb ^ */ - - if (shape == Convex) { - while (count--) { - c = *((int*)ptsIn); - if (((c - vertex1) | (vertex2 - c)) & 0x80008000) - return POLY_USE_MI; - - c = intToY(c); - if (c < *topY) { - *topY = c; - *topPoint = ptsIn; - } - ptsIn++; - if (c > *bottomY) *bottomY = c; - } - } else { - int yFlip = 0; - int dx2, dx1, x1, x2; - - x2 = x1 = -1; - dx2 = dx1 = 1; - - while (count--) { - c = *((int*)ptsIn); - if (((c - vertex1) | (vertex2 - c)) & 0x80008000) - return POLY_USE_MI; - c = intToY(c); - if (c < *topY) { - *topY = c; - *topPoint = ptsIn; - } - ptsIn++; - if (c > *bottomY) *bottomY = c; - if (c == x1) - continue; - if (dx1 > 0) { - if (x2 < 0) x2 = c; - else dx2 = dx1 = (c - x1) >> 31; - } else if ((c - x1) >> 31 != dx1) { - dx1 = ~dx1; - yFlip++; - } - x1 = c; - } - x1 = (x2 - c) >> 31; - if (x1 != dx1) yFlip++; - if (x1 != dx2) yFlip++; - if (yFlip != 2) { - if(*topY == *bottomY) - return POLY_FULLY_CLIPPED; - else - return POLY_USE_MI; - } - } - if (*topY == *bottomY) - return POLY_FULLY_CLIPPED; - - return POLY_IS_EASY; -} - -void -XAAFillPolygonSolid( - DrawablePtr pDraw, - GCPtr pGC, - int shape, - int mode, - int count, - DDXPointPtr ptsIn -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int origin, vertex1, vertex2; - int *vertex1p, *vertex2p, *endp; - int x1 = 0, x2 = 0; - int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; - int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; - int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; - int c, y, maxy, h, yoffset; - DDXPointPtr topPoint; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if (mode == CoordModePrevious) { - register DDXPointPtr ppt = ptsIn + 1; - - for (origin = 1; origin < count; origin++, ppt++) { - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - mode = CoordModeOrigin; - } - - if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - origin = coordToInt(pDraw->x, pDraw->y); - - switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, - origin, &topPoint, &y, &maxy, shape) ) { - case POLY_USE_MI: - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - case POLY_FULLY_CLIPPED: - return; - } - - endp = (int*)ptsIn + count; - vertex2p = vertex1p = (int *)topPoint; - origin = pDraw->x; - yoffset = pDraw->y; - vertex2 = vertex1 = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - while(1) { - if (y == intToY(vertex1)) { - do { - if (vertex1p == (int *) ptsIn) - vertex1p = endp; - c = *--vertex1p; - Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) - } while (y >= intToY(vertex1)); - h = dy1; - } else { - Step(x1,dx1,dy1,e1,sign1,step1) - h = intToY(vertex1) - y; - } - if (y == intToY(vertex2)) { - do { - c = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) - } while (y >= intToY(vertex2)); - if (dy2 < h) - h = dy2; - } else { - Step(x2,dx2,dy2,e2,sign2,step2) - if ((c = (intToY(vertex2) - y)) < h) - h = c; - } - - /* fill spans for this segment */ - if(DX1 | DX2) { - if(infoRec->SubsequentSolidFillTrap && (h > 6)) { - if(x1 == x2) { - while(x1 == x2) { - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - if(y == maxy) break; - if(!h) continue; - } - - if(x1 < x2) - (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, - y + yoffset, h, - x1, DX1, dy1, e1, - x2 - 1, DX2, dy2, e2); - else - (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, - y + yoffset, h, - x2, DX2, dy2, e2, - x1 - 1, DX1, dy1, e1); - y += h; - if(--h) { - FixError(x1,dx1,dy1,e1,sign1,step1,h); - FixError(x2,dx2,dy2,e2,sign2,step2,h); - h = 0; - } - } else { - while(1) { - if (x2 > x1) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x1, y + yoffset, x2 - x1, 1); - else if (x1 > x2) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x2, y + yoffset, x1 - x2, 1); - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - } - } else { - if (x2 > x1) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x1, y + yoffset, x2 - x1, h); - else if (x1 > x2) - (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, - x2, y + yoffset, x1 - x2, h); - - y += h; - h = 0; - } - if (y == maxy) break; - } - SET_SYNC_FLAG(infoRec); -} - - - - -void -XAAFillPolygonHelper( - ScrnInfoPtr pScrn, - DDXPointPtr ptsIn, - int count, - DDXPointPtr topPoint, - int y, - int maxy, - int origin, - RectFuncPtr RectFunc, - TrapFuncPtr TrapFunc, - int xorg, - int yorg, - XAACacheInfoPtr pCache -){ - int *vertex1p, *vertex2p, *endp; - int vertex1, vertex2; - int x1 = 0, x2 = 0; - int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; - int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; - int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; - int c, h, yoffset; - - - endp = (int*)ptsIn + count; - vertex2p = vertex1p = (int *)topPoint; - yoffset = intToY(origin); - origin = intToX(origin); - vertex2 = vertex1 = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *)ptsIn; - - while(1) { - if (y == intToY(vertex1)) { - do { - if (vertex1p == (int *) ptsIn) - vertex1p = endp; - c = *--vertex1p; - Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) - } while (y >= intToY(vertex1)); - h = dy1; - } else { - Step(x1,dx1,dy1,e1,sign1,step1) - h = intToY(vertex1) - y; - } - if (y == intToY(vertex2)) { - do { - c = *vertex2p++; - if (vertex2p == endp) - vertex2p = (int *) ptsIn; - Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) - } while (y >= intToY(vertex2)); - if (dy2 < h) - h = dy2; - } else { - Step(x2,dx2,dy2,e2,sign2,step2) - if ((c = (intToY(vertex2) - y)) < h) - h = c; - } - - /* fill spans for this segment */ - if(DX1 | DX2) { - if(TrapFunc && (h > 6)) { - if(x1 == x2) { - while(x1 == x2) { - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - if(y == maxy) break; - if(!h) continue; - } - - if(x1 < x2) - (*TrapFunc)(pScrn, y + yoffset, h, - x1, DX1, dy1, e1, - x2 - 1, DX2, dy2, e2, xorg, yorg, pCache); - else - (*TrapFunc)(pScrn, y + yoffset, h, - x2, DX2, dy2, e2, - x1 - 1, DX1, dy1, e1, xorg, yorg, pCache); - y += h; - if(--h) { - FixError(x1,dx1,dy1,e1,sign1,step1,h); - FixError(x2,dx2,dy2,e2,sign2,step2,h); - h = 0; - } - } else { - while(1) { - if (x2 > x1) - (*RectFunc)(pScrn, - x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache); - else if (x1 > x2) - (*RectFunc)(pScrn, - x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache); - y++; - if (!--h) break; - Step(x1,dx1,dy1,e1,sign1,step1) - Step(x2,dx2,dy2,e2,sign2,step2) - } - } - } else { - if (x2 > x1) - (*RectFunc)(pScrn, - x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache); - else if (x1 > x2) - (*RectFunc)(pScrn, - x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache); - - y += h; - h = 0; - } - if (y == maxy) break; - } -} - - /*****************\ - | Solid Helpers | - \*****************/ - -static void -SolidTrapHelper( - ScrnInfoPtr pScrn, - int y, int h, - int x1, int dx1, int dy1, int e1, - int x2, int dx2, int dy2, int e2, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentSolidFillTrap) (pScrn, - y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); -} - -static void -SolidRectHelper ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); -} - - - /*********************\ - | Mono 8x8 Patterns | - \*********************/ - -static void -Mono8x8PatternTrapHelper_ScreenOrigin( - ScrnInfoPtr pScrn, - int y, int h, - int x1, int dx1, int dy1, int e1, - int x2, int dx2, int dy2, int e2, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg, - y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); -} - -static void -Mono8x8PatternRectHelper_ScreenOrigin ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, - x, y, w, h); -} - -static void -Mono8x8PatternRectHelper ( - ScrnInfoPtr pScrn, - int x, int y, int w, int h, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - xorg = (x - xorg) & 0x07; - yorg = (y - yorg) & 0x07; - - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - int patx = pCache->pat0; - int paty = pCache->pat1; - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } else { - int slot = (yorg << 3) + xorg; - xorg = pCache->x + pCache->offsets[slot].x; - yorg = pCache->y + pCache->offsets[slot].y; - } - } - - - (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, - x, y, w, h); -} - - - - /****************\ - | Cache Expand | - \****************/ - - -static void -CacheExpandRectHelper ( - ScrnInfoPtr pScrn, - int X, int Y, int Width, int Height, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; - int cacheWidth; - - cacheWidth = (pCache->w * pScrn->bitsPerPixel) / - infoRec->CacheColorExpandDensity; - - phaseY = (Y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (X - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - - while(1) { - w = Width; skipleft = phaseX; x = X; - blit_h = pCache->h - phaseY; - if(blit_h > Height) blit_h = Height; - - while(1) { - blit_w = cacheWidth - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenColorExpandFill)( - pScrn, x, Y, blit_w, blit_h, - pCache->x, pCache->y + phaseY, skipleft); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - Height -= blit_h; - if(!Height) break; - Y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } -} - - - - /**************\ - | Cache Blit | - \**************/ - - -static void -CacheBltRectHelper ( - ScrnInfoPtr pScrn, - int X, int Y, int Width, int Height, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; - - phaseY = (Y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (X - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - - while(1) { - w = Width; skipleft = phaseX; x = X; - blit_h = pCache->h - phaseY; - if(blit_h > Height) blit_h = Height; - - while(1) { - blit_w = pCache->w - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + skipleft, pCache->y + phaseY, - x, Y, blit_w, blit_h); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - Height -= blit_h; - if(!Height) break; - Y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } -} - - - /**********************\ - | Stippled Polygons | - \**********************/ - - -void -XAAFillPolygonStippled( - DrawablePtr pDraw, - GCPtr pGC, - int shape, - int mode, - int count, - DDXPointPtr ptsIn -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - int origin, type, patx, paty, fg, bg; - int y, maxy, xorg, yorg; - DDXPointPtr topPoint; - XAACacheInfoPtr pCache = NULL; - RectFuncPtr RectFunc = NULL; - TrapFuncPtr TrapFunc = NULL; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if (mode == CoordModePrevious) { - register DDXPointPtr ppt = ptsIn + 1; - - for (origin = 1; origin < count; origin++, ppt++) { - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - mode = CoordModeOrigin; - } - - if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - - if(pGC->fillStyle == FillStippled) { - type = (*infoRec->StippledFillChooser)(pGC); - fg = pGC->fgPixel; bg = -1; - } else { - type = (*infoRec->OpaqueStippledFillChooser)(pGC); - fg = pGC->fgPixel; bg = pGC->bgPixel; - } - - - if(!type) { - (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - origin = pDraw->x; - - switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, - origin, &topPoint, &y, &maxy, shape) ) { - case POLY_USE_MI: - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - case POLY_FULLY_CLIPPED: - return; - } - - xorg = (pDraw->x + pGC->patOrg.x); - yorg = (pDraw->y + pGC->patOrg.y); - - - if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) { - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg, - pGC->alu, pGC->planemask); - - RectFunc = SolidRectHelper; - TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL; - } else - switch(type) { - case DO_MONO_8x8: - patx = pPriv->pattern0; paty = pPriv->pattern1; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_SCREEN_ORIGIN) { - xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; - if(infoRec->SubsequentMono8x8PatternFillTrap) - TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; - } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - } else { - pCache = &(infoRec->ScratchCacheInfoRec); - pCache->pat0 = patx; - pCache->pat1 = paty; - } - RectFunc = Mono8x8PatternRectHelper; - } - - (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, - patx, paty, fg, bg, pGC->alu, pGC->planemask); - break; - case DO_CACHE_EXPAND: - pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple); - - (*infoRec->SetupForScreenToScreenColorExpandFill)( - infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask); - - RectFunc = CacheExpandRectHelper; - break; - case DO_CACHE_BLT: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - fg, bg); - (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, - pGC->alu, pGC->planemask, pCache->trans_color); - - RectFunc = CacheBltRectHelper; - break; - default: - return; - } - - - XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, - y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); - - SET_SYNC_FLAG(infoRec); -} - - - - - /*******************\ - | Tiled Polygons | - \*******************/ - - -void -XAAFillPolygonTiled( - DrawablePtr pDraw, - GCPtr pGC, - int shape, - int mode, - int count, - DDXPointPtr ptsIn -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - int origin, type, patx, paty; - int y, maxy, xorg, yorg; - DDXPointPtr topPoint; - XAACacheInfoPtr pCache = NULL; - RectFuncPtr RectFunc = NULL; - TrapFuncPtr TrapFunc = NULL; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if (mode == CoordModePrevious) { - register DDXPointPtr ppt = ptsIn + 1; - - for (origin = 1; origin < count; origin++, ppt++) { - ppt->x += (ppt-1)->x; - ppt->y += (ppt-1)->y; - } - mode = CoordModeOrigin; - } - - if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - - type = (*infoRec->TiledFillChooser)(pGC); - - if(!type || (type == DO_IMAGE_WRITE)) { - (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - if(type == DO_COLOR_8x8) { - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - return; - } - - origin = pDraw->x; - - switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, - origin, &topPoint, &y, &maxy, shape) ) { - case POLY_USE_MI: - miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); - case POLY_FULLY_CLIPPED: - return; - } - - xorg = (pDraw->x + pGC->patOrg.x); - yorg = (pDraw->y + pGC->patOrg.y); - - switch(type) { - case DO_MONO_8x8: - patx = pPriv->pattern0; paty = pPriv->pattern1; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_SCREEN_ORIGIN) { - xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; - if(infoRec->SubsequentMono8x8PatternFillTrap) - TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; - } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)( - infoRec->pScrn, patx, paty); - patx = pCache->x; paty = pCache->y; - } - else { - pCache = &(infoRec->ScratchCacheInfoRec); - pCache->pat0 = patx; - pCache->pat1 = paty; - } - RectFunc = Mono8x8PatternRectHelper; - } - - (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, - patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask); - break; - case DO_CACHE_BLT: - pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); - (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, - pGC->alu, pGC->planemask, -1); - - RectFunc = CacheBltRectHelper; - break; - case DO_PIXMAP_COPY: - pCache = &(infoRec->ScratchCacheInfoRec); - pCache->x = pPriv->offscreenArea->box.x1; - pCache->y = pPriv->offscreenArea->box.y1; - pCache->w = pCache->orig_w = - pPriv->offscreenArea->box.x2 - pCache->x; - pCache->h = pCache->orig_h = - pPriv->offscreenArea->box.y2 - pCache->y; - - (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, - pGC->alu, pGC->planemask, -1); - - RectFunc = CacheBltRectHelper; - break; - default: - return; - } - - XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, - y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); - - SET_SYNC_FLAG(infoRec); -} - - + +/* + * Copyright 1996 The XFree86 Project + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +/* + * Written by Mark Vojkovich. Loosly based on an original version + * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which + * only did solid rectangles and didn't have trapezoid support. + * + */ + + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "mi.h" +#include "micoord.h" + +#include "xaa.h" +#include "xaalocal.h" + +#define POLY_USE_MI 0 +#define POLY_FULLY_CLIPPED 1 +#define POLY_IS_EASY 2 + + +#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\ + x = intToX(vertex); \ + if ((dy = intToY(c) - y)) { \ + DX = dx = intToX(c) - x; \ + step = 0; \ + if (dx >= 0) \ + { \ + e = 0; \ + sign = 1; \ + if (dx >= dy) {\ + step = dx / dy; \ + dx %= dy; \ + } \ + } \ + else \ + { \ + e = 1 - dy; \ + sign = -1; \ + dx = -dx; \ + if (dx >= dy) { \ + step = - (dx / dy); \ + dx %= dy; \ + } \ + } \ + } \ + x += origin; \ + vertex = c; \ +} + +#define Step(x,dx,dy,e,sign,step) {\ + x += step; \ + if ((e += dx) > 0) \ + { \ + x += sign; \ + e -= dy; \ + } \ +} + +#define FixError(x, dx, dy, e, sign, step, h) { \ + e += (h) * dx; \ + x += (h) * step; \ + if(e > 0) { \ + x += e * sign/dy; \ + e %= dy; \ + if(e) { \ + x += sign; \ + e -= dy; \ + } \ + } \ +} + + +/* + XAAIsEasyPoly - + + Checks CoordModeOrigin one rect polygons to see if we need + to use Mi. + Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY + as well as the pointer to the "top" point and the y + extents. +*/ + +int +XAAIsEasyPolygon( + DDXPointPtr ptsIn, + int count, + BoxPtr extents, + int origin, + DDXPointPtr *topPoint, /* return */ + int *topY, int *bottomY, /* return */ + int shape +){ + int c = 0, vertex1, vertex2; + + *topY = 32767; + *bottomY = 0; + + origin -= (origin & 0x8000) << 1; + vertex1 = extents->x1 - origin; + vertex2 = extents->x2 - origin /* - 0x00010001 */; + /* I think this was an error in cfb ^ */ + + if (shape == Convex) { + while (count--) { + c = *((int*)ptsIn); + if (((c - vertex1) | (vertex2 - c)) & 0x80008000) + return POLY_USE_MI; + + c = intToY(c); + if (c < *topY) { + *topY = c; + *topPoint = ptsIn; + } + ptsIn++; + if (c > *bottomY) *bottomY = c; + } + } else { + int yFlip = 0; + int dx2, dx1, x1, x2; + + x2 = x1 = -1; + dx2 = dx1 = 1; + + while (count--) { + c = *((int*)ptsIn); + if (((c - vertex1) | (vertex2 - c)) & 0x80008000) + return POLY_USE_MI; + c = intToY(c); + if (c < *topY) { + *topY = c; + *topPoint = ptsIn; + } + ptsIn++; + if (c > *bottomY) *bottomY = c; + if (c == x1) + continue; + if (dx1 > 0) { + if (x2 < 0) x2 = c; + else dx2 = dx1 = (c - x1) >> 31; + } else if ((c - x1) >> 31 != dx1) { + dx1 = ~dx1; + yFlip++; + } + x1 = c; + } + x1 = (x2 - c) >> 31; + if (x1 != dx1) yFlip++; + if (x1 != dx2) yFlip++; + if (yFlip != 2) { + if(*topY == *bottomY) + return POLY_FULLY_CLIPPED; + else + return POLY_USE_MI; + } + } + if (*topY == *bottomY) + return POLY_FULLY_CLIPPED; + + return POLY_IS_EASY; +} + +void +XAAFillPolygonSolid( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int origin, vertex1, vertex2; + int *vertex1p, *vertex2p, *endp; + int x1 = 0, x2 = 0; + int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; + int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; + int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; + int c, y, maxy, h, yoffset; + DDXPointPtr topPoint; + + if(!RegionNumRects(pGC->pCompositeClip)) + return; + + if (mode == CoordModePrevious) { + register DDXPointPtr ppt = ptsIn + 1; + + for (origin = 1; origin < count; origin++, ppt++) { + ppt->x += (ppt-1)->x; + ppt->y += (ppt-1)->y; + } + mode = CoordModeOrigin; + } + + if (RegionNumRects(pGC->pCompositeClip) != 1) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + origin = coordToInt(pDraw->x, pDraw->y); + + switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, + origin, &topPoint, &y, &maxy, shape) ) { + case POLY_USE_MI: + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + case POLY_FULLY_CLIPPED: + return; + } + + endp = (int*)ptsIn + count; + vertex2p = vertex1p = (int *)topPoint; + origin = pDraw->x; + yoffset = pDraw->y; + vertex2 = vertex1 = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + while(1) { + if (y == intToY(vertex1)) { + do { + if (vertex1p == (int *) ptsIn) + vertex1p = endp; + c = *--vertex1p; + Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) + } while (y >= intToY(vertex1)); + h = dy1; + } else { + Step(x1,dx1,dy1,e1,sign1,step1) + h = intToY(vertex1) - y; + } + if (y == intToY(vertex2)) { + do { + c = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) + } while (y >= intToY(vertex2)); + if (dy2 < h) + h = dy2; + } else { + Step(x2,dx2,dy2,e2,sign2,step2) + if ((c = (intToY(vertex2) - y)) < h) + h = c; + } + + /* fill spans for this segment */ + if(DX1 | DX2) { + if(infoRec->SubsequentSolidFillTrap && (h > 6)) { + if(x1 == x2) { + while(x1 == x2) { + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + if(y == maxy) break; + if(!h) continue; + } + + if(x1 < x2) + (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, + y + yoffset, h, + x1, DX1, dy1, e1, + x2 - 1, DX2, dy2, e2); + else + (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, + y + yoffset, h, + x2, DX2, dy2, e2, + x1 - 1, DX1, dy1, e1); + y += h; + if(--h) { + FixError(x1,dx1,dy1,e1,sign1,step1,h); + FixError(x2,dx2,dy2,e2,sign2,step2,h); + h = 0; + } + } else { + while(1) { + if (x2 > x1) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x1, y + yoffset, x2 - x1, 1); + else if (x1 > x2) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x2, y + yoffset, x1 - x2, 1); + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + } + } else { + if (x2 > x1) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x1, y + yoffset, x2 - x1, h); + else if (x1 > x2) + (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, + x2, y + yoffset, x1 - x2, h); + + y += h; + h = 0; + } + if (y == maxy) break; + } + SET_SYNC_FLAG(infoRec); +} + + + + +void +XAAFillPolygonHelper( + ScrnInfoPtr pScrn, + DDXPointPtr ptsIn, + int count, + DDXPointPtr topPoint, + int y, + int maxy, + int origin, + RectFuncPtr RectFunc, + TrapFuncPtr TrapFunc, + int xorg, + int yorg, + XAACacheInfoPtr pCache +){ + int *vertex1p, *vertex2p, *endp; + int vertex1, vertex2; + int x1 = 0, x2 = 0; + int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; + int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0; + int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0; + int c, h, yoffset; + + + endp = (int*)ptsIn + count; + vertex2p = vertex1p = (int *)topPoint; + yoffset = intToY(origin); + origin = intToX(origin); + vertex2 = vertex1 = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *)ptsIn; + + while(1) { + if (y == intToY(vertex1)) { + do { + if (vertex1p == (int *) ptsIn) + vertex1p = endp; + c = *--vertex1p; + Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1) + } while (y >= intToY(vertex1)); + h = dy1; + } else { + Step(x1,dx1,dy1,e1,sign1,step1) + h = intToY(vertex1) - y; + } + if (y == intToY(vertex2)) { + do { + c = *vertex2p++; + if (vertex2p == endp) + vertex2p = (int *) ptsIn; + Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2) + } while (y >= intToY(vertex2)); + if (dy2 < h) + h = dy2; + } else { + Step(x2,dx2,dy2,e2,sign2,step2) + if ((c = (intToY(vertex2) - y)) < h) + h = c; + } + + /* fill spans for this segment */ + if(DX1 | DX2) { + if(TrapFunc && (h > 6)) { + if(x1 == x2) { + while(x1 == x2) { + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + if(y == maxy) break; + if(!h) continue; + } + + if(x1 < x2) + (*TrapFunc)(pScrn, y + yoffset, h, + x1, DX1, dy1, e1, + x2 - 1, DX2, dy2, e2, xorg, yorg, pCache); + else + (*TrapFunc)(pScrn, y + yoffset, h, + x2, DX2, dy2, e2, + x1 - 1, DX1, dy1, e1, xorg, yorg, pCache); + y += h; + if(--h) { + FixError(x1,dx1,dy1,e1,sign1,step1,h); + FixError(x2,dx2,dy2,e2,sign2,step2,h); + h = 0; + } + } else { + while(1) { + if (x2 > x1) + (*RectFunc)(pScrn, + x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache); + else if (x1 > x2) + (*RectFunc)(pScrn, + x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache); + y++; + if (!--h) break; + Step(x1,dx1,dy1,e1,sign1,step1) + Step(x2,dx2,dy2,e2,sign2,step2) + } + } + } else { + if (x2 > x1) + (*RectFunc)(pScrn, + x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache); + else if (x1 > x2) + (*RectFunc)(pScrn, + x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache); + + y += h; + h = 0; + } + if (y == maxy) break; + } +} + + /*****************\ + | Solid Helpers | + \*****************/ + +static void +SolidTrapHelper( + ScrnInfoPtr pScrn, + int y, int h, + int x1, int dx1, int dy1, int e1, + int x2, int dx2, int dy2, int e2, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentSolidFillTrap) (pScrn, + y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); +} + +static void +SolidRectHelper ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h); +} + + + /*********************\ + | Mono 8x8 Patterns | + \*********************/ + +static void +Mono8x8PatternTrapHelper_ScreenOrigin( + ScrnInfoPtr pScrn, + int y, int h, + int x1, int dx1, int dy1, int e1, + int x2, int dx2, int dy2, int e2, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg, + y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2); +} + +static void +Mono8x8PatternRectHelper_ScreenOrigin ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, + x, y, w, h); +} + +static void +Mono8x8PatternRectHelper ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + xorg = (x - xorg) & 0x07; + yorg = (y - yorg) & 0x07; + + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + int patx = pCache->pat0; + int paty = pCache->pat1; + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } else { + int slot = (yorg << 3) + xorg; + xorg = pCache->x + pCache->offsets[slot].x; + yorg = pCache->y + pCache->offsets[slot].y; + } + } + + + (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg, + x, y, w, h); +} + + + + /****************\ + | Cache Expand | + \****************/ + + +static void +CacheExpandRectHelper ( + ScrnInfoPtr pScrn, + int X, int Y, int Width, int Height, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; + int cacheWidth; + + cacheWidth = (pCache->w * pScrn->bitsPerPixel) / + infoRec->CacheColorExpandDensity; + + phaseY = (Y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (X - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + + while(1) { + w = Width; skipleft = phaseX; x = X; + blit_h = pCache->h - phaseY; + if(blit_h > Height) blit_h = Height; + + while(1) { + blit_w = cacheWidth - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenColorExpandFill)( + pScrn, x, Y, blit_w, blit_h, + pCache->x, pCache->y + phaseY, skipleft); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + Height -= blit_h; + if(!Height) break; + Y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } +} + + + + /**************\ + | Cache Blit | + \**************/ + + +static void +CacheBltRectHelper ( + ScrnInfoPtr pScrn, + int X, int Y, int Width, int Height, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, phaseY, phaseX, skipleft, w, blit_w, blit_h; + + phaseY = (Y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (X - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + + while(1) { + w = Width; skipleft = phaseX; x = X; + blit_h = pCache->h - phaseY; + if(blit_h > Height) blit_h = Height; + + while(1) { + blit_w = pCache->w - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + skipleft, pCache->y + phaseY, + x, Y, blit_w, blit_h); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + Height -= blit_h; + if(!Height) break; + Y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } +} + + + /**********************\ + | Stippled Polygons | + \**********************/ + + +void +XAAFillPolygonStippled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + int origin, type, patx, paty, fg, bg; + int y, maxy, xorg, yorg; + DDXPointPtr topPoint; + XAACacheInfoPtr pCache = NULL; + RectFuncPtr RectFunc = NULL; + TrapFuncPtr TrapFunc = NULL; + + if(!RegionNumRects(pGC->pCompositeClip)) + return; + + if (mode == CoordModePrevious) { + register DDXPointPtr ppt = ptsIn + 1; + + for (origin = 1; origin < count; origin++, ppt++) { + ppt->x += (ppt-1)->x; + ppt->y += (ppt-1)->y; + } + mode = CoordModeOrigin; + } + + if (RegionNumRects(pGC->pCompositeClip) != 1) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + + if(pGC->fillStyle == FillStippled) { + type = (*infoRec->StippledFillChooser)(pGC); + fg = pGC->fgPixel; bg = -1; + } else { + type = (*infoRec->OpaqueStippledFillChooser)(pGC); + fg = pGC->fgPixel; bg = pGC->bgPixel; + } + + + if(!type) { + (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + origin = pDraw->x; + + switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, + origin, &topPoint, &y, &maxy, shape) ) { + case POLY_USE_MI: + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + case POLY_FULLY_CLIPPED: + return; + } + + xorg = (pDraw->x + pGC->patOrg.x); + yorg = (pDraw->y + pGC->patOrg.y); + + + if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) { + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg, + pGC->alu, pGC->planemask); + + RectFunc = SolidRectHelper; + TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL; + } else + switch(type) { + case DO_MONO_8x8: + patx = pPriv->pattern0; paty = pPriv->pattern1; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_SCREEN_ORIGIN) { + xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; + if(infoRec->SubsequentMono8x8PatternFillTrap) + TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; + } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + } else { + pCache = &(infoRec->ScratchCacheInfoRec); + pCache->pat0 = patx; + pCache->pat1 = paty; + } + RectFunc = Mono8x8PatternRectHelper; + } + + (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, + patx, paty, fg, bg, pGC->alu, pGC->planemask); + break; + case DO_CACHE_EXPAND: + pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple); + + (*infoRec->SetupForScreenToScreenColorExpandFill)( + infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask); + + RectFunc = CacheExpandRectHelper; + break; + case DO_CACHE_BLT: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + fg, bg); + (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, + pGC->alu, pGC->planemask, pCache->trans_color); + + RectFunc = CacheBltRectHelper; + break; + default: + return; + } + + + XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, + y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); + + SET_SYNC_FLAG(infoRec); +} + + + + + /*******************\ + | Tiled Polygons | + \*******************/ + + +void +XAAFillPolygonTiled( + DrawablePtr pDraw, + GCPtr pGC, + int shape, + int mode, + int count, + DDXPointPtr ptsIn +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + int origin, type, patx, paty; + int y, maxy, xorg, yorg; + DDXPointPtr topPoint; + XAACacheInfoPtr pCache = NULL; + RectFuncPtr RectFunc = NULL; + TrapFuncPtr TrapFunc = NULL; + + if(!RegionNumRects(pGC->pCompositeClip)) + return; + + if (mode == CoordModePrevious) { + register DDXPointPtr ppt = ptsIn + 1; + + for (origin = 1; origin < count; origin++, ppt++) { + ppt->x += (ppt-1)->x; + ppt->y += (ppt-1)->y; + } + mode = CoordModeOrigin; + } + + if (RegionNumRects(pGC->pCompositeClip) != 1) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + + type = (*infoRec->TiledFillChooser)(pGC); + + if(!type || (type == DO_IMAGE_WRITE)) { + (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + if(type == DO_COLOR_8x8) { + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + return; + } + + origin = pDraw->x; + + switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents, + origin, &topPoint, &y, &maxy, shape) ) { + case POLY_USE_MI: + miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn); + case POLY_FULLY_CLIPPED: + return; + } + + xorg = (pDraw->x + pGC->patOrg.x); + yorg = (pDraw->y + pGC->patOrg.y); + + switch(type) { + case DO_MONO_8x8: + patx = pPriv->pattern0; paty = pPriv->pattern1; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_SCREEN_ORIGIN) { + xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07; + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) { + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + RectFunc = Mono8x8PatternRectHelper_ScreenOrigin; + if(infoRec->SubsequentMono8x8PatternFillTrap) + TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin; + } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */ + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)( + infoRec->pScrn, patx, paty); + patx = pCache->x; paty = pCache->y; + } + else { + pCache = &(infoRec->ScratchCacheInfoRec); + pCache->pat0 = patx; + pCache->pat1 = paty; + } + RectFunc = Mono8x8PatternRectHelper; + } + + (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn, + patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask); + break; + case DO_CACHE_BLT: + pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); + (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, + pGC->alu, pGC->planemask, -1); + + RectFunc = CacheBltRectHelper; + break; + case DO_PIXMAP_COPY: + pCache = &(infoRec->ScratchCacheInfoRec); + pCache->x = pPriv->offscreenArea->box.x1; + pCache->y = pPriv->offscreenArea->box.y1; + pCache->w = pCache->orig_w = + pPriv->offscreenArea->box.x2 - pCache->x; + pCache->h = pCache->orig_h = + pPriv->offscreenArea->box.y2 - pCache->y; + + (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1, + pGC->alu, pGC->planemask, -1); + + RectFunc = CacheBltRectHelper; + break; + default: + return; + } + + XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint, + y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache); + + SET_SYNC_FLAG(infoRec); +} + + diff --git a/xorg-server/hw/xfree86/xaa/xaaFillRect.c b/xorg-server/hw/xfree86/xaa/xaaFillRect.c index 0b83ef3ee..724ff37a2 100644 --- a/xorg-server/hw/xfree86/xaa/xaaFillRect.c +++ b/xorg-server/hw/xfree86/xaa/xaaFillRect.c @@ -1,1095 +1,1095 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - - -static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int); -static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int); -static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int); -static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int); - -void -XAAPolyFillRect( - DrawablePtr pDraw, - GCPtr pGC, - int nrectFill, /* number of rectangles to fill */ - xRectangle *prectInit /* Pointer to first rectangle to fill */ -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int xorg = pDraw->x; - int yorg = pDraw->y; - int type = 0; - ClipAndRenderRectsFunc function; - - if((nrectFill <= 0) || !pGC->planemask) - return; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - switch(pGC->fillStyle) { - case FillSolid: - type = DO_SOLID; - break; - case FillStippled: - type = (*infoRec->StippledFillChooser)(pGC); - break; - case FillOpaqueStippled: - if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects && - CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) && - CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) && - CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) && - CHECK_FG(pGC,infoRec->FillSolidRectsFlags)) - type = DO_SOLID; - else - type = (*infoRec->OpaqueStippledFillChooser)(pGC); - break; - case FillTiled: - type = (*infoRec->TiledFillChooser)(pGC); - break; - } - - switch(type) { - case DO_SOLID: - function = XAARenderSolidRects; - break; - case DO_COLOR_8x8: - function = XAARenderColor8x8Rects; - break; - case DO_MONO_8x8: - function = XAARenderMono8x8Rects; - break; - case DO_CACHE_BLT: - function = XAARenderCacheBltRects; - break; - case DO_COLOR_EXPAND: - function = XAARenderColorExpandRects; - break; - case DO_CACHE_EXPAND: - function = XAARenderCacheExpandRects; - break; - case DO_IMAGE_WRITE: - function = XAARenderImageWriteRects; - break; - case DO_PIXMAP_COPY: - function = XAARenderPixmapCopyRects; - break; - default: - (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit); - return; - } - - if(xorg | yorg) { - int n = nrectFill; - xRectangle *prect = prectInit; - - while(n--) { - prect->x += xorg; - prect->y += yorg; - prect++; - } - } - - - XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg); -} - - - - /*********************\ - | Solid Rects | - \*********************/ - -static void -XAARenderSolidRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - - (*infoRec->FillSolidRects) (infoRec->pScrn, - pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes); -} - - - /************************\ - | Mono 8x8 Rects | - \************************/ - -static void -XAARenderMono8x8Rects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - fg = pPriv->fg; bg = pPriv->bg; - break; - default: /* Muffle compiler */ - pPriv = NULL; /* Kaboom */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn, - fg, bg, pGC->alu, pGC->planemask, - nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); -} - - /*************************\ - | Color 8x8 Rects | - \*************************/ - -static void -XAARenderColor8x8Rects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - PixmapPtr pPix; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPix = pGC->tile.pixmap; - fg = -1; bg = -1; - break; - default: /* Muffle compiler */ - pPix = NULL; - fg = -1; bg = -1; - break; - } - - pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); - (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, - pGC->alu, pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); -} - - - /****************************\ - | Color Expand Rects | - \****************************/ - -static void -XAARenderColorExpandRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); -} - - - /*************************\ - | Cache Blt Rects | - \*************************/ - -static void -XAARenderCacheBltRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - - switch(pGC->fillStyle) { - case FillStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, -1); - break; - case FillOpaqueStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, pGC->bgPixel); - break; - case FillTiled: - pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); - break; - default: /* Muffle compiler */ - pCache = NULL; - break; - } - - (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, - pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); -} - - - /****************************\ - | Cache Expand Rects | - \****************************/ - -static void -XAARenderCacheExpandRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); -} - - - - /***************************\ - | Image Write Rects | - \***************************/ - -static void -XAARenderImageWriteRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - - (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu, - pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->tile.pixmap); -} - - - - /***************************\ - | Pixmap Copy Rects | - \***************************/ - -static void -XAARenderPixmapCopyRects( - GCPtr pGC, - int nboxes, - BoxPtr pClipBoxes, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - - pCache->x = pPriv->offscreenArea->box.x1; - pCache->y = pPriv->offscreenArea->box.y1; - pCache->w = pCache->orig_w = - pPriv->offscreenArea->box.x2 - pCache->x; - pCache->h = pCache->orig_h = - pPriv->offscreenArea->box.y2 - pCache->y; - pCache->trans_color = -1; - - (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, - pGC->planemask, nboxes, pClipBoxes, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pCache); -} - - - - /************\ - | Solid | - \************/ - -void -XAAFillSolidRects( - ScrnInfoPtr pScrn, - int fg, int rop, - unsigned int planemask, - int nBox, /* number of rectangles to fill */ - BoxPtr pBox /* Pointer to first rectangle to fill */ -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); - while(nBox--) { - (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - SET_SYNC_FLAG(infoRec); -} - - - - - /*********************\ - | 8x8 Mono Patterns | - \*********************/ - - -void -XAAFillMono8x8PatternRectsScreenOrigin( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int pattern0, int pattern1, - int xorigin, int yorigin -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - - if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = - (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - while(nBox--) { - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - SET_SYNC_FLAG(infoRec); -} - -void -XAAFillMono8x8PatternRects( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int pattern0, int pattern1, - int xorigin, int yorigin -) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg, yorg; - XAACacheInfoPtr pCache = NULL; - - - if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - } - - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - - while(nBox--) { - xorg = (pBox->x1 - xorigin) & 0x07; - yorg = (pBox->y1 - yorigin) & 0x07; - - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - patx = pattern0; paty = pattern1; - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } else { - int slot = (yorg << 3) + xorg; - xorg = patx + pCache->offsets[slot].x; - yorg = paty + pCache->offsets[slot].y; - } - } - - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - /**********************\ - | 8x8 Color Patterns | - \**********************/ - - -void -XAAFillColor8x8PatternRectsScreenOrigin( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorigin, int yorigin, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pCache->x, paty = pCache->y; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - paty += pCache->offsets[slot].y; - patx += pCache->offsets[slot].x; - xorg = patx; yorg = paty; - } - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, - rop, planemask, pCache->trans_color); - - while(nBox--) { - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - SET_SYNC_FLAG(infoRec); -} - -void -XAAFillColor8x8PatternRects( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorigin, int yorigin, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int xorg, yorg; - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, - rop, planemask, pCache->trans_color); - - while(nBox--) { - xorg = (pBox->x1 - xorigin) & 0x07; - yorg = (pBox->y1 - yorigin) & 0x07; - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - yorg = pCache->y + pCache->offsets[slot].y; - xorg = pCache->x + pCache->offsets[slot].x; - } - - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - /***************\ - | Cache Blits | - \***************/ - -void -XAAFillCacheBltRects( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - XAACacheInfoPtr pCache -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; - - (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, - pCache->trans_color); - - while(nBox--) { - y = pBox->y1; - phaseY = (y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (pBox->x1 - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - height = pBox->y2 - y; - width = pBox->x2 - pBox->x1; - -#if 0 - if (rop == GXcopy) { - while(1) { - w = width; skipleft = phaseX; x = pBox->x1; - blit_h = pCache->h - phaseY; - if(blit_h > height) blit_h = height; - - while(1) { - blit_w = pCache->w - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + skipleft, pCache->y + phaseY, - x, y, blit_w, blit_h); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - if(blit_w >= pCache->orig_w) break; - } - - /* Expand horizontally */ - if (w) { - skipleft -= phaseX; - if (skipleft < 0) skipleft += pCache->orig_w; - blit_w = x - pBox->x1 - skipleft; - while(w) { - if (blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pBox->x1 + skipleft, y, x, y, blit_w, blit_h); - w -= blit_w; - x += blit_w; - blit_w <<= 1; - } - } - - height -= blit_h; - if(!height) break; - y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - if(blit_h >= pCache->orig_h) break; - } - - /* Expand vertically */ - if (height) { - blit_w = pBox->x2 - pBox->x1; - phaseY -= (pBox->y1 - yorg) % pCache->orig_h; - if (phaseY < 0) phaseY += pCache->orig_h; - blit_h = y - pBox->y1 - phaseY; - while(height) { - if (blit_h > height) blit_h = height; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1, - pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h); - height -= blit_h; - y += blit_h; - blit_h <<= 1; - } - } - } else -#endif - { - while(1) { - w = width; skipleft = phaseX; x = pBox->x1; - blit_h = pCache->h - phaseY; - if(blit_h > height) blit_h = height; - - while(1) { - blit_w = pCache->w - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + skipleft, pCache->y + phaseY, - x, y, blit_w, blit_h); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - height -= blit_h; - if(!height) break; - y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } - } - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - - - /*******************\ - | Cache Expansion | - \*******************/ - - - -void -XAAFillCacheExpandRects( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - PixmapPtr pPix -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; - int cacheWidth; - XAACacheInfoPtr pCache; - - pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); - - cacheWidth = (pCache->w * pScrn->bitsPerPixel) / - infoRec->CacheColorExpandDensity; - - (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, - planemask); - - while(nBox--) { - y = pBox->y1; - phaseY = (y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - phaseX = (pBox->x1 - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - height = pBox->y2 - y; - width = pBox->x2 - pBox->x1; - - while(1) { - w = width; skipleft = phaseX; x = pBox->x1; - blit_h = pCache->h - phaseY; - if(blit_h > height) blit_h = height; - - while(1) { - blit_w = cacheWidth - skipleft; - if(blit_w > w) blit_w = w; - (*infoRec->SubsequentScreenToScreenColorExpandFill)( - pScrn, x, y, blit_w, blit_h, - pCache->x, pCache->y + phaseY, skipleft); - w -= blit_w; - if(!w) break; - x += blit_w; - skipleft = (skipleft + blit_w) % pCache->orig_w; - } - height -= blit_h; - if(!height) break; - y += blit_h; - phaseY = (phaseY + blit_h) % pCache->orig_h; - } - pBox++; - } - - SET_SYNC_FLAG(infoRec); -} - - - /******************\ - | Image Writes | - \******************/ - - - -/* This requires all LEFT_EDGE clipping. You get too many problems - with reading past the edge of the pattern otherwise */ - -static void -WriteColumn( - ScrnInfoPtr pScrn, - unsigned char *pSrc, - int x, int y, int w, int h, - int xoff, int yoff, - int pHeight, - int srcwidth, - int Bpp -) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - unsigned char *src; - Bool PlusOne = FALSE; - int skipleft, dwords; - - pSrc += (Bpp * xoff); - - if((skipleft = (long)pSrc & 0x03L)) { - if(Bpp == 3) - skipleft = 4 - skipleft; - else - skipleft /= Bpp; - - x -= skipleft; - w += skipleft; - - if(Bpp == 3) - pSrc -= 3 * skipleft; - else /* is this Alpha friendly ? */ - pSrc = (unsigned char*)((long)pSrc & ~0x03L); - } - - src = pSrc + (yoff * srcwidth); - - dwords = bytes_to_int32(w * Bpp); - - if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && - ((dwords * h) & 0x01)) { - PlusOne = TRUE; - } - - (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft); - - if(dwords > infoRec->ImageWriteRange) { - while(h--) { - XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase, - (CARD32*)src, dwords); - src += srcwidth; - yoff++; - if(yoff >= pHeight) { - yoff = 0; - src = pSrc; - } - } - } else { - if(srcwidth == (dwords << 2)) { - int maxLines = infoRec->ImageWriteRange/dwords; - int step; - - while(h) { - step = pHeight - yoff; - if(step > maxLines) step = maxLines; - if(step > h) step = h; - - XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, - (CARD32*)src, dwords * step); - - src += (srcwidth * step); - yoff += step; - if(yoff >= pHeight) { - yoff = 0; - src = pSrc; - } - h -= step; - } - } else { - while(h--) { - XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, - (CARD32*)src, dwords); - src += srcwidth; - yoff++; - if(yoff >= pHeight) { - yoff = 0; - src = pSrc; - } - } - } - } - - if(PlusOne) { - CARD32* base = (CARD32*)infoRec->ImageWriteBase; - *base = 0x00000000; - } -} - -void -XAAFillImageWriteRects( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int nBox, - BoxPtr pBox, - int xorg, int yorg, - PixmapPtr pPix -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, phaseY, phaseX, height, width, blit_w; - int pHeight = pPix->drawable.height; - int pWidth = pPix->drawable.width; - int Bpp = pPix->drawable.bitsPerPixel >> 3; - int srcwidth = pPix->devKind; - - (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1, - pPix->drawable.bitsPerPixel, pPix->drawable.depth); - - while(nBox--) { - x = pBox->x1; - phaseY = (pBox->y1 - yorg) % pHeight; - if(phaseY < 0) phaseY += pHeight; - phaseX = (x - xorg) % pWidth; - if(phaseX < 0) phaseX += pWidth; - height = pBox->y2 - pBox->y1; - width = pBox->x2 - x; - - while(1) { - blit_w = pWidth - phaseX; - if(blit_w > width) blit_w = width; - - WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1, - blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp); - - width -= blit_w; - if(!width) break; - x += blit_w; - phaseX = (phaseX + blit_w) % pWidth; - } - pBox++; - } - - if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE) - (*infoRec->Sync)(pScrn); - else SET_SYNC_FLAG(infoRec); -} - - - /*************\ - | Utilities | - \*************/ - - -void -XAAClipAndRenderRects( - GCPtr pGC, - ClipAndRenderRectsFunc BoxFunc, - int nrectFill, - xRectangle *prect, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int Right, Bottom, MaxBoxes; - BoxPtr pextent, pboxClipped, pboxClippedBase; - - MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec); - pboxClippedBase = (BoxPtr)infoRec->PreAllocMem; - pboxClipped = pboxClippedBase; - - if (REGION_NUM_RECTS(pGC->pCompositeClip) == 1) { - pextent = REGION_RECTS(pGC->pCompositeClip); - while (nrectFill--) { - pboxClipped->x1 = max(pextent->x1, prect->x); - pboxClipped->y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - pboxClipped->x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - pboxClipped->y2 = min(pextent->y2, Bottom); - - prect++; - if ((pboxClipped->x1 < pboxClipped->x2) && - (pboxClipped->y1 < pboxClipped->y2)) { - pboxClipped++; - if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { - (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); - pboxClipped = pboxClippedBase; - } - } - } - } else { - pextent = REGION_EXTENTS(pGC->pScreen, pGC->pCompositeClip); - while (nrectFill--) { - int n; - BoxRec box, *pbox; - - box.x1 = max(pextent->x1, prect->x); - box.y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - box.x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - box.y2 = min(pextent->y2, Bottom); - - prect++; - - if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) - continue; - - n = REGION_NUM_RECTS (pGC->pCompositeClip); - pbox = REGION_RECTS(pGC->pCompositeClip); - - /* clip the rectangle to each box in the clip region - this is logically equivalent to calling Intersect() - */ - while(n--) { - pboxClipped->x1 = max(box.x1, pbox->x1); - pboxClipped->y1 = max(box.y1, pbox->y1); - pboxClipped->x2 = min(box.x2, pbox->x2); - pboxClipped->y2 = min(box.y2, pbox->y2); - pbox++; - - /* see if clipping left anything */ - if(pboxClipped->x1 < pboxClipped->x2 && - pboxClipped->y1 < pboxClipped->y2) { - pboxClipped++; - if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { - (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); - pboxClipped = pboxClippedBase; - } - } - } - } - } - - if(pboxClipped != pboxClippedBase) - (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase, - xorg, yorg); -} - - -int -XAAGetRectClipBoxes( - GCPtr pGC, - BoxPtr pboxClippedBase, - int nrectFill, - xRectangle *prectInit -){ - int Right, Bottom; - BoxPtr pextent, pboxClipped = pboxClippedBase; - xRectangle *prect = prectInit; - RegionPtr prgnClip = pGC->pCompositeClip; - - if (REGION_NUM_RECTS(prgnClip) == 1) { - pextent = REGION_RECTS(prgnClip); - while (nrectFill--) { - pboxClipped->x1 = max(pextent->x1, prect->x); - pboxClipped->y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - pboxClipped->x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - pboxClipped->y2 = min(pextent->y2, Bottom); - - prect++; - if ((pboxClipped->x1 < pboxClipped->x2) && - (pboxClipped->y1 < pboxClipped->y2)) { - pboxClipped++; - } - } - } else { - pextent = REGION_EXTENTS(pGC->pScreen, prgnClip); - while (nrectFill--) { - int n; - BoxRec box, *pbox; - - box.x1 = max(pextent->x1, prect->x); - box.y1 = max(pextent->y1, prect->y); - - Right = (int)prect->x + (int)prect->width; - box.x2 = min(pextent->x2, Right); - - Bottom = (int)prect->y + (int)prect->height; - box.y2 = min(pextent->y2, Bottom); - - prect++; - - if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) - continue; - - n = REGION_NUM_RECTS (prgnClip); - pbox = REGION_RECTS(prgnClip); - - /* clip the rectangle to each box in the clip region - this is logically equivalent to calling Intersect() - */ - while(n--) { - pboxClipped->x1 = max(box.x1, pbox->x1); - pboxClipped->y1 = max(box.y1, pbox->y1); - pboxClipped->x2 = min(box.x2, pbox->x2); - pboxClipped->y2 = min(box.y2, pbox->y2); - pbox++; - - /* see if clipping left anything */ - if(pboxClipped->x1 < pboxClipped->x2 && - pboxClipped->y1 < pboxClipped->y2) { - pboxClipped++; - } - } - } - } - - return(pboxClipped - pboxClippedBase); -} - + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int); +static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int); +static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int); +static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int); + +void +XAAPolyFillRect( + DrawablePtr pDraw, + GCPtr pGC, + int nrectFill, /* number of rectangles to fill */ + xRectangle *prectInit /* Pointer to first rectangle to fill */ +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int xorg = pDraw->x; + int yorg = pDraw->y; + int type = 0; + ClipAndRenderRectsFunc function; + + if((nrectFill <= 0) || !pGC->planemask) + return; + + if(!RegionNumRects(pGC->pCompositeClip)) + return; + + switch(pGC->fillStyle) { + case FillSolid: + type = DO_SOLID; + break; + case FillStippled: + type = (*infoRec->StippledFillChooser)(pGC); + break; + case FillOpaqueStippled: + if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects && + CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) && + CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) && + CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) && + CHECK_FG(pGC,infoRec->FillSolidRectsFlags)) + type = DO_SOLID; + else + type = (*infoRec->OpaqueStippledFillChooser)(pGC); + break; + case FillTiled: + type = (*infoRec->TiledFillChooser)(pGC); + break; + } + + switch(type) { + case DO_SOLID: + function = XAARenderSolidRects; + break; + case DO_COLOR_8x8: + function = XAARenderColor8x8Rects; + break; + case DO_MONO_8x8: + function = XAARenderMono8x8Rects; + break; + case DO_CACHE_BLT: + function = XAARenderCacheBltRects; + break; + case DO_COLOR_EXPAND: + function = XAARenderColorExpandRects; + break; + case DO_CACHE_EXPAND: + function = XAARenderCacheExpandRects; + break; + case DO_IMAGE_WRITE: + function = XAARenderImageWriteRects; + break; + case DO_PIXMAP_COPY: + function = XAARenderPixmapCopyRects; + break; + default: + (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit); + return; + } + + if(xorg | yorg) { + int n = nrectFill; + xRectangle *prect = prectInit; + + while(n--) { + prect->x += xorg; + prect->y += yorg; + prect++; + } + } + + + XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg); +} + + + + /*********************\ + | Solid Rects | + \*********************/ + +static void +XAARenderSolidRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + (*infoRec->FillSolidRects) (infoRec->pScrn, + pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes); +} + + + /************************\ + | Mono 8x8 Rects | + \************************/ + +static void +XAARenderMono8x8Rects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + fg = pPriv->fg; bg = pPriv->bg; + break; + default: /* Muffle compiler */ + pPriv = NULL; /* Kaboom */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn, + fg, bg, pGC->alu, pGC->planemask, + nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); +} + + /*************************\ + | Color 8x8 Rects | + \*************************/ + +static void +XAARenderColor8x8Rects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + PixmapPtr pPix; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPix = pGC->tile.pixmap; + fg = -1; bg = -1; + break; + default: /* Muffle compiler */ + pPix = NULL; + fg = -1; bg = -1; + break; + } + + pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); + (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, + pGC->alu, pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); +} + + + /****************************\ + | Color Expand Rects | + \****************************/ + +static void +XAARenderColorExpandRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); +} + + + /*************************\ + | Cache Blt Rects | + \*************************/ + +static void +XAARenderCacheBltRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + + switch(pGC->fillStyle) { + case FillStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, -1); + break; + case FillOpaqueStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, pGC->bgPixel); + break; + case FillTiled: + pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); + break; + default: /* Muffle compiler */ + pCache = NULL; + break; + } + + (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, + pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache); +} + + + /****************************\ + | Cache Expand Rects | + \****************************/ + +static void +XAARenderCacheExpandRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); +} + + + + /***************************\ + | Image Write Rects | + \***************************/ + +static void +XAARenderImageWriteRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu, + pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->tile.pixmap); +} + + + + /***************************\ + | Pixmap Copy Rects | + \***************************/ + +static void +XAARenderPixmapCopyRects( + GCPtr pGC, + int nboxes, + BoxPtr pClipBoxes, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + + pCache->x = pPriv->offscreenArea->box.x1; + pCache->y = pPriv->offscreenArea->box.y1; + pCache->w = pCache->orig_w = + pPriv->offscreenArea->box.x2 - pCache->x; + pCache->h = pCache->orig_h = + pPriv->offscreenArea->box.y2 - pCache->y; + pCache->trans_color = -1; + + (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu, + pGC->planemask, nboxes, pClipBoxes, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pCache); +} + + + + /************\ + | Solid | + \************/ + +void +XAAFillSolidRects( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int nBox, /* number of rectangles to fill */ + BoxPtr pBox /* Pointer to first rectangle to fill */ +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); + while(nBox--) { + (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + SET_SYNC_FLAG(infoRec); +} + + + + + /*********************\ + | 8x8 Mono Patterns | + \*********************/ + + +void +XAAFillMono8x8PatternRectsScreenOrigin( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pattern0, int pattern1, + int xorigin, int yorigin +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + + if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = + (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + while(nBox--) { + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + SET_SYNC_FLAG(infoRec); +} + +void +XAAFillMono8x8PatternRects( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int pattern0, int pattern1, + int xorigin, int yorigin +) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg, yorg; + XAACacheInfoPtr pCache = NULL; + + + if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + } + + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + + while(nBox--) { + xorg = (pBox->x1 - xorigin) & 0x07; + yorg = (pBox->y1 - yorigin) & 0x07; + + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + patx = pattern0; paty = pattern1; + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } else { + int slot = (yorg << 3) + xorg; + xorg = patx + pCache->offsets[slot].x; + yorg = paty + pCache->offsets[slot].y; + } + } + + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + /**********************\ + | 8x8 Color Patterns | + \**********************/ + + +void +XAAFillColor8x8PatternRectsScreenOrigin( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorigin, int yorigin, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pCache->x, paty = pCache->y; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + paty += pCache->offsets[slot].y; + patx += pCache->offsets[slot].x; + xorg = patx; yorg = paty; + } + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, + rop, planemask, pCache->trans_color); + + while(nBox--) { + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + SET_SYNC_FLAG(infoRec); +} + +void +XAAFillColor8x8PatternRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorigin, int yorigin, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int xorg, yorg; + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, + rop, planemask, pCache->trans_color); + + while(nBox--) { + xorg = (pBox->x1 - xorigin) & 0x07; + yorg = (pBox->y1 - yorigin) & 0x07; + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + yorg = pCache->y + pCache->offsets[slot].y; + xorg = pCache->x + pCache->offsets[slot].x; + } + + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + /***************\ + | Cache Blits | + \***************/ + +void +XAAFillCacheBltRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + XAACacheInfoPtr pCache +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; + + (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, + pCache->trans_color); + + while(nBox--) { + y = pBox->y1; + phaseY = (y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (pBox->x1 - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + height = pBox->y2 - y; + width = pBox->x2 - pBox->x1; + +#if 0 + if (rop == GXcopy) { + while(1) { + w = width; skipleft = phaseX; x = pBox->x1; + blit_h = pCache->h - phaseY; + if(blit_h > height) blit_h = height; + + while(1) { + blit_w = pCache->w - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + skipleft, pCache->y + phaseY, + x, y, blit_w, blit_h); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + if(blit_w >= pCache->orig_w) break; + } + + /* Expand horizontally */ + if (w) { + skipleft -= phaseX; + if (skipleft < 0) skipleft += pCache->orig_w; + blit_w = x - pBox->x1 - skipleft; + while(w) { + if (blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pBox->x1 + skipleft, y, x, y, blit_w, blit_h); + w -= blit_w; + x += blit_w; + blit_w <<= 1; + } + } + + height -= blit_h; + if(!height) break; + y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + if(blit_h >= pCache->orig_h) break; + } + + /* Expand vertically */ + if (height) { + blit_w = pBox->x2 - pBox->x1; + phaseY -= (pBox->y1 - yorg) % pCache->orig_h; + if (phaseY < 0) phaseY += pCache->orig_h; + blit_h = y - pBox->y1 - phaseY; + while(height) { + if (blit_h > height) blit_h = height; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1, + pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h); + height -= blit_h; + y += blit_h; + blit_h <<= 1; + } + } + } else +#endif + { + while(1) { + w = width; skipleft = phaseX; x = pBox->x1; + blit_h = pCache->h - phaseY; + if(blit_h > height) blit_h = height; + + while(1) { + blit_w = pCache->w - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + skipleft, pCache->y + phaseY, + x, y, blit_w, blit_h); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + height -= blit_h; + if(!height) break; + y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } + } + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + + + /*******************\ + | Cache Expansion | + \*******************/ + + + +void +XAAFillCacheExpandRects( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h; + int cacheWidth; + XAACacheInfoPtr pCache; + + pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); + + cacheWidth = (pCache->w * pScrn->bitsPerPixel) / + infoRec->CacheColorExpandDensity; + + (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, + planemask); + + while(nBox--) { + y = pBox->y1; + phaseY = (y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + phaseX = (pBox->x1 - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + height = pBox->y2 - y; + width = pBox->x2 - pBox->x1; + + while(1) { + w = width; skipleft = phaseX; x = pBox->x1; + blit_h = pCache->h - phaseY; + if(blit_h > height) blit_h = height; + + while(1) { + blit_w = cacheWidth - skipleft; + if(blit_w > w) blit_w = w; + (*infoRec->SubsequentScreenToScreenColorExpandFill)( + pScrn, x, y, blit_w, blit_h, + pCache->x, pCache->y + phaseY, skipleft); + w -= blit_w; + if(!w) break; + x += blit_w; + skipleft = (skipleft + blit_w) % pCache->orig_w; + } + height -= blit_h; + if(!height) break; + y += blit_h; + phaseY = (phaseY + blit_h) % pCache->orig_h; + } + pBox++; + } + + SET_SYNC_FLAG(infoRec); +} + + + /******************\ + | Image Writes | + \******************/ + + + +/* This requires all LEFT_EDGE clipping. You get too many problems + with reading past the edge of the pattern otherwise */ + +static void +WriteColumn( + ScrnInfoPtr pScrn, + unsigned char *pSrc, + int x, int y, int w, int h, + int xoff, int yoff, + int pHeight, + int srcwidth, + int Bpp +) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + unsigned char *src; + Bool PlusOne = FALSE; + int skipleft, dwords; + + pSrc += (Bpp * xoff); + + if((skipleft = (long)pSrc & 0x03L)) { + if(Bpp == 3) + skipleft = 4 - skipleft; + else + skipleft /= Bpp; + + x -= skipleft; + w += skipleft; + + if(Bpp == 3) + pSrc -= 3 * skipleft; + else /* is this Alpha friendly ? */ + pSrc = (unsigned char*)((long)pSrc & ~0x03L); + } + + src = pSrc + (yoff * srcwidth); + + dwords = bytes_to_int32(w * Bpp); + + if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) && + ((dwords * h) & 0x01)) { + PlusOne = TRUE; + } + + (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft); + + if(dwords > infoRec->ImageWriteRange) { + while(h--) { + XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src += srcwidth; + yoff++; + if(yoff >= pHeight) { + yoff = 0; + src = pSrc; + } + } + } else { + if(srcwidth == (dwords << 2)) { + int maxLines = infoRec->ImageWriteRange/dwords; + int step; + + while(h) { + step = pHeight - yoff; + if(step > maxLines) step = maxLines; + if(step > h) step = h; + + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords * step); + + src += (srcwidth * step); + yoff += step; + if(yoff >= pHeight) { + yoff = 0; + src = pSrc; + } + h -= step; + } + } else { + while(h--) { + XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase, + (CARD32*)src, dwords); + src += srcwidth; + yoff++; + if(yoff >= pHeight) { + yoff = 0; + src = pSrc; + } + } + } + } + + if(PlusOne) { + CARD32* base = (CARD32*)infoRec->ImageWriteBase; + *base = 0x00000000; + } +} + +void +XAAFillImageWriteRects( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int nBox, + BoxPtr pBox, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, phaseY, phaseX, height, width, blit_w; + int pHeight = pPix->drawable.height; + int pWidth = pPix->drawable.width; + int Bpp = pPix->drawable.bitsPerPixel >> 3; + int srcwidth = pPix->devKind; + + (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1, + pPix->drawable.bitsPerPixel, pPix->drawable.depth); + + while(nBox--) { + x = pBox->x1; + phaseY = (pBox->y1 - yorg) % pHeight; + if(phaseY < 0) phaseY += pHeight; + phaseX = (x - xorg) % pWidth; + if(phaseX < 0) phaseX += pWidth; + height = pBox->y2 - pBox->y1; + width = pBox->x2 - x; + + while(1) { + blit_w = pWidth - phaseX; + if(blit_w > width) blit_w = width; + + WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1, + blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp); + + width -= blit_w; + if(!width) break; + x += blit_w; + phaseX = (phaseX + blit_w) % pWidth; + } + pBox++; + } + + if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE) + (*infoRec->Sync)(pScrn); + else SET_SYNC_FLAG(infoRec); +} + + + /*************\ + | Utilities | + \*************/ + + +void +XAAClipAndRenderRects( + GCPtr pGC, + ClipAndRenderRectsFunc BoxFunc, + int nrectFill, + xRectangle *prect, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int Right, Bottom, MaxBoxes; + BoxPtr pextent, pboxClipped, pboxClippedBase; + + MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec); + pboxClippedBase = (BoxPtr)infoRec->PreAllocMem; + pboxClipped = pboxClippedBase; + + if (RegionNumRects(pGC->pCompositeClip) == 1) { + pextent = RegionRects(pGC->pCompositeClip); + while (nrectFill--) { + pboxClipped->x1 = max(pextent->x1, prect->x); + pboxClipped->y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + pboxClipped->x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + pboxClipped->y2 = min(pextent->y2, Bottom); + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) { + pboxClipped++; + if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { + (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); + pboxClipped = pboxClippedBase; + } + } + } + } else { + pextent = RegionExtents(pGC->pCompositeClip); + while (nrectFill--) { + int n; + BoxRec box, *pbox; + + box.x1 = max(pextent->x1, prect->x); + box.y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + box.x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + box.y2 = min(pextent->y2, Bottom); + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = RegionNumRects (pGC->pCompositeClip); + pbox = RegionRects(pGC->pCompositeClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) { + pboxClipped++; + if(pboxClipped >= (pboxClippedBase + MaxBoxes)) { + (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg); + pboxClipped = pboxClippedBase; + } + } + } + } + } + + if(pboxClipped != pboxClippedBase) + (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase, + xorg, yorg); +} + + +int +XAAGetRectClipBoxes( + GCPtr pGC, + BoxPtr pboxClippedBase, + int nrectFill, + xRectangle *prectInit +){ + int Right, Bottom; + BoxPtr pextent, pboxClipped = pboxClippedBase; + xRectangle *prect = prectInit; + RegionPtr prgnClip = pGC->pCompositeClip; + + if (RegionNumRects(prgnClip) == 1) { + pextent = RegionRects(prgnClip); + while (nrectFill--) { + pboxClipped->x1 = max(pextent->x1, prect->x); + pboxClipped->y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + pboxClipped->x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + pboxClipped->y2 = min(pextent->y2, Bottom); + + prect++; + if ((pboxClipped->x1 < pboxClipped->x2) && + (pboxClipped->y1 < pboxClipped->y2)) { + pboxClipped++; + } + } + } else { + pextent = RegionExtents(prgnClip); + while (nrectFill--) { + int n; + BoxRec box, *pbox; + + box.x1 = max(pextent->x1, prect->x); + box.y1 = max(pextent->y1, prect->y); + + Right = (int)prect->x + (int)prect->width; + box.x2 = min(pextent->x2, Right); + + Bottom = (int)prect->y + (int)prect->height; + box.y2 = min(pextent->y2, Bottom); + + prect++; + + if ((box.x1 >= box.x2) || (box.y1 >= box.y2)) + continue; + + n = RegionNumRects (prgnClip); + pbox = RegionRects(prgnClip); + + /* clip the rectangle to each box in the clip region + this is logically equivalent to calling Intersect() + */ + while(n--) { + pboxClipped->x1 = max(box.x1, pbox->x1); + pboxClipped->y1 = max(box.y1, pbox->y1); + pboxClipped->x2 = min(box.x2, pbox->x2); + pboxClipped->y2 = min(box.y2, pbox->y2); + pbox++; + + /* see if clipping left anything */ + if(pboxClipped->x1 < pboxClipped->x2 && + pboxClipped->y1 < pboxClipped->y2) { + pboxClipped++; + } + } + } + } + + return pboxClipped - pboxClippedBase; +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaGC.c b/xorg-server/hw/xfree86/xaa/xaaGC.c index d029d982b..4bd3750cb 100644 --- a/xorg-server/hw/xfree86/xaa/xaaGC.c +++ b/xorg-server/hw/xfree86/xaa/xaaGC.c @@ -243,8 +243,7 @@ XAADestroyGC(GCPtr pGC) if(pGCPriv->XAAOps != &XAAFallbackOps) free(pGCPriv->XAAOps); - if(pGCPriv->DashPattern) - free(pGCPriv->DashPattern); + free(pGCPriv->DashPattern); (*pGC->funcs->DestroyGC)(pGC); XAA_GC_FUNC_EPILOGUE (pGC); diff --git a/xorg-server/hw/xfree86/xaa/xaaImage.c b/xorg-server/hw/xfree86/xaa/xaaImage.c index c8d98c7d0..1967c5e0e 100644 --- a/xorg-server/hw/xfree86/xaa/xaaImage.c +++ b/xorg-server/hw/xfree86/xaa/xaaImage.c @@ -406,7 +406,7 @@ XAAPutImage( Bool depthBug = FALSE; if(!w || !h) return; - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; depthBug = XAA_DEPTH_BUG(pGC); @@ -431,7 +431,7 @@ XAAPutImage( !(infoRec->WriteBitmapFlags & NO_PLANEMASK) && !(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))){ - int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip); + int MaxBoxes = RegionNumRects(pGC->pCompositeClip); BoxPtr pbox, pClipBoxes; int nboxes, srcx, srcy, srcwidth; xRectangle TheRect; diff --git a/xorg-server/hw/xfree86/xaa/xaaInit.c b/xorg-server/hw/xfree86/xaa/xaaInit.c index 58efb6a82..a4b235acf 100644 --- a/xorg-server/hw/xfree86/xaa/xaaInit.c +++ b/xorg-server/hw/xfree86/xaa/xaaInit.c @@ -42,12 +42,12 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet); static void XAAEnableDisableFBAccess (int index, Bool enable); static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask); -static int XAAScreenKeyIndex; -static DevPrivateKey XAAScreenKey = &XAAScreenKeyIndex; -static int XAAGCKeyIndex; -static DevPrivateKey XAAGCKey = &XAAGCKeyIndex; -static int XAAPixmapKeyIndex; -static DevPrivateKey XAAPixmapKey = &XAAPixmapKeyIndex; +static DevPrivateKeyRec XAAScreenKeyRec; +#define XAAScreenKey (&XAAScreenKeyRec) +static DevPrivateKeyRec XAAGCKeyRec; +#define XAAGCKey (&XAAGCKeyRec) +static DevPrivateKeyRec XAAPixmapKeyRec; +#define XAAPixmapKey (&XAAPixmapKeyRec) DevPrivateKey XAAGetScreenKey(void) { return XAAScreenKey; @@ -84,11 +84,9 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec) if(infoRec->ClosePixmapCache) (*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen); - if(infoRec->PreAllocMem) - free(infoRec->PreAllocMem); + free(infoRec->PreAllocMem); - if(infoRec->PixmapCachePrivate) - free(infoRec->PixmapCachePrivate); + free(infoRec->PixmapCachePrivate); free(infoRec); } @@ -106,10 +104,13 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) if (!infoRec) return TRUE; - if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec))) + if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec))) + return FALSE; + + if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec))) return FALSE; - if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec))) + if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!(pScreenPriv = malloc(sizeof(XAAScreenRec)))) diff --git a/xorg-server/hw/xfree86/xaa/xaaLine.c b/xorg-server/hw/xfree86/xaa/xaaLine.c index 7469de179..d94f1f4e0 100644 --- a/xorg-server/hw/xfree86/xaa/xaaLine.c +++ b/xorg-server/hw/xfree86/xaa/xaaLine.c @@ -1,394 +1,394 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include - -#include -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "miline.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - - -void -#ifdef POLYSEGMENT -XAAPolySegment( - DrawablePtr pDrawable, - GCPtr pGC, - int nseg, - xSegment *pSeg -#else -XAAPolyLines( - DrawablePtr pDrawable, - GCPtr pGC, - int mode, /* Origin or Previous */ - int npt, /* number of points */ - DDXPointPtr pptInit -#endif -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); - int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); - unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); - int xorg = pDrawable->x; - int yorg = pDrawable->y; - int nbox; - BoxPtr pbox; -#ifndef POLYSEGMENT - DDXPointPtr ppt; -#endif - int x1, x2, y1, y2, tmp, len; - - if(!nboxInit) - return; - - if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) { - int minValX = infoRec->SolidLineLimits.x1; - int maxValX = infoRec->SolidLineLimits.x2; - int minValY = infoRec->SolidLineLimits.y1; - int maxValY = infoRec->SolidLineLimits.y2; -#ifdef POLYSEGMENT - int n = nseg; - xSegment *s = pSeg; - - while (n--) -#else - int n = npt; - int xorgtmp = xorg; - int yorgtmp = yorg; - - ppt = pptInit; - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; - while (--n) -#endif - { -#ifdef POLYSEGMENT - x1 = s->x1 + xorg; - y1 = s->y1 + yorg; - x2 = s->x2 + xorg; - y2 = s->y2 + yorg; - s++; -#else - x1 = x2; - y1 = y2; - ++ppt; - if (mode == CoordModePrevious) { - xorgtmp = x1; - yorgtmp = y1; - } - x2 = ppt->x + xorgtmp; - y2 = ppt->y + yorgtmp; -#endif - if (x1 > maxValX || x1 < minValX || - x2 > maxValX || x2 < minValX || - y1 > maxValY || y1 < minValY || - y2 > maxValY || y2 < minValY) { -#ifdef POLYSEGMENT - XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); -#else - XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); -#endif - return; - } - } - } - - (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel, - pGC->alu, pGC->planemask); - -#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 - - if (x1 == x2) { /* vertical line */ - /* make the line go top to bottom of screen, keeping - endpoint semantics - */ - if (y1 > y2) { - tmp = y2; - y2 = y1 + 1; - y1 = tmp + 1; -#ifdef POLYSEGMENT - if (pGC->capStyle != CapNotLast) y1--; -#endif - } -#ifdef POLYSEGMENT - else if (pGC->capStyle != CapNotLast) y2++; -#endif - /* get to first band that might contain part of line */ - while(nbox && (pbox->y2 <= y1)) { - pbox++; - nbox--; - } - - /* stop when lower edge of box is beyond end of line */ - while(nbox && (y2 >= pbox->y1)) { - if ((x1 >= pbox->x1) && (x1 < pbox->x2)) { - tmp = max(y1, pbox->y1); - len = min(y2, pbox->y2) - tmp; - if (len) (*infoRec->SubsequentSolidHorVertLine)( - infoRec->pScrn, x1, tmp, len, DEGREES_270); - } - nbox--; - pbox++; - } -#ifndef POLYSEGMENT - y2 = ppt->y + yorg; -#endif - } else if (y1 == y2) { /* horizontal line */ - /* force line from left to right, keeping endpoint semantics */ - if (x1 > x2) { - tmp = x2; - x2 = x1 + 1; - x1 = tmp + 1; -#ifdef POLYSEGMENT - if (pGC->capStyle != CapNotLast) x1--; -#endif - } -#ifdef POLYSEGMENT - else if (pGC->capStyle != CapNotLast) x2++; -#endif - - /* find the correct band */ - while(nbox && (pbox->y2 <= y1)) { - pbox++; - nbox--; - } - - /* try to draw the line, if we haven't gone beyond it */ - if (nbox && (pbox->y1 <= y1)) { - int orig_y = pbox->y1; - /* when we leave this band, we're done */ - while(nbox && (orig_y == pbox->y1)) { - if (pbox->x2 <= x1) { - /* skip boxes until one might contain start point */ - nbox--; - pbox++; - continue; - } - - /* stop if left of box is beyond right of line */ - if (pbox->x1 >= x2) { - nbox = 0; - break; - } - - tmp = max(x1, pbox->x1); - len = min(x2, pbox->x2) - tmp; - if (len) (*infoRec->SubsequentSolidHorVertLine)( - infoRec->pScrn, tmp, y1, len, DEGREES_0); - nbox--; - pbox++; - } - } -#ifndef POLYSEGMENT - x2 = ppt->x + xorg; -#endif - } else{ /* sloped line */ - unsigned int oc1, oc2; - int dmin, dmaj, e, octant; - - if (infoRec->SubsequentSolidBresenhamLine) { - if((dmaj = x2 - x1) < 0) { - dmaj = -dmaj; - octant = XDECREASING; - } else octant = 0; - - if((dmin = y2 - y1) < 0) { - dmin = -dmin; - octant |= YDECREASING; - } - - if(dmin >= dmaj){ - tmp = dmin; dmin = dmaj; dmaj = tmp; - octant |= YMAJOR; - } - - e = -dmaj - ((bias >> octant) & 1); - len = dmaj; - dmin <<= 1; - dmaj <<= 1; - } else { /* Muffle compiler */ - dmin = dmaj = e = octant = len = 0; - } - - while(nbox--) { - oc1 = oc2 = 0; - OUTCODES(oc1, x1, y1, pbox); - OUTCODES(oc2, x2, y2, pbox); - if (!(oc1 | oc2)) { /* unclipped */ - if(infoRec->SubsequentSolidTwoPointLine) { - (*infoRec->SubsequentSolidTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST - ); - } else { - (*infoRec->SubsequentSolidBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant); - } - break; - } else if (oc1 & oc2) { /* completely clipped */ - pbox++; - } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) { - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); - - if(infoRec->SubsequentSolidBresenhamLine) { - (*infoRec->SubsequentSolidBresenhamLine)( - infoRec->pScrn, x1, y1, dmaj, dmin, e, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? (len+1) : -#endif - len, octant); - } else { - (*infoRec->SubsequentSolidTwoPointLine)( - infoRec->pScrn, x1, y1, x2, y2, -#ifdef POLYSEGMENT - (pGC->capStyle != CapNotLast) ? 0 : -#endif - OMIT_LAST - ); - } - (*infoRec->DisableClipping)(infoRec->pScrn); - pbox++; - } else { - int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; - int clip1 = 0, clip2 = 0; - int err, adx, ady; - - if(octant & YMAJOR) { - ady = dmaj >> 1; - adx = dmin >> 1; - } else { - ady = dmin >> 1; - adx = dmaj >> 1; - } - - if (miZeroClipLine(pbox->x1, pbox->y1, - pbox->x2 - 1, pbox->y2 - 1, - &new_x1, &new_y1, &new_x2, &new_y2, - adx, ady, &clip1, &clip2, - octant, bias, oc1, oc2) == -1) - { - pbox++; - continue; - } - - if (octant & YMAJOR) - len = abs(new_y2 - new_y1); - else - len = abs(new_x2 - new_x1); -#ifdef POLYSEGMENT - if (clip2 != 0 || pGC->capStyle != CapNotLast) - len++; -#else - len += (clip2 != 0); -#endif - if (len) { - int abserr, clipdx, clipdy; - /* unwind bresenham error term to first point */ - if (clip1) { - clipdx = abs(new_x1 - x1); - clipdy = abs(new_y1 - y1); - - if (octant & YMAJOR) - err = e + clipdy*dmin - clipdx*dmaj; - else - err = e + clipdx*dmin - clipdy*dmaj; - } else - err = e; - -#define range infoRec->SolidBresenhamLineErrorTermBits - abserr = abs(err); - while((abserr & range) || - (dmaj & range) || - (dmin & range)) { - dmin >>= 1; - dmaj >>= 1; - abserr >>= 1; - err /= 2; - } - - (*infoRec->SubsequentSolidBresenhamLine)( - infoRec->pScrn, new_x1, new_y1, - dmaj, dmin, err, len, octant); - } - 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)) - { - (*infoRec->SubsequentSolidHorVertLine)( - infoRec->pScrn, x2, y2, 1, DEGREES_0); - break; - } - else - pbox++; - } - } -#endif - - SET_SYNC_FLAG(infoRec); -} - + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include + +#include +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "miline.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + + +void +#ifdef POLYSEGMENT +XAAPolySegment( + DrawablePtr pDrawable, + GCPtr pGC, + int nseg, + xSegment *pSeg +#else +XAAPolyLines( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, /* Origin or Previous */ + int npt, /* number of points */ + DDXPointPtr pptInit +#endif +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + BoxPtr pboxInit = RegionRects(pGC->pCompositeClip); + int nboxInit = RegionNumRects(pGC->pCompositeClip); + unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); + int xorg = pDrawable->x; + int yorg = pDrawable->y; + int nbox; + BoxPtr pbox; +#ifndef POLYSEGMENT + DDXPointPtr ppt; +#endif + int x1, x2, y1, y2, tmp, len; + + if(!nboxInit) + return; + + if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) { + int minValX = infoRec->SolidLineLimits.x1; + int maxValX = infoRec->SolidLineLimits.x2; + int minValY = infoRec->SolidLineLimits.y1; + int maxValY = infoRec->SolidLineLimits.y2; +#ifdef POLYSEGMENT + int n = nseg; + xSegment *s = pSeg; + + while (n--) +#else + int n = npt; + int xorgtmp = xorg; + int yorgtmp = yorg; + + ppt = pptInit; + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; + while (--n) +#endif + { +#ifdef POLYSEGMENT + x1 = s->x1 + xorg; + y1 = s->y1 + yorg; + x2 = s->x2 + xorg; + y2 = s->y2 + yorg; + s++; +#else + x1 = x2; + y1 = y2; + ++ppt; + if (mode == CoordModePrevious) { + xorgtmp = x1; + yorgtmp = y1; + } + x2 = ppt->x + xorgtmp; + y2 = ppt->y + yorgtmp; +#endif + if (x1 > maxValX || x1 < minValX || + x2 > maxValX || x2 < minValX || + y1 > maxValY || y1 < minValY || + y2 > maxValY || y2 < minValY) { +#ifdef POLYSEGMENT + XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg); +#else + XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit); +#endif + return; + } + } + } + + (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel, + pGC->alu, pGC->planemask); + +#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 + + if (x1 == x2) { /* vertical line */ + /* make the line go top to bottom of screen, keeping + endpoint semantics + */ + if (y1 > y2) { + tmp = y2; + y2 = y1 + 1; + y1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) y1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) y2++; +#endif + /* get to first band that might contain part of line */ + while(nbox && (pbox->y2 <= y1)) { + pbox++; + nbox--; + } + + /* stop when lower edge of box is beyond end of line */ + while(nbox && (y2 >= pbox->y1)) { + if ((x1 >= pbox->x1) && (x1 < pbox->x2)) { + tmp = max(y1, pbox->y1); + len = min(y2, pbox->y2) - tmp; + if (len) (*infoRec->SubsequentSolidHorVertLine)( + infoRec->pScrn, x1, tmp, len, DEGREES_270); + } + nbox--; + pbox++; + } +#ifndef POLYSEGMENT + y2 = ppt->y + yorg; +#endif + } else if (y1 == y2) { /* horizontal line */ + /* force line from left to right, keeping endpoint semantics */ + if (x1 > x2) { + tmp = x2; + x2 = x1 + 1; + x1 = tmp + 1; +#ifdef POLYSEGMENT + if (pGC->capStyle != CapNotLast) x1--; +#endif + } +#ifdef POLYSEGMENT + else if (pGC->capStyle != CapNotLast) x2++; +#endif + + /* find the correct band */ + while(nbox && (pbox->y2 <= y1)) { + pbox++; + nbox--; + } + + /* try to draw the line, if we haven't gone beyond it */ + if (nbox && (pbox->y1 <= y1)) { + int orig_y = pbox->y1; + /* when we leave this band, we're done */ + while(nbox && (orig_y == pbox->y1)) { + if (pbox->x2 <= x1) { + /* skip boxes until one might contain start point */ + nbox--; + pbox++; + continue; + } + + /* stop if left of box is beyond right of line */ + if (pbox->x1 >= x2) { + nbox = 0; + break; + } + + tmp = max(x1, pbox->x1); + len = min(x2, pbox->x2) - tmp; + if (len) (*infoRec->SubsequentSolidHorVertLine)( + infoRec->pScrn, tmp, y1, len, DEGREES_0); + nbox--; + pbox++; + } + } +#ifndef POLYSEGMENT + x2 = ppt->x + xorg; +#endif + } else{ /* sloped line */ + unsigned int oc1, oc2; + int dmin, dmaj, e, octant; + + if (infoRec->SubsequentSolidBresenhamLine) { + if((dmaj = x2 - x1) < 0) { + dmaj = -dmaj; + octant = XDECREASING; + } else octant = 0; + + if((dmin = y2 - y1) < 0) { + dmin = -dmin; + octant |= YDECREASING; + } + + if(dmin >= dmaj){ + tmp = dmin; dmin = dmaj; dmaj = tmp; + octant |= YMAJOR; + } + + e = -dmaj - ((bias >> octant) & 1); + len = dmaj; + dmin <<= 1; + dmaj <<= 1; + } else { /* Muffle compiler */ + dmin = dmaj = e = octant = len = 0; + } + + while(nbox--) { + oc1 = oc2 = 0; + OUTCODES(oc1, x1, y1, pbox); + OUTCODES(oc2, x2, y2, pbox); + if (!(oc1 | oc2)) { /* unclipped */ + if(infoRec->SubsequentSolidTwoPointLine) { + (*infoRec->SubsequentSolidTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST + ); + } else { + (*infoRec->SubsequentSolidBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant); + } + break; + } else if (oc1 & oc2) { /* completely clipped */ + pbox++; + } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) { + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1); + + if(infoRec->SubsequentSolidBresenhamLine) { + (*infoRec->SubsequentSolidBresenhamLine)( + infoRec->pScrn, x1, y1, dmaj, dmin, e, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? (len+1) : +#endif + len, octant); + } else { + (*infoRec->SubsequentSolidTwoPointLine)( + infoRec->pScrn, x1, y1, x2, y2, +#ifdef POLYSEGMENT + (pGC->capStyle != CapNotLast) ? 0 : +#endif + OMIT_LAST + ); + } + (*infoRec->DisableClipping)(infoRec->pScrn); + pbox++; + } else { + int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; + int clip1 = 0, clip2 = 0; + int err, adx, ady; + + if(octant & YMAJOR) { + ady = dmaj >> 1; + adx = dmin >> 1; + } else { + ady = dmin >> 1; + adx = dmaj >> 1; + } + + if (miZeroClipLine(pbox->x1, pbox->y1, + pbox->x2 - 1, pbox->y2 - 1, + &new_x1, &new_y1, &new_x2, &new_y2, + adx, ady, &clip1, &clip2, + octant, bias, oc1, oc2) == -1) + { + pbox++; + continue; + } + + if (octant & YMAJOR) + len = abs(new_y2 - new_y1); + else + len = abs(new_x2 - new_x1); +#ifdef POLYSEGMENT + if (clip2 != 0 || pGC->capStyle != CapNotLast) + len++; +#else + len += (clip2 != 0); +#endif + if (len) { + int abserr, clipdx, clipdy; + /* unwind bresenham error term to first point */ + if (clip1) { + clipdx = abs(new_x1 - x1); + clipdy = abs(new_y1 - y1); + + if (octant & YMAJOR) + err = e + clipdy*dmin - clipdx*dmaj; + else + err = e + clipdx*dmin - clipdy*dmaj; + } else + err = e; + +#define range infoRec->SolidBresenhamLineErrorTermBits + abserr = abs(err); + while((abserr & range) || + (dmaj & range) || + (dmin & range)) { + dmin >>= 1; + dmaj >>= 1; + abserr >>= 1; + err /= 2; + } + + (*infoRec->SubsequentSolidBresenhamLine)( + infoRec->pScrn, new_x1, new_y1, + dmaj, dmin, err, len, octant); + } + 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)) + { + (*infoRec->SubsequentSolidHorVertLine)( + infoRec->pScrn, x2, y2, 1, DEGREES_0); + break; + } + else + pbox++; + } + } +#endif + + SET_SYNC_FLAG(infoRec); +} + diff --git a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c index 3e5330fd3..44048674e 100644 --- a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c +++ b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c @@ -74,8 +74,7 @@ XAAComputeDash(GCPtr pGC) int shift, value, direction; Bool set; - if(pGCPriv->DashPattern) - free(pGCPriv->DashPattern); + free(pGCPriv->DashPattern); pGCPriv->DashPattern = NULL; pGCPriv->DashLength = 0; diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c index eb798a82b..519bda0e7 100644 --- a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c +++ b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c @@ -82,7 +82,7 @@ XAAPolyText8NonTEColorExpansion( infoRec->CharInfo); } - return (x + width); + return x + width; } @@ -112,7 +112,7 @@ XAAPolyText16NonTEColorExpansion( infoRec->CharInfo); } - return (x + width); + return x + width; } @@ -128,7 +128,7 @@ XAAImageText8NonTEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); unsigned long n; - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, @@ -153,7 +153,7 @@ XAAImageText16NonTEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); unsigned long n; - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; (*pGC->font->get_glyphs)( @@ -188,7 +188,7 @@ XAAImageGlyphBltNonTEColorExpansion( ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; ImageGlyphBltNonTEColorExpansion( @@ -208,7 +208,7 @@ XAAPolyGlyphBltNonTEColorExpansion( ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; PolyGlyphBltNonTEColorExpansion( @@ -368,8 +368,8 @@ ImageGlyphBltNonTEColorExpansion( int skippix, skipglyph, width, n, i; int Left, Right, Top, Bottom; int LeftEdge, RightEdge, ytop, ybot; - int nbox = REGION_NUM_RECTS(cclip); - BoxPtr pbox = REGION_RECTS(cclip); + int nbox = RegionNumRects(cclip); + BoxPtr pbox = RegionRects(cclip); Bool AlreadySetup = FALSE; width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font); @@ -405,8 +405,8 @@ ImageGlyphBltNonTEColorExpansion( nbox--; pbox++; } - nbox = REGION_NUM_RECTS(cclip); - pbox = REGION_RECTS(cclip); + nbox = RegionNumRects(cclip); + pbox = RegionRects(cclip); if(infoRec->WriteBitmap && (nglyph > 1) && ((FONTMAXBOUNDS(font, rightSideBearing) - @@ -477,8 +477,8 @@ PolyGlyphBltNonTEColorExpansion( int skippix, skipglyph, width, n, i; int Left, Right, Top, Bottom; int LeftEdge, RightEdge; - int nbox = REGION_NUM_RECTS(cclip); - BoxPtr pbox = REGION_RECTS(cclip); + int nbox = RegionNumRects(cclip); + BoxPtr pbox = RegionRects(cclip); width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font); diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlay.c b/xorg-server/hw/xfree86/xaa/xaaOverlay.c index b7122a58f..176a2d891 100644 --- a/xorg-server/hw/xfree86/xaa/xaaOverlay.c +++ b/xorg-server/hw/xfree86/xaa/xaaOverlay.c @@ -54,23 +54,23 @@ XAACopyWindow8_32( return; } - pwinRoot = WindowTable[pScreen->myNum]; + pwinRoot = pScreen->root; if(doUnderlay) freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip); - REGION_NULL(pScreen, &rgnDst); + RegionNull(&rgnDst); dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; - REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); - REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc); + RegionTranslate(prgnSrc, -dx, -dy); + RegionIntersect(&rgnDst, borderClip, prgnSrc); - pbox = REGION_RECTS(&rgnDst); - nbox = REGION_NUM_RECTS(&rgnDst); + pbox = RegionRects(&rgnDst); + nbox = RegionNumRects(&rgnDst); if(!nbox || !(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) { - REGION_UNINIT(pScreen, &rgnDst); + RegionUninit(&rgnDst); return; } ppt = pptSrc; @@ -88,9 +88,9 @@ XAACopyWindow8_32( &(infoRec->ScratchGC), &rgnDst, pptSrc); free(pptSrc); - REGION_UNINIT(pScreen, &rgnDst); + RegionUninit(&rgnDst); if(freeReg) - REGION_DESTROY(pScreen, borderClip); + RegionDestroy(borderClip); } static void diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c index 4548935fd..309ec9fa4 100644 --- a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c +++ b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c @@ -151,8 +151,8 @@ typedef struct { int (*TiledFillChooser)(GCPtr); } XAAOverlayRec, *XAAOverlayPtr; -static int XAAOverlayKeyIndex; -static DevPrivateKey XAAOverlayKey = &XAAOverlayKeyIndex; +static DevPrivateKeyRec XAAOverlayKeyRec; +#define XAAOverlayKey (&XAAOverlayKeyRec) #define GET_OVERLAY_PRIV(pScreen) \ (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey) @@ -173,6 +173,9 @@ XAAInitDualFramebufferOverlay( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAOverlayPtr pOverPriv; + if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + if(!(pOverPriv = malloc(sizeof(XAAOverlayRec)))) return FALSE; @@ -324,7 +327,7 @@ XAAOverCopyWindow( RegionRec rgnDst; BoxPtr pbox; int i, nbox, dx, dy; - WindowPtr pRoot = WindowTable[pScreen->myNum]; + WindowPtr pRoot = pScreen->root; if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { @@ -341,18 +344,18 @@ XAAOverCopyWindow( infoRec->ScratchGC.alu = GXcopy; infoRec->ScratchGC.planemask = ~0; - REGION_NULL(pScreen, &rgnDst); + RegionNull(&rgnDst); dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; - REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); - REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc); + RegionTranslate(prgnSrc, -dx, -dy); + RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc); - nbox = REGION_NUM_RECTS(&rgnDst); + nbox = RegionNumRects(&rgnDst); if(nbox && (pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) { - pbox = REGION_RECTS(&rgnDst); + pbox = RegionRects(&rgnDst); for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { ppt->x = pbox->x1 + dx; ppt->y = pbox->y1 + dy; @@ -371,18 +374,18 @@ XAAOverCopyWindow( free(pptSrc); } - REGION_UNINIT(pScreen, &rgnDst); + RegionUninit(&rgnDst); if(pWin->drawable.depth == 8) { - REGION_NULL(pScreen, &rgnDst); + RegionNull(&rgnDst); miSegregateChildren(pWin, &rgnDst, pScrn->depth); - if(REGION_NOTEMPTY(pScreen, &rgnDst)) { - REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrc); - nbox = REGION_NUM_RECTS(&rgnDst); + if(RegionNotEmpty(&rgnDst)) { + RegionIntersect(&rgnDst, &rgnDst, prgnSrc); + nbox = RegionNumRects(&rgnDst); if(nbox && (pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))){ - pbox = REGION_RECTS(&rgnDst); + pbox = RegionRects(&rgnDst); for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { ppt->x = pbox->x1 + dx; ppt->y = pbox->y1 + dy; @@ -394,7 +397,7 @@ XAAOverCopyWindow( free(pptSrc); } } - REGION_UNINIT(pScreen, &rgnDst); + RegionUninit(&rgnDst); } } @@ -409,13 +412,13 @@ XAAOverWindowExposures( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) { - if(REGION_NUM_RECTS(pReg) && infoRec->FillSolidRects) { + if(RegionNumRects(pReg) && infoRec->FillSolidRects) { XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen); SWITCH_DEPTH(8); (*infoRec->FillSolidRects)(infoRec->pScrn, infoRec->pScrn->colorKey, GXcopy, ~0, - REGION_NUM_RECTS(pReg), REGION_RECTS(pReg)); + RegionNumRects(pReg), RegionRects(pReg)); miWindowExposures(pWin, pReg, pOtherReg); return; } else if(infoRec->NeedToSync) { diff --git a/xorg-server/hw/xfree86/xaa/xaaPCache.c b/xorg-server/hw/xfree86/xaa/xaaPCache.c index 62726d539..ff3f9ef56 100644 --- a/xorg-server/hw/xfree86/xaa/xaaPCache.c +++ b/xorg-server/hw/xfree86/xaa/xaaPCache.c @@ -144,18 +144,12 @@ FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv) { if(!pPriv) return; - if(pPriv->Info512) - free(pPriv->Info512); - if(pPriv->Info256) - free(pPriv->Info256); - if(pPriv->Info128) - free(pPriv->Info128); - if(pPriv->InfoColor) - free(pPriv->InfoColor); - if(pPriv->InfoMono) - free(pPriv->InfoMono); - if(pPriv->InfoPartial) - free(pPriv->InfoPartial); + free(pPriv->Info512); + free(pPriv->Info256); + free(pPriv->Info128); + free(pPriv->InfoColor); + free(pPriv->InfoMono); + free(pPriv->InfoPartial); free(pPriv); } @@ -639,8 +633,8 @@ XAAInitPixmapCache( ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAInfoRecPtr infoRec = (XAAInfoRecPtr)data; XAAPixmapCachePrivatePtr pCachePriv; - BoxPtr pBox = REGION_RECTS(areas); - int nBox = REGION_NUM_RECTS(areas); + BoxPtr pBox = RegionRects(areas); + int nBox = RegionNumRects(areas); int Num512, Num256, Num128, NumPartial, NumColor, NumMono; int Target512, Target256; CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono; diff --git a/xorg-server/hw/xfree86/xaa/xaaPict.c b/xorg-server/hw/xfree86/xaa/xaaPict.c index b66291458..1ad75835b 100644 --- a/xorg-server/hw/xfree86/xaa/xaaPict.c +++ b/xorg-server/hw/xfree86/xaa/xaaPict.c @@ -215,7 +215,7 @@ XAADoComposite ( BoxPtr pbox; int nbox, w, h; - if(!REGION_NUM_RECTS(pDst->pCompositeClip)) + if(!RegionNumRects(pDst->pCompositeClip)) return TRUE; if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable)) @@ -273,8 +273,8 @@ XAADoComposite ( width, height)) return TRUE; - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); + nbox = RegionNumRects(®ion); + pbox = RegionRects(®ion); if(!nbox) return TRUE; @@ -298,7 +298,7 @@ XAADoComposite ( } /* WriteBitmap sets the Sync flag */ - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return TRUE; } @@ -340,11 +340,11 @@ XAADoComposite ( width, height)) return TRUE; - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); + nbox = RegionNumRects(®ion); + pbox = RegionRects(®ion); if(!nbox) { - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return TRUE; } @@ -355,7 +355,7 @@ XAADoComposite ( ((PixmapPtr)(pMask->pDrawable))->devKind, w, h, flags)) { - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return FALSE; } @@ -371,7 +371,7 @@ XAADoComposite ( } SET_SYNC_FLAG(infoRec); - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return TRUE; } } else { @@ -409,11 +409,11 @@ XAADoComposite ( width, height)) return TRUE; - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); + nbox = RegionNumRects(®ion); + pbox = RegionRects(®ion); if(!nbox) { - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return TRUE; } @@ -423,7 +423,7 @@ XAADoComposite ( ((PixmapPtr)(pSrc->pDrawable))->devKind, w, h, flags)) { - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return FALSE; } @@ -440,7 +440,7 @@ XAADoComposite ( } SET_SYNC_FLAG(infoRec); - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return TRUE; } @@ -476,16 +476,16 @@ XAACompositeSrcCopy (PicturePtr pSrc, width, height)) return; - nbox = REGION_NUM_RECTS(®ion); - pbox = REGION_RECTS(®ion); + nbox = RegionNumRects(®ion); + pbox = RegionRects(®ion); if(!nbox) { - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return; } pptSrc = malloc(sizeof(DDXPointRec) * nbox); if (!pptSrc) { - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return; } xoff = xSrc - xDst; @@ -502,7 +502,7 @@ XAACompositeSrcCopy (PicturePtr pSrc, pptSrc); free(pptSrc); - REGION_UNINIT(pScreen, ®ion); + RegionUninit(®ion); return; } @@ -588,7 +588,7 @@ XAADoGlyphs (CARD8 op, ScreenPtr pScreen = pDst->pDrawable->pScreen; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); - if(!REGION_NUM_RECTS(pDst->pCompositeClip)) + if(!RegionNumRects(pDst->pCompositeClip)) return TRUE; if(!infoRec->pScrn->vtSema || diff --git a/xorg-server/hw/xfree86/xaa/xaaRect.c b/xorg-server/hw/xfree86/xaa/xaaRect.c index 0a7e174b7..988dbf608 100644 --- a/xorg-server/hw/xfree86/xaa/xaaRect.c +++ b/xorg-server/hw/xfree86/xaa/xaaRect.c @@ -1,136 +1,136 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - -/* - Much of this file based on code by - Harm Hanemaayer (H.Hanemaayer@inter.nl.net). -*/ - - -void -XAAPolyRectangleThinSolid( - DrawablePtr pDrawable, - GCPtr pGC, - int nRectsInit, - xRectangle *pRectsInit ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int nClipRects; /* number of clip rectangles */ - BoxPtr pClipRects; /* points to the list of clip rects */ - int xOrigin; /* Drawables x origin */ - int yOrigin; /* Drawables x origin */ - xRectangle *pRect; /* list of rects */ - int nRects; /* running count of number of rects */ - int origX1, origY1; /* original rectangle's U/L corner */ - int origX2, origY2; /* original rectangle's L/R corner */ - int clippedX1; /* clipped rectangle's left x */ - int clippedY1; /* clipped rectangle's top y */ - int clippedX2; /* clipped rectangle's right x */ - int clippedY2; /* clipped rectangle's bottom y */ - int clipXMin; /* upper left corner of clip rect */ - int clipYMin; /* upper left corner of clip rect */ - int clipXMax; /* lower right corner of clip rect */ - int clipYMax; /* lower right corner of clip rect */ - int width, height; /* width and height of rect */ - - nClipRects = REGION_NUM_RECTS(pGC->pCompositeClip); - pClipRects = REGION_RECTS(pGC->pCompositeClip); - - if(!nClipRects) return; - - xOrigin = pDrawable->x; - yOrigin = pDrawable->y; - - - (*infoRec->SetupForSolidLine)(infoRec->pScrn, - pGC->fgPixel, pGC->alu, pGC->planemask); - - - for ( ; nClipRects > 0; - nClipRects--, pClipRects++ ) - { - clipYMin = pClipRects->y1; - clipYMax = pClipRects->y2 - 1; - clipXMin = pClipRects->x1; - clipXMax = pClipRects->x2 - 1; - - for (pRect = pRectsInit, nRects = nRectsInit; - nRects > 0; - nRects--, pRect++ ) - { - /* translate rectangle data over to the drawable */ - origX1 = pRect->x + xOrigin; - origY1 = pRect->y + yOrigin; - origX2 = origX1 + pRect->width; - origY2 = origY1 + pRect->height; - - /* reject entire rectangle if completely outside clip rect */ - if ((origX1 > clipXMax) || (origX2 < clipXMin) || - (origY1 > clipYMax) || (origY2 < clipYMin)) - continue; - - /* clip the rectangle */ - clippedX1 = max (origX1, clipXMin); - clippedX2 = min (origX2, clipXMax); - clippedY1 = max (origY1, clipYMin); - clippedY2 = min (origY2, clipYMax); - - width = clippedX2 - clippedX1 + 1; - - if (origY1 >= clipYMin) { - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX1, clippedY1, width, DEGREES_0); - - /* don't overwrite corner */ - clippedY1++; - } - - if ((origY2 <= clipYMax) && (origY1 != origY2)) { - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX1, clippedY2, width, DEGREES_0); - - /* don't overwrite corner */ - clippedY2--; - } - - if (clippedY2 < clippedY1) continue; - - height = clippedY2 - clippedY1 + 1; - - /* draw vertical edges using lines if not clipped out */ - if (origX1 >= clipXMin) - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX1, clippedY1, height, DEGREES_270); - - if ((origX2 <= clipXMax) && (origX2 != origX1)) - (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, - clippedX2, clippedY1, height, DEGREES_270); - } - } - - SET_SYNC_FLAG(infoRec); -} - - - - - - - - - - - + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + +/* + Much of this file based on code by + Harm Hanemaayer (H.Hanemaayer@inter.nl.net). +*/ + + +void +XAAPolyRectangleThinSolid( + DrawablePtr pDrawable, + GCPtr pGC, + int nRectsInit, + xRectangle *pRectsInit ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int nClipRects; /* number of clip rectangles */ + BoxPtr pClipRects; /* points to the list of clip rects */ + int xOrigin; /* Drawables x origin */ + int yOrigin; /* Drawables x origin */ + xRectangle *pRect; /* list of rects */ + int nRects; /* running count of number of rects */ + int origX1, origY1; /* original rectangle's U/L corner */ + int origX2, origY2; /* original rectangle's L/R corner */ + int clippedX1; /* clipped rectangle's left x */ + int clippedY1; /* clipped rectangle's top y */ + int clippedX2; /* clipped rectangle's right x */ + int clippedY2; /* clipped rectangle's bottom y */ + int clipXMin; /* upper left corner of clip rect */ + int clipYMin; /* upper left corner of clip rect */ + int clipXMax; /* lower right corner of clip rect */ + int clipYMax; /* lower right corner of clip rect */ + int width, height; /* width and height of rect */ + + nClipRects = RegionNumRects(pGC->pCompositeClip); + pClipRects = RegionRects(pGC->pCompositeClip); + + if(!nClipRects) return; + + xOrigin = pDrawable->x; + yOrigin = pDrawable->y; + + + (*infoRec->SetupForSolidLine)(infoRec->pScrn, + pGC->fgPixel, pGC->alu, pGC->planemask); + + + for ( ; nClipRects > 0; + nClipRects--, pClipRects++ ) + { + clipYMin = pClipRects->y1; + clipYMax = pClipRects->y2 - 1; + clipXMin = pClipRects->x1; + clipXMax = pClipRects->x2 - 1; + + for (pRect = pRectsInit, nRects = nRectsInit; + nRects > 0; + nRects--, pRect++ ) + { + /* translate rectangle data over to the drawable */ + origX1 = pRect->x + xOrigin; + origY1 = pRect->y + yOrigin; + origX2 = origX1 + pRect->width; + origY2 = origY1 + pRect->height; + + /* reject entire rectangle if completely outside clip rect */ + if ((origX1 > clipXMax) || (origX2 < clipXMin) || + (origY1 > clipYMax) || (origY2 < clipYMin)) + continue; + + /* clip the rectangle */ + clippedX1 = max (origX1, clipXMin); + clippedX2 = min (origX2, clipXMax); + clippedY1 = max (origY1, clipYMin); + clippedY2 = min (origY2, clipYMax); + + width = clippedX2 - clippedX1 + 1; + + if (origY1 >= clipYMin) { + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX1, clippedY1, width, DEGREES_0); + + /* don't overwrite corner */ + clippedY1++; + } + + if ((origY2 <= clipYMax) && (origY1 != origY2)) { + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX1, clippedY2, width, DEGREES_0); + + /* don't overwrite corner */ + clippedY2--; + } + + if (clippedY2 < clippedY1) continue; + + height = clippedY2 - clippedY1 + 1; + + /* draw vertical edges using lines if not clipped out */ + if (origX1 >= clipXMin) + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX1, clippedY1, height, DEGREES_270); + + if ((origX2 <= clipXMax) && (origX2 != origX1)) + (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn, + clippedX2, clippedY1, height, DEGREES_270); + } + } + + SET_SYNC_FLAG(infoRec); +} + + + + + + + + + + + diff --git a/xorg-server/hw/xfree86/xaa/xaaSpans.c b/xorg-server/hw/xfree86/xaa/xaaSpans.c index 46d6d0740..1e6ef3a18 100644 --- a/xorg-server/hw/xfree86/xaa/xaaSpans.c +++ b/xorg-server/hw/xfree86/xaa/xaaSpans.c @@ -1,882 +1,882 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "xf86str.h" -#include "mi.h" -#include "mispans.h" -#include "xaa.h" -#include "xaalocal.h" - - -static void XAARenderSolidSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderColor8x8Spans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderMono8x8Spans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderCacheBltSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderColorExpandSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderCacheExpandSpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); -static void XAARenderPixmapCopySpans( - GCPtr, int, DDXPointPtr, int*, int, int, int); - -void -XAAFillSpans( - DrawablePtr pDraw, - 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 -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int type = 0; - ClipAndRenderSpansFunc function; - Bool fastClip = FALSE; - - if((nInit <= 0) || !pGC->planemask) - return; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - switch(pGC->fillStyle) { - case FillSolid: - type = DO_SOLID; - break; - case FillStippled: - type = (*infoRec->StippledFillChooser)(pGC); - break; - case FillOpaqueStippled: - if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid && - CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) && - CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) && - CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) && - CHECK_FG(pGC,infoRec->FillSpansSolidFlags)) - type = DO_SOLID; - else - type = (*infoRec->OpaqueStippledFillChooser)(pGC); - break; - case FillTiled: - type = (*infoRec->TiledFillChooser)(pGC); - break; - } - - switch(type) { - case DO_SOLID: - function = XAARenderSolidSpans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) - fastClip = TRUE; - break; - case DO_COLOR_8x8: - function = XAARenderColor8x8Spans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL) - fastClip = TRUE; - break; - case DO_MONO_8x8: - function = XAARenderMono8x8Spans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL) - fastClip = TRUE; - break; - case DO_CACHE_BLT: - function = XAARenderCacheBltSpans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) - fastClip = TRUE; - break; - case DO_COLOR_EXPAND: - function = XAARenderColorExpandSpans; - break; - case DO_CACHE_EXPAND: - function = XAARenderCacheExpandSpans; - if(infoRec->ClippingFlags & - HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND) - fastClip = TRUE; - break; - case DO_PIXMAP_COPY: - function = XAARenderPixmapCopySpans; - if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) - fastClip = TRUE; - break; - case DO_IMAGE_WRITE: - default: - (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit, - pwidthInit, fSorted); - return; - } - - - if((nInit < 10) || (REGION_NUM_RECTS(pGC->pCompositeClip) != 1)) - fastClip = FALSE; - - if(fastClip) { - infoRec->ClipBox = &pGC->pCompositeClip->extents; - (*function)(pGC, nInit, pptInit, pwidthInit, fSorted, - pDraw->x, pDraw->y); - infoRec->ClipBox = NULL; - } else - XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted, - function, pDraw->x, pDraw->y); -} - - - /*********************\ - | Solid Spans | - \*********************/ - - -static void -XAARenderSolidSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - - (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted); -} - - - /************************\ - | Mono 8x8 Spans | - \************************/ - - -static void -XAARenderMono8x8Spans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAAPixmapPtr pPriv; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - fg = pPriv->fg; bg = pPriv->bg; - break; - default: /* Muffle compiler */ - pPriv = NULL; /* Kaboom */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn, - fg, bg, pGC->alu, pGC->planemask, - n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); -} - - - /*************************\ - | Color 8x8 Spans | - \*************************/ - - -static void -XAARenderColor8x8Spans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - PixmapPtr pPix; - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - pPix = pGC->stipple; - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - case FillTiled: - pPix = pGC->tile.pixmap; - fg = -1; bg = -1; - break; - default: /* Muffle compiler */ - pPix = NULL; - fg = -1; bg = -1; - break; - } - - pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); - - (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, - (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y)); -} - - - /****************************\ - | Color Expand Spans | - \****************************/ - - -static void -XAARenderColorExpandSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); - -} - - - /*************************\ - | Cache Blt Spans | - \*************************/ - - -static void -XAARenderCacheBltSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache; - - switch(pGC->fillStyle) { - case FillStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, -1); - break; - case FillOpaqueStippled: - pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, - pGC->fgPixel, pGC->bgPixel); - break; - case FillTiled: - pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); - break; - default: /* Muffle compiler */ - pCache = NULL; - break; - } - - (*infoRec->FillCacheBltSpans) (infoRec->pScrn, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); - -} - - - /****************************\ - | Cache Expand Spans | - \****************************/ - - -static void -XAARenderCacheExpandSpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int fg, bg; - - switch(pGC->fillStyle) { - case FillStippled: - fg = pGC->fgPixel; bg = -1; - break; - case FillOpaqueStippled: - fg = pGC->fgPixel; bg = pGC->bgPixel; - break; - default: /* Muffle compiler */ - fg = -1; bg = -1; - break; - } - - (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), - pGC->stipple); -} - - - /***************************\ - | Pixmap Copy Spans | - \***************************/ - - -static void -XAARenderPixmapCopySpans( - GCPtr pGC, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); - XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); - - pCache->x = pPriv->offscreenArea->box.x1; - pCache->y = pPriv->offscreenArea->box.y1; - pCache->w = pCache->orig_w = - pPriv->offscreenArea->box.x2 - pCache->x; - pCache->h = pCache->orig_h = - pPriv->offscreenArea->box.y2 - pCache->y; - pCache->trans_color = -1; - - (*infoRec->FillCacheBltSpans) (infoRec->pScrn, - pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, - (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); -} - - - - - - /****************\ - | Solid | - \****************/ - - -void -XAAFillSolidSpans( - ScrnInfoPtr pScrn, - int fg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - - (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - if (*pwidth > 0) - (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y, - *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - /***************\ - | Mono 8x8 | - \***************/ - - -void -XAAFillMono8x8PatternSpansScreenOrigin( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - int pattern0, int pattern1, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - - if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } - } else { - XAACacheInfoPtr pCache = - (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - patx += pCache->offsets[slot].x; - paty += pCache->offsets[slot].y; - xorg = patx; yorg = paty; - } - } - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - -void -XAAFillMono8x8PatternSpans( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - int pattern0, int pattern1, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pattern0, paty = pattern1; - int xorg, yorg, slot; - XAACacheInfoPtr pCache = NULL; - - - if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ - pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); - patx = pCache->x; paty = pCache->y; - } - - (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, - fg, bg, rop, planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - xorg = (ppt->x - xorigin) & 0x07; - yorg = (ppt->y - yorigin) & 0x07; - - if(!(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - if(infoRec->Mono8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_BITS) { - patx = pattern0; paty = pattern1; - XAARotateMonoPattern(&patx, &paty, xorg, yorg, - (infoRec->Mono8x8PatternFillFlags & - BIT_ORDER_IN_BYTE_MSBFIRST)); - xorg = patx; yorg = paty; - } else { - slot = (yorg << 3) + xorg; - xorg = patx + pCache->offsets[slot].x; - yorg = paty + pCache->offsets[slot].y; - } - } - - (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - - - /****************\ - | Color 8x8 | - \****************/ - - -void -XAAFillColor8x8PatternSpansScreenOrigin( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - XAACacheInfoPtr pCache, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int patx = pCache->x, paty = pCache->y; - int xorg = (-xorigin) & 0x07; - int yorg = (-yorigin) & 0x07; - - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - int slot = (yorg << 3) + xorg; - paty += pCache->offsets[slot].y; - patx += pCache->offsets[slot].x; - xorg = patx; yorg = paty; - } - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, - rop, planemask, pCache->trans_color); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - -void -XAAFillColor8x8PatternSpans( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, int fSorted, - XAACacheInfoPtr pCache, - int xorigin, int yorigin -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int xorg, yorg, slot; - - (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, - rop, planemask, pCache->trans_color); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - xorg = (ppt->x - xorigin) & 0x07; - yorg = (ppt->y - yorigin) & 0x07; - - if(!(infoRec->Color8x8PatternFillFlags & - HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ - slot = (yorg << 3) + xorg; - yorg = pCache->y + pCache->offsets[slot].y; - xorg = pCache->x + pCache->offsets[slot].x; - } - - (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, - xorg, yorg, ppt->x, ppt->y, *pwidth, 1); - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - /*****************\ - | Cache Blit | - \*****************/ - - -void -XAAFillCacheBltSpans( - ScrnInfoPtr pScrn, - int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - XAACacheInfoPtr pCache, - int xorg, int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, w, phaseX, phaseY, blit_w; - - (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, - pCache->trans_color); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - x = ppt->x; - w = *pwidth; - phaseX = (x - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - phaseY = (ppt->y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - - while(1) { - blit_w = pCache->w - phaseX; - if(blit_w > w) blit_w = w; - - (*infoRec->SubsequentScreenToScreenCopy)(pScrn, - pCache->x + phaseX, pCache->y + phaseY, - x, ppt->y, blit_w, 1); - - w -= blit_w; - if(!w) break; - x += blit_w; - phaseX = (phaseX + blit_w) % pCache->orig_w; - } - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - - /****************\ - | Cache Expand | - \****************/ - - -void -XAAFillCacheExpandSpans( - ScrnInfoPtr pScrn, - int fg, int bg, int rop, - unsigned int planemask, - int n, - DDXPointPtr ppt, - int *pwidth, - int fSorted, - int xorg, int yorg, - PixmapPtr pPix -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - int x, w, phaseX, phaseY, blit_w, cacheWidth; - XAACacheInfoPtr pCache; - - pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); - - cacheWidth = (pCache->w * pScrn->bitsPerPixel) / - infoRec->CacheColorExpandDensity; - - (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, - planemask); - - if(infoRec->ClipBox) - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - - while(n--) { - x = ppt->x; - w = *pwidth; - phaseX = (x - xorg) % pCache->orig_w; - if(phaseX < 0) phaseX += pCache->orig_w; - phaseY = (ppt->y - yorg) % pCache->orig_h; - if(phaseY < 0) phaseY += pCache->orig_h; - - while(1) { - blit_w = cacheWidth - phaseX; - if(blit_w > w) blit_w = w; - - (*infoRec->SubsequentScreenToScreenColorExpandFill)( - pScrn, x, ppt->y, blit_w, 1, - pCache->x, pCache->y + phaseY, phaseX); - - w -= blit_w; - if(!w) break; - x += blit_w; - phaseX = (phaseX + blit_w) % pCache->orig_w; - } - ppt++; pwidth++; - } - - if(infoRec->ClipBox) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} - - - -void -XAAClipAndRenderSpans( - GCPtr pGC, - DDXPointPtr ppt, - int *pwidth, - int nspans, - int fSorted, - ClipAndRenderSpansFunc func, - int xorg, - int yorg -){ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - DDXPointPtr pptNew, pptBase; - int *pwidthBase, *pwidthNew; - int Right, numRects, MaxBoxes; - - MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int)); - pptBase = (DDXPointRec*)infoRec->PreAllocMem; - pwidthBase = (int*)(&pptBase[MaxBoxes]); - - pptNew = pptBase; - pwidthNew = pwidthBase; - - numRects = REGION_NUM_RECTS(pGC->pCompositeClip); - - if(numRects == 1) { - BoxPtr pextent = REGION_RECTS(pGC->pCompositeClip); - - while(nspans--) { - if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) { - pptNew->x = max(pextent->x1, ppt->x); - Right = ppt->x + *pwidth; - *pwidthNew = min(pextent->x2, Right) - pptNew->x; - - if (*pwidthNew > 0) { - pptNew->y = ppt->y; - pptNew++; - pwidthNew++; - - if(pptNew >= (pptBase + MaxBoxes)) { - (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted, - xorg, yorg); - pptNew = pptBase; - pwidthNew = pwidthBase; - } - } - } - ppt++; - pwidth++; - } - } else if (numRects) { - BoxPtr pbox; - int nbox; - - while(nspans--) { - nbox = numRects; - pbox = REGION_RECTS(pGC->pCompositeClip); - - /* find the first band */ - while(nbox && (pbox->y2 <= ppt->y)) { - pbox++; - nbox--; - } - - if(nbox && (pbox->y1 <= ppt->y)) { - int orig_y = pbox->y1; - Right = ppt->x + *pwidth; - while(nbox && (orig_y == pbox->y1)) { - if(pbox->x2 <= ppt->x) { - nbox--; - pbox++; - continue; - } - - if(pbox->x1 >= Right) { - nbox = 0; - break; - } - - pptNew->x = max(pbox->x1, ppt->x); - *pwidthNew = min(pbox->x2, Right) - pptNew->x; - if(*pwidthNew > 0) { - pptNew->y = ppt->y; - pptNew++; - pwidthNew++; - - if(pptNew >= (pptBase + MaxBoxes)) { - (*func)(pGC, MaxBoxes, pptBase, pwidthBase, - fSorted, xorg, yorg); - pptNew = pptBase; - pwidthNew = pwidthBase; - } - } - pbox++; - nbox--; - } - } - ppt++; - pwidth++; - } - } - - if(pptNew != pptBase) - (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted, - xorg, yorg); -} + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "xf86str.h" +#include "mi.h" +#include "mispans.h" +#include "xaa.h" +#include "xaalocal.h" + + +static void XAARenderSolidSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderColor8x8Spans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderMono8x8Spans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderCacheBltSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderColorExpandSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderCacheExpandSpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); +static void XAARenderPixmapCopySpans( + GCPtr, int, DDXPointPtr, int*, int, int, int); + +void +XAAFillSpans( + DrawablePtr pDraw, + 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 +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int type = 0; + ClipAndRenderSpansFunc function; + Bool fastClip = FALSE; + + if((nInit <= 0) || !pGC->planemask) + return; + + if(!RegionNumRects(pGC->pCompositeClip)) + return; + + switch(pGC->fillStyle) { + case FillSolid: + type = DO_SOLID; + break; + case FillStippled: + type = (*infoRec->StippledFillChooser)(pGC); + break; + case FillOpaqueStippled: + if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid && + CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) && + CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) && + CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) && + CHECK_FG(pGC,infoRec->FillSpansSolidFlags)) + type = DO_SOLID; + else + type = (*infoRec->OpaqueStippledFillChooser)(pGC); + break; + case FillTiled: + type = (*infoRec->TiledFillChooser)(pGC); + break; + } + + switch(type) { + case DO_SOLID: + function = XAARenderSolidSpans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) + fastClip = TRUE; + break; + case DO_COLOR_8x8: + function = XAARenderColor8x8Spans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL) + fastClip = TRUE; + break; + case DO_MONO_8x8: + function = XAARenderMono8x8Spans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL) + fastClip = TRUE; + break; + case DO_CACHE_BLT: + function = XAARenderCacheBltSpans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) + fastClip = TRUE; + break; + case DO_COLOR_EXPAND: + function = XAARenderColorExpandSpans; + break; + case DO_CACHE_EXPAND: + function = XAARenderCacheExpandSpans; + if(infoRec->ClippingFlags & + HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND) + fastClip = TRUE; + break; + case DO_PIXMAP_COPY: + function = XAARenderPixmapCopySpans; + if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY) + fastClip = TRUE; + break; + case DO_IMAGE_WRITE: + default: + (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit, + pwidthInit, fSorted); + return; + } + + + if((nInit < 10) || (RegionNumRects(pGC->pCompositeClip) != 1)) + fastClip = FALSE; + + if(fastClip) { + infoRec->ClipBox = &pGC->pCompositeClip->extents; + (*function)(pGC, nInit, pptInit, pwidthInit, fSorted, + pDraw->x, pDraw->y); + infoRec->ClipBox = NULL; + } else + XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted, + function, pDraw->x, pDraw->y); +} + + + /*********************\ + | Solid Spans | + \*********************/ + + +static void +XAARenderSolidSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + + (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted); +} + + + /************************\ + | Mono 8x8 Spans | + \************************/ + + +static void +XAARenderMono8x8Spans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAAPixmapPtr pPriv; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + fg = pPriv->fg; bg = pPriv->bg; + break; + default: /* Muffle compiler */ + pPriv = NULL; /* Kaboom */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn, + fg, bg, pGC->alu, pGC->planemask, + n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); +} + + + /*************************\ + | Color 8x8 Spans | + \*************************/ + + +static void +XAARenderColor8x8Spans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + PixmapPtr pPix; + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + pPix = pGC->stipple; + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + case FillTiled: + pPix = pGC->tile.pixmap; + fg = -1; bg = -1; + break; + default: /* Muffle compiler */ + pPix = NULL; + fg = -1; bg = -1; + break; + } + + pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg); + + (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, + (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y)); +} + + + /****************************\ + | Color Expand Spans | + \****************************/ + + +static void +XAARenderColorExpandSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); + +} + + + /*************************\ + | Cache Blt Spans | + \*************************/ + + +static void +XAARenderCacheBltSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache; + + switch(pGC->fillStyle) { + case FillStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, -1); + break; + case FillOpaqueStippled: + pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple, + pGC->fgPixel, pGC->bgPixel); + break; + case FillTiled: + pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap); + break; + default: /* Muffle compiler */ + pCache = NULL; + break; + } + + (*infoRec->FillCacheBltSpans) (infoRec->pScrn, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); + +} + + + /****************************\ + | Cache Expand Spans | + \****************************/ + + +static void +XAARenderCacheExpandSpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int fg, bg; + + switch(pGC->fillStyle) { + case FillStippled: + fg = pGC->fgPixel; bg = -1; + break; + case FillOpaqueStippled: + fg = pGC->fgPixel; bg = pGC->bgPixel; + break; + default: /* Muffle compiler */ + fg = -1; bg = -1; + break; + } + + (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), + pGC->stipple); +} + + + /***************************\ + | Pixmap Copy Spans | + \***************************/ + + +static void +XAARenderPixmapCopySpans( + GCPtr pGC, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec); + XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); + + pCache->x = pPriv->offscreenArea->box.x1; + pCache->y = pPriv->offscreenArea->box.y1; + pCache->w = pCache->orig_w = + pPriv->offscreenArea->box.x2 - pCache->x; + pCache->h = pCache->orig_h = + pPriv->offscreenArea->box.y2 - pCache->y; + pCache->trans_color = -1; + + (*infoRec->FillCacheBltSpans) (infoRec->pScrn, + pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache, + (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y)); +} + + + + + + /****************\ + | Solid | + \****************/ + + +void +XAAFillSolidSpans( + ScrnInfoPtr pScrn, + int fg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + + (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + if (*pwidth > 0) + (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y, + *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + /***************\ + | Mono 8x8 | + \***************/ + + +void +XAAFillMono8x8PatternSpansScreenOrigin( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + int pattern0, int pattern1, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + + if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) { + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } + } else { + XAACacheInfoPtr pCache = + (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + patx += pCache->offsets[slot].x; + paty += pCache->offsets[slot].y; + xorg = patx; yorg = paty; + } + } + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAFillMono8x8PatternSpans( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + int pattern0, int pattern1, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pattern0, paty = pattern1; + int xorg, yorg, slot; + XAACacheInfoPtr pCache = NULL; + + + if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){ + pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1); + patx = pCache->x; paty = pCache->y; + } + + (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty, + fg, bg, rop, planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + xorg = (ppt->x - xorigin) & 0x07; + yorg = (ppt->y - yorigin) & 0x07; + + if(!(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + if(infoRec->Mono8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_BITS) { + patx = pattern0; paty = pattern1; + XAARotateMonoPattern(&patx, &paty, xorg, yorg, + (infoRec->Mono8x8PatternFillFlags & + BIT_ORDER_IN_BYTE_MSBFIRST)); + xorg = patx; yorg = paty; + } else { + slot = (yorg << 3) + xorg; + xorg = patx + pCache->offsets[slot].x; + yorg = paty + pCache->offsets[slot].y; + } + } + + (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + + + /****************\ + | Color 8x8 | + \****************/ + + +void +XAAFillColor8x8PatternSpansScreenOrigin( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + XAACacheInfoPtr pCache, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int patx = pCache->x, paty = pCache->y; + int xorg = (-xorigin) & 0x07; + int yorg = (-yorigin) & 0x07; + + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + int slot = (yorg << 3) + xorg; + paty += pCache->offsets[slot].y; + patx += pCache->offsets[slot].x; + xorg = patx; yorg = paty; + } + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty, + rop, planemask, pCache->trans_color); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + +void +XAAFillColor8x8PatternSpans( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, int fSorted, + XAACacheInfoPtr pCache, + int xorigin, int yorigin +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int xorg, yorg, slot; + + (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y, + rop, planemask, pCache->trans_color); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + xorg = (ppt->x - xorigin) & 0x07; + yorg = (ppt->y - yorigin) & 0x07; + + if(!(infoRec->Color8x8PatternFillFlags & + HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){ + slot = (yorg << 3) + xorg; + yorg = pCache->y + pCache->offsets[slot].y; + xorg = pCache->x + pCache->offsets[slot].x; + } + + (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn, + xorg, yorg, ppt->x, ppt->y, *pwidth, 1); + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + /*****************\ + | Cache Blit | + \*****************/ + + +void +XAAFillCacheBltSpans( + ScrnInfoPtr pScrn, + int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + XAACacheInfoPtr pCache, + int xorg, int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, w, phaseX, phaseY, blit_w; + + (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask, + pCache->trans_color); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + x = ppt->x; + w = *pwidth; + phaseX = (x - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + phaseY = (ppt->y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + + while(1) { + blit_w = pCache->w - phaseX; + if(blit_w > w) blit_w = w; + + (*infoRec->SubsequentScreenToScreenCopy)(pScrn, + pCache->x + phaseX, pCache->y + phaseY, + x, ppt->y, blit_w, 1); + + w -= blit_w; + if(!w) break; + x += blit_w; + phaseX = (phaseX + blit_w) % pCache->orig_w; + } + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + + /****************\ + | Cache Expand | + \****************/ + + +void +XAAFillCacheExpandSpans( + ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int n, + DDXPointPtr ppt, + int *pwidth, + int fSorted, + int xorg, int yorg, + PixmapPtr pPix +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + int x, w, phaseX, phaseY, blit_w, cacheWidth; + XAACacheInfoPtr pCache; + + pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix); + + cacheWidth = (pCache->w * pScrn->bitsPerPixel) / + infoRec->CacheColorExpandDensity; + + (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop, + planemask); + + if(infoRec->ClipBox) + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + + while(n--) { + x = ppt->x; + w = *pwidth; + phaseX = (x - xorg) % pCache->orig_w; + if(phaseX < 0) phaseX += pCache->orig_w; + phaseY = (ppt->y - yorg) % pCache->orig_h; + if(phaseY < 0) phaseY += pCache->orig_h; + + while(1) { + blit_w = cacheWidth - phaseX; + if(blit_w > w) blit_w = w; + + (*infoRec->SubsequentScreenToScreenColorExpandFill)( + pScrn, x, ppt->y, blit_w, 1, + pCache->x, pCache->y + phaseY, phaseX); + + w -= blit_w; + if(!w) break; + x += blit_w; + phaseX = (phaseX + blit_w) % pCache->orig_w; + } + ppt++; pwidth++; + } + + if(infoRec->ClipBox) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} + + + +void +XAAClipAndRenderSpans( + GCPtr pGC, + DDXPointPtr ppt, + int *pwidth, + int nspans, + int fSorted, + ClipAndRenderSpansFunc func, + int xorg, + int yorg +){ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + DDXPointPtr pptNew, pptBase; + int *pwidthBase, *pwidthNew; + int Right, numRects, MaxBoxes; + + MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int)); + pptBase = (DDXPointRec*)infoRec->PreAllocMem; + pwidthBase = (int*)(&pptBase[MaxBoxes]); + + pptNew = pptBase; + pwidthNew = pwidthBase; + + numRects = RegionNumRects(pGC->pCompositeClip); + + if(numRects == 1) { + BoxPtr pextent = RegionRects(pGC->pCompositeClip); + + while(nspans--) { + if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) { + pptNew->x = max(pextent->x1, ppt->x); + Right = ppt->x + *pwidth; + *pwidthNew = min(pextent->x2, Right) - pptNew->x; + + if (*pwidthNew > 0) { + pptNew->y = ppt->y; + pptNew++; + pwidthNew++; + + if(pptNew >= (pptBase + MaxBoxes)) { + (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted, + xorg, yorg); + pptNew = pptBase; + pwidthNew = pwidthBase; + } + } + } + ppt++; + pwidth++; + } + } else if (numRects) { + BoxPtr pbox; + int nbox; + + while(nspans--) { + nbox = numRects; + pbox = RegionRects(pGC->pCompositeClip); + + /* find the first band */ + while(nbox && (pbox->y2 <= ppt->y)) { + pbox++; + nbox--; + } + + if(nbox && (pbox->y1 <= ppt->y)) { + int orig_y = pbox->y1; + Right = ppt->x + *pwidth; + while(nbox && (orig_y == pbox->y1)) { + if(pbox->x2 <= ppt->x) { + nbox--; + pbox++; + continue; + } + + if(pbox->x1 >= Right) { + nbox = 0; + break; + } + + pptNew->x = max(pbox->x1, ppt->x); + *pwidthNew = min(pbox->x2, Right) - pptNew->x; + if(*pwidthNew > 0) { + pptNew->y = ppt->y; + pptNew++; + pwidthNew++; + + if(pptNew >= (pptBase + MaxBoxes)) { + (*func)(pGC, MaxBoxes, pptBase, pwidthBase, + fSorted, xorg, yorg); + pptNew = pptBase; + pwidthNew = pwidthBase; + } + } + pbox++; + nbox--; + } + } + ppt++; + pwidth++; + } + } + + if(pptNew != pptBase) + (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted, + xorg, yorg); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaStateChange.c b/xorg-server/hw/xfree86/xaa/xaaStateChange.c index 9c98a32f2..4eb15125b 100644 --- a/xorg-server/hw/xfree86/xaa/xaaStateChange.c +++ b/xorg-server/hw/xfree86/xaa/xaaStateChange.c @@ -272,8 +272,8 @@ typedef struct _XAAStateWrapRec { int width, int height, int flags); } XAAStateWrapRec, *XAAStateWrapPtr; -static int XAAStateKeyIndex; -static DevPrivateKey XAAStateKey = &XAAStateKeyIndex; +static DevPrivateKeyRec XAAStateKeyRec; +#define XAAStateKey (&XAAStateKeyRec) /* Wrap functions start here */ #define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\ @@ -1500,6 +1500,7 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec) XAAStateWrapPtr pStatePriv; int i = 0; + if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE; dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv); pStatePriv->RestoreAccelState = infoRec->RestoreAccelState; diff --git a/xorg-server/hw/xfree86/xaa/xaaTEText.c b/xorg-server/hw/xfree86/xaa/xaaTEText.c index 1e28d3103..2cc5fc1e6 100644 --- a/xorg-server/hw/xfree86/xaa/xaaTEText.c +++ b/xorg-server/hw/xfree86/xaa/xaaTEText.c @@ -110,7 +110,7 @@ XAAImageText8TEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); unsigned long n; - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; (*pGC->font->get_glyphs)(pGC->font, (unsigned long)count, @@ -134,7 +134,7 @@ XAAImageText16TEColorExpansion( XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); unsigned long n; - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; (*pGC->font->get_glyphs)( @@ -169,7 +169,7 @@ XAAImageGlyphBltTEColorExpansion( { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; XAAGlyphBltTEColorExpansion( @@ -189,7 +189,7 @@ XAAPolyGlyphBltTEColorExpansion( { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) + if(!RegionNumRects(pGC->pCompositeClip)) return; XAAGlyphBltTEColorExpansion( @@ -229,8 +229,8 @@ XAAGlyphBltTEColorExpansion( int skippix, skipglyphs; int Left, Right, Top, Bottom; int LeftEdge, RightEdge, ytop, ybot; - int nbox = REGION_NUM_RECTS(cclip); - BoxPtr pbox = REGION_RECTS(cclip); + int nbox = RegionNumRects(cclip); + BoxPtr pbox = RegionRects(cclip); unsigned int **glyphs = NULL; int glyphWidth = FONTMAXBOUNDS(font, characterWidth); @@ -299,8 +299,7 @@ XAAGlyphBltTEColorExpansion( skippix, ytop - Top, glyphs + skipglyphs, glyphWidth, fg, bg, rop, planemask); - if (fallbackBits) - free(fallbackBits); + free(fallbackBits); } nbox--; pbox++; diff --git a/xorg-server/hw/xfree86/xaa/xaaWideLine.c b/xorg-server/hw/xfree86/xaa/xaaWideLine.c index a684d6676..f73e04f17 100644 --- a/xorg-server/hw/xfree86/xaa/xaaWideLine.c +++ b/xorg-server/hw/xfree86/xaa/xaaWideLine.c @@ -1,921 +1,921 @@ -/* - -XAAPolylinesWideSolid does not maintain a span list and subsequently does -not follow the "touch-each-pixel-once" rules for wide lines and arcs. -This means it can only be used in the case where we have -miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we -limited usage of this function to one rect situations. This -function is used only for solid lines. - - Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu) -Original mi code written by Keith Packard. - -*/ - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include - -#include "misc.h" -#include "xf86.h" -#include "xf86_OSproc.h" - -#include -#include "windowstr.h" -#include "gcstruct.h" -#include "regionstr.h" -#include "miwideline.h" -#include "mi.h" -#include "xf86str.h" -#include "xaa.h" -#include "xaalocal.h" - -#define DRAW_POINT(pScrn, x, y) \ - if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \ - else XAAPointHelper(pScrn, x, y) - -#define FILL_RECT(pScrn, x, y, w, h) \ - if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \ - else XAAFillRectHelper(pScrn, x, y, w, h) - -#define FILL_SPAN(pScrn, x, y, w) \ - if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \ - else XAASpanHelper(pScrn, x, y, w) - - -#define CLIPSTEPEDGE(edgey,edge,edgeleft) \ - if (ybase == edgey) { \ - if (edgeleft) { \ - if (edge->x > xcl) \ - xcl = edge->x; \ - } else { \ - if (edge->x < xcr) \ - xcr = edge->x; \ - } \ - edgey++; \ - edge->x += edge->stepx; \ - edge->e += edge->dx; \ - if (edge->e > 0) { \ - edge->x += edge->signdx; \ - edge->e -= edge->dy; \ - } \ - } - -static void -XAAPointHelper(ScrnInfoPtr pScrn, int x, int y) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - BoxPtr extents = infoRec->ClipBox; - - if((x >= extents->x1) && (x < extents->x2) && - (y >= extents->y1) && (y < extents->y2)) - (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); -} - -static void -XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - BoxPtr extents = infoRec->ClipBox; - int x2 = x1 + dx; - int y2 = y1 + dy; - - if(x1 < extents->x1) x1 = extents->x1; - if(x2 >= extents->x2) x2 = extents->x2; - if((dx = x2 - x1)<1) return; - if(y1 < extents->y1) y1 = extents->y1; - if(y2 >= extents->y2) y2 = extents->y2; - if((dy = y2 - y1)<1) return; - - (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy); -} - - -static void -XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); - BoxPtr extents = infoRec->ClipBox; - int x2; - - if((y < extents->y1) || (y >= extents->y2)) return; - - x2 = x1 + width; - if(x1 < extents->x1) x1 = extents->x1; - if(x2 > extents->x2) x2 = extents->x2; - width = x2 - x1; - - if(width > 0) - (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1); - -} - -#define FixError(x, dx, dy, e, sign, step, h) { \ - e += (h) * dx; \ - x += (h) * step; \ - if(e > 0) { \ - x += e * sign/dy; \ - e %= dy; \ - if(e) { \ - x += sign; \ - e -= dy; \ - } \ - } \ -} - - -static void -XAAFillPolyHelper ( - GCPtr pGC, - int y, /* start y coordinate */ - int overall_height, /* height of entire segment */ - PolyEdgePtr left, PolyEdgePtr right, - int left_count, int right_count ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - BoxPtr extents = infoRec->ClipBox; - int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx; - int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx; - int height, left_height, right_height; - int xorg; - Bool hardClip; - - if((y >= extents->y2) || ((y + overall_height) <= extents->y1)) - return; - - /* Muffle compiler */ - left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0; - right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0; - - left_height = right_height = 0; - xorg = 0; - - hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - while ((left_count || left_height) && (right_count || right_height)) { - if (!left_height && left_count) { - left_height = left->height; - left_x = left->x + xorg; - left_stepx = left->stepx; - left_signdx = left->signdx; - left_e = left->e; - left_dy = left->dy; - left_dx = left->dx; - left_count--; - left++; - } - if (!right_height && right_count) { - right_height = right->height; - right_x = right->x + xorg + 1; - right_stepx = right->stepx; - right_signdx = right->signdx; - right_e = right->e; - right_dy = right->dy; - right_dx = right->dx; - right_count--; - right++; - } - - height = (left_height > right_height) ? right_height : left_height; - - left_height -= height; - right_height -= height; - - if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) { - int right_DX, left_DX; - - right_DX = (right_dx * right_signdx) + (right_stepx * right_dy); - left_DX = (left_dx * left_signdx) + (left_stepx * left_dy); - - (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height, - left_x, left_DX, left_dy, left_e, - right_x - 1, right_DX, right_dy, right_e); - - FixError(left_x, left_dx, left_dy, left_e, left_signdx, - left_stepx, height); - FixError(right_x, right_dx, right_dy, right_e, right_signdx, - right_stepx, height); - y += height; - continue; - } - - while (height--) { - if(right_x > left_x) { - FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x); - } - y++; - - left_x += left_stepx; - left_e += left_dx; - if (left_e > 0) { - left_x += left_signdx; - left_e -= left_dy; - } - right_x += right_stepx; - right_e += right_dx; - if (right_e > 0) { - right_x += right_signdx; - right_e -= right_dy; - } - - } - } -} - - - -static void -XAAWideSegment ( - GCPtr pGC, - int x1, int y1, int x2, int y2, - Bool projectLeft, Bool projectRight, - LineFacePtr leftFace, LineFacePtr rightFace ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - double l, L, r; - double xa, ya; - double projectXoff, projectYoff; - double k; - double maxy; - int x, y; - int dx, dy; - int finaly; - PolyEdgePtr left, right; - PolyEdgePtr top, bottom; - int lefty, righty, topy, bottomy; - int signdx; - PolyEdgeRec lefts[2], rights[2]; - LineFacePtr tface; - int lw = pGC->lineWidth; - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - /* draw top-to-bottom always */ - if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) { - x = x1; - x1 = x2; - x2 = x; - - y = y1; - y1 = y2; - y2 = y; - - x = projectLeft; - projectLeft = projectRight; - projectRight = x; - - tface = leftFace; - leftFace = rightFace; - rightFace = tface; - } - - dy = y2 - y1; - signdx = 1; - dx = x2 - x1; - if (dx < 0) - signdx = -1; - - leftFace->x = x1; - leftFace->y = y1; - leftFace->dx = dx; - leftFace->dy = dy; - - rightFace->x = x2; - rightFace->y = y2; - rightFace->dx = -dx; - rightFace->dy = -dy; - - if (!dy) { - rightFace->xa = 0; - rightFace->ya = (double) lw / 2.0; - rightFace->k = -(double) (lw * dx) / 2.0; - leftFace->xa = 0; - leftFace->ya = -rightFace->ya; - leftFace->k = rightFace->k; - x = x1; - if (projectLeft) - x -= (lw >> 1); - y = y1 - (lw >> 1); - dx = x2 - x; - if (projectRight) - dx += ((lw + 1) >> 1); - dy = lw; - FILL_RECT(infoRec->pScrn, x, y, dx, dy); - } else if (!dx) { - leftFace->xa = (double) lw / 2.0; - leftFace->ya = 0; - leftFace->k = (double) (lw * dy) / 2.0; - rightFace->xa = -leftFace->xa; - rightFace->ya = 0; - rightFace->k = leftFace->k; - y = y1; - if (projectLeft) - y -= lw >> 1; - x = x1 - (lw >> 1); - dy = y2 - y; - if (projectRight) - dy += ((lw + 1) >> 1); - dx = lw; - FILL_RECT(infoRec->pScrn, x, y, dx, dy); - } else { - l = ((double) lw) / 2.0; - L = sqrt((double)(dx*dx + dy*dy)); - - if (dx < 0) { - right = &rights[1]; - left = &lefts[0]; - top = &rights[0]; - bottom = &lefts[1]; - } else { - right = &rights[0]; - left = &lefts[1]; - top = &lefts[0]; - bottom = &rights[1]; - } - r = l / L; - - /* coord of upper bound at integral y */ - ya = -r * dx; - xa = r * dy; - - projectXoff = -ya; - projectYoff = xa; - - /* xa * dy - ya * dx */ - k = l * L; - - leftFace->xa = xa; - leftFace->ya = ya; - leftFace->k = k; - rightFace->xa = -xa; - rightFace->ya = -ya; - rightFace->k = k; - - if (projectLeft) - righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, - k, dx, dy, x1, y1, 0, right); - else - righty = miPolyBuildEdge (xa, ya, - k, dx, dy, x1, y1, 0, right); - - /* coord of lower bound at integral y */ - ya = -ya; - xa = -xa; - - /* xa * dy - ya * dx */ - k = - k; - - if (projectLeft) - lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, - k, dx, dy, x1, y1, 1, left); - else - lefty = miPolyBuildEdge (xa, ya, - k, dx, dy, x1, y1, 1, left); - - /* coord of top face at integral y */ - - if (signdx > 0) { - ya = -ya; - xa = -xa; - } - - if (projectLeft) { - double xap = xa - projectXoff; - double yap = ya - projectYoff; - topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, - -dy, dx, x1, y1, dx > 0, top); - } - else - topy = miPolyBuildEdge(xa, ya, 0.0, - -dy, dx, x1, y1, dx > 0, top); - - /* coord of bottom face at integral y */ - - if (projectRight) { - double xap = xa + projectXoff; - double yap = ya + projectYoff; - bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, - -dy, dx, x2, y2, dx < 0, bottom); - maxy = -ya + projectYoff; - } else { - bottomy = miPolyBuildEdge (xa, ya, 0.0, - -dy, dx, x2, y2, dx < 0, bottom); - maxy = -ya; - } - - finaly = ICEIL (maxy) + y2; - - if (dx < 0) { - left->height = bottomy - lefty; - right->height = finaly - righty; - top->height = righty - topy; - } else { - right->height = bottomy - righty; - left->height = finaly - lefty; - top->height = lefty - topy; - } - bottom->height = finaly - bottomy; - XAAFillPolyHelper (pGC, topy, - bottom->height + bottomy - topy, lefts, rights, 2, 2); - } -} - - -static void -XAALineArcI (GCPtr pGC, int xorg, int yorg) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int x, y, e, ex; - int slw = pGC->lineWidth; - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - y = (slw >> 1) + 1; - if (slw & 1) - e = - ((y << 2) + 3); - else - e = - (y << 3); - ex = -4; - x = 0; - while (y) { - e += (y << 3) - 4; - while (e >= 0) { - x++; - e += (ex = -((x << 3) + 4)); - } - y--; - slw = (x << 1) + 1; - if ((e == ex) && (slw > 1)) - slw--; - - FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw); - - if ((y != 0) && ((slw > 1) || (e != ex))) { - FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw); - } - } -} - - -static void -XAALineArcD ( - GCPtr pGC, - double xorg, - double yorg, - PolyEdgePtr edge1, - int edgey1, - Bool edgeleft1, - PolyEdgePtr edge2, - int edgey2, - Bool edgeleft2 ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - double radius, x0, y0, el, er, yk, xlk, xrk, k; - int xbase, ybase, y, boty, xl, xr, xcl, xcr; - int ymin, ymax; - Bool edge1IsMin, edge2IsMin; - int ymin1, ymin2; - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - - - xbase = floor(xorg); - x0 = xorg - xbase; - ybase = ICEIL (yorg); - y0 = yorg - ybase; - - xlk = x0 + x0 + 1.0; - xrk = x0 + x0 - 1.0; - yk = y0 + y0 - 1.0; - radius = ((double)pGC->lineWidth) / 2.0; - y = floor(radius - y0 + 1.0); - ybase -= y; - ymin = ybase; - ymax = 65536; - edge1IsMin = FALSE; - ymin1 = edgey1; - if (edge1->dy >= 0) { - if (!edge1->dy) { - if (edgeleft1) - edge1IsMin = TRUE; - else - ymax = edgey1; - edgey1 = 65536; - } else if ((edge1->signdx < 0) == edgeleft1) - edge1IsMin = TRUE; - } - edge2IsMin = FALSE; - ymin2 = edgey2; - if (edge2->dy >= 0) { - if (!edge2->dy) { - if (edgeleft2) - edge2IsMin = TRUE; - else - ymax = edgey2; - edgey2 = 65536; - } else if ((edge2->signdx < 0) == edgeleft2) - edge2IsMin = TRUE; - } - if (edge1IsMin) { - ymin = ymin1; - if (edge2IsMin && (ymin1 > ymin2)) - ymin = ymin2; - } else if (edge2IsMin) - ymin = ymin2; - el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0); - er = el + xrk; - xl = 1; - xr = 0; - if (x0 < 0.5) { - xl = 0; - el -= xlk; - } - boty = (y0 < -0.5) ? 1 : 0; - if (ybase + y - boty > ymax) - boty = ymax - ybase - y; - while (y > boty) { - k = (y << 1) + yk; - er += k; - while (er > 0.0) { - xr++; - er += xrk - (xr << 1); - } - el += k; - while (el >= 0.0) { - xl--; - el += (xl << 1) - xlk; - } - y--; - ybase++; - if (ybase < ymin) - continue; - xcl = xl + xbase; - xcr = xr + xbase; - CLIPSTEPEDGE(edgey1, edge1, edgeleft1); - CLIPSTEPEDGE(edgey2, edge2, edgeleft2); - if(xcr >= xcl) { - FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); - } - } - er = xrk - (xr << 1) - er; - el = (xl << 1) - xlk - el; - boty = floor(-y0 - radius + 1.0); - if (ybase + y - boty > ymax) - boty = ymax - ybase - y; - while (y > boty) { - k = (y << 1) + yk; - er -= k; - while ((er >= 0.0) && (xr >= 0)) { - xr--; - er += xrk - (xr << 1); - } - el -= k; - while ((el > 0.0) && (xl <= 0)) { - xl++; - el += (xl << 1) - xlk; - } - y--; - ybase++; - if (ybase < ymin) - continue; - xcl = xl + xbase; - xcr = xr + xbase; - CLIPSTEPEDGE(edgey1, edge1, edgeleft1); - CLIPSTEPEDGE(edgey2, edge2, edgeleft2); - if(xcr >= xcl) { - FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); - } - } -} - - -static void -XAALineArc ( - GCPtr pGC, - LineFacePtr leftFace, - LineFacePtr rightFace, - double xorg, - double yorg, - Bool isInt ) -{ - int xorgi, yorgi; - PolyEdgeRec edge1, edge2; - int edgey1, edgey2; - Bool edgeleft1, edgeleft2; - - if (isInt) { - xorgi = leftFace ? leftFace->x : rightFace->x; - yorgi = leftFace ? leftFace->y : rightFace->y; - } else { /* Muffle compiler */ - xorgi = yorgi = 0; - } - edgey1 = 65536; - edgey2 = 65536; - edge1.x = 0; /* not used, keep memory checkers happy */ - edge1.dy = -1; - edge2.x = 0; /* not used, keep memory checkers happy */ - edge2.dy = -1; - edgeleft1 = FALSE; - edgeleft2 = FALSE; - - if ((pGC->lineWidth > 2) && - ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) || - (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) { - if (isInt) { - xorg = (double) xorgi; - yorg = (double) yorgi; - } - - if (leftFace && rightFace) - miRoundJoinClip (leftFace, rightFace, &edge1, &edge2, - &edgey1, &edgey2, &edgeleft1, &edgeleft2); - else if (leftFace) - edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1); - else if (rightFace) - edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2); - - isInt = FALSE; - } - - if (isInt) { - if(pGC->lineWidth == 1) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - DRAW_POINT(infoRec->pScrn, xorgi, yorgi); - } else - XAALineArcI(pGC, xorgi, yorgi); - } else - XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1, - &edge2, edgey2, edgeleft2); - -} - - -static void -XAALineJoin ( - GCPtr pGC, - LineFacePtr pLeft, - LineFacePtr pRight ) -{ - double mx = 0, my = 0; - double denom = 0; - PolyVertexRec vertices[4]; - PolySlopeRec slopes[4]; - int edgecount; - PolyEdgeRec left[4], right[4]; - int nleft, nright; - int y, height; - int swapslopes; - int joinStyle = pGC->joinStyle; - int lw = pGC->lineWidth; - - if (lw == 1) { - /* Lines going in the same direction have no join */ - if ((pLeft->dx >= 0) == (pRight->dx <= 0)) - return; - if (joinStyle != JoinRound) { - denom = - pLeft->dx * (double)pRight->dy + pRight->dx * - (double)pLeft->dy; - if (denom == 0.0) - return; /* no join to draw */ - } - if (joinStyle != JoinMiter) { - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); - DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y); - return; - } - } else { - if (joinStyle == JoinRound) { - XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE); - return; - } - denom = - pLeft->dx * (double)pRight->dy + pRight->dx * - (double)pLeft->dy; - if (denom == 0.0) - return; /* no join to draw */ - } - - swapslopes = 0; - if (denom > 0) { - pLeft->xa = -pLeft->xa; - pLeft->ya = -pLeft->ya; - pLeft->dx = -pLeft->dx; - pLeft->dy = -pLeft->dy; - } else { - swapslopes = 1; - pRight->xa = -pRight->xa; - pRight->ya = -pRight->ya; - pRight->dx = -pRight->dx; - pRight->dy = -pRight->dy; - } - - vertices[0].x = pRight->xa; - vertices[0].y = pRight->ya; - slopes[0].dx = -pRight->dy; - slopes[0].dy = pRight->dx; - slopes[0].k = 0; - - vertices[1].x = 0; - vertices[1].y = 0; - slopes[1].dx = pLeft->dy; - slopes[1].dy = -pLeft->dx; - slopes[1].k = 0; - - vertices[2].x = pLeft->xa; - vertices[2].y = pLeft->ya; - - if (joinStyle == JoinMiter) { - my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) - - pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/ - denom; - if (pLeft->dy != 0) - mx = pLeft->xa + (my - pLeft->ya) * - (double) pLeft->dx / (double) pLeft->dy; - else - mx = pRight->xa + (my - pRight->ya) * - (double) pRight->dx / (double) pRight->dy; - - /* check miter limit */ - if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw) - joinStyle = JoinBevel; - } - - if (joinStyle == JoinMiter) { - slopes[2].dx = pLeft->dx; - slopes[2].dy = pLeft->dy; - slopes[2].k = pLeft->k; - if (swapslopes) { - slopes[2].dx = -slopes[2].dx; - slopes[2].dy = -slopes[2].dy; - slopes[2].k = -slopes[2].k; - } - vertices[3].x = mx; - vertices[3].y = my; - slopes[3].dx = pRight->dx; - slopes[3].dy = pRight->dy; - slopes[3].k = pRight->k; - if (swapslopes) { - slopes[3].dx = -slopes[3].dx; - slopes[3].dy = -slopes[3].dy; - slopes[3].k = -slopes[3].k; - } - edgecount = 4; - } else { - double scale, dx, dy, adx, ady; - - adx = dx = pRight->xa - pLeft->xa; - ady = dy = pRight->ya - pLeft->ya; - if (adx < 0) - adx = -adx; - if (ady < 0) - ady = -ady; - scale = ady; - if (adx > ady) - scale = adx; - slopes[2].dx = (dx * 65536) / scale; - slopes[2].dy = (dy * 65536) / scale; - slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy - - (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0; - edgecount = 3; - } - - y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y, - left, right, &nleft, &nright, &height); - XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright); -} - - -void -XAAPolylinesWideSolid ( - DrawablePtr pDrawable, - GCPtr pGC, - int mode, - int npt, - DDXPointPtr pPts ) -{ - XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); - int x1, y1, x2, y2; - Bool projectLeft, projectRight; - LineFaceRec leftFace, rightFace, prevRightFace, firstFace; - int first = TRUE; - Bool somethingDrawn = FALSE; - Bool selfJoin = FALSE; - int xorg = pDrawable->x; - int yorg = pDrawable->y; - Bool hardClip = FALSE; - - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) - return; - - if(REGION_NUM_RECTS(pGC->pCompositeClip) != 1) { - miWideLine(pDrawable, pGC, mode, npt, pPts); - return; - } - - x2 = pPts->x; - y2 = pPts->y; - if (npt > 1) { - if (mode == CoordModePrevious) { - int nptTmp; - register DDXPointPtr pPtsTmp; - - x1 = x2; - y1 = y2; - nptTmp = npt; - pPtsTmp = pPts + 1; - while (--nptTmp) { - x1 += pPtsTmp->x; - y1 += pPtsTmp->y; - ++pPtsTmp; - } - if ((x2 == x1) && (y2 == y1)) - selfJoin = TRUE; - } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y)) - selfJoin = TRUE; - } - - projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin); - projectRight = FALSE; - - (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, - pGC->planemask); - - infoRec->ClipBox = &pGC->pCompositeClip->extents; - - if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) { - hardClip = TRUE; - (*infoRec->SetClippingRectangle)(infoRec->pScrn, - infoRec->ClipBox->x1, infoRec->ClipBox->y1, - infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); - } - - x2 += xorg; - y2 += yorg; - while (--npt) { - x1 = x2; - y1 = y2; - ++pPts; - x2 = pPts->x; - y2 = pPts->y; - if (mode == CoordModePrevious) { - x2 += x1; - y2 += y1; - } else { - x2 += xorg; - y2 += yorg; - } - if ((x1 != x2) || (y1 != y2)) { - somethingDrawn = TRUE; - if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin) - projectRight = TRUE; - XAAWideSegment(pGC, x1, y1, x2, y2, - projectLeft, projectRight, &leftFace, &rightFace); - if (first) { - if (selfJoin) - firstFace = leftFace; - else if (pGC->capStyle == CapRound) { - if (pGC->lineWidth == 1) { - DRAW_POINT(infoRec->pScrn, x1, y1); - } else - XAALineArc(pGC,&leftFace, (LineFacePtr) NULL, - (double)0.0, (double)0.0,TRUE); - } - } else - XAALineJoin (pGC, &leftFace, &prevRightFace); - - prevRightFace = rightFace; - first = FALSE; - projectLeft = FALSE; - } - if (npt == 1 && somethingDrawn) { - if (selfJoin) - XAALineJoin (pGC, &firstFace, &rightFace); - else if (pGC->capStyle == CapRound) { - if (pGC->lineWidth == 1) { - DRAW_POINT(infoRec->pScrn, x2, y2); - } else - XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, - (double)0.0, (double)0.0,TRUE); - } - } - } - /* handle crock where all points are coincedent */ - if (!somethingDrawn) { - projectLeft = (pGC->capStyle == CapProjecting); - XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft, - &leftFace, &rightFace); - if (pGC->capStyle == CapRound) { - XAALineArc (pGC, &leftFace, (LineFacePtr) NULL, - (double)0.0, (double)0.0, TRUE); - rightFace.dx = -1; /* sleezy hack to make it work */ - XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, - (double)0.0, (double)0.0, TRUE); - } - } - - infoRec->ClipBox = NULL; - if(hardClip) - (*infoRec->DisableClipping)(infoRec->pScrn); - - SET_SYNC_FLAG(infoRec); -} +/* + +XAAPolylinesWideSolid does not maintain a span list and subsequently does +not follow the "touch-each-pixel-once" rules for wide lines and arcs. +This means it can only be used in the case where we have +miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we +limited usage of this function to one rect situations. This +function is used only for solid lines. + + Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu) +Original mi code written by Keith Packard. + +*/ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" + +#include +#include "windowstr.h" +#include "gcstruct.h" +#include "regionstr.h" +#include "miwideline.h" +#include "mi.h" +#include "xf86str.h" +#include "xaa.h" +#include "xaalocal.h" + +#define DRAW_POINT(pScrn, x, y) \ + if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \ + else XAAPointHelper(pScrn, x, y) + +#define FILL_RECT(pScrn, x, y, w, h) \ + if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \ + else XAAFillRectHelper(pScrn, x, y, w, h) + +#define FILL_SPAN(pScrn, x, y, w) \ + if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \ + else XAASpanHelper(pScrn, x, y, w) + + +#define CLIPSTEPEDGE(edgey,edge,edgeleft) \ + if (ybase == edgey) { \ + if (edgeleft) { \ + if (edge->x > xcl) \ + xcl = edge->x; \ + } else { \ + if (edge->x < xcr) \ + xcr = edge->x; \ + } \ + edgey++; \ + edge->x += edge->stepx; \ + edge->e += edge->dx; \ + if (edge->e > 0) { \ + edge->x += edge->signdx; \ + edge->e -= edge->dy; \ + } \ + } + +static void +XAAPointHelper(ScrnInfoPtr pScrn, int x, int y) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + BoxPtr extents = infoRec->ClipBox; + + if((x >= extents->x1) && (x < extents->x2) && + (y >= extents->y1) && (y < extents->y2)) + (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); +} + +static void +XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + BoxPtr extents = infoRec->ClipBox; + int x2 = x1 + dx; + int y2 = y1 + dy; + + if(x1 < extents->x1) x1 = extents->x1; + if(x2 >= extents->x2) x2 = extents->x2; + if((dx = x2 - x1)<1) return; + if(y1 < extents->y1) y1 = extents->y1; + if(y2 >= extents->y2) y2 = extents->y2; + if((dy = y2 - y1)<1) return; + + (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy); +} + + +static void +XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); + BoxPtr extents = infoRec->ClipBox; + int x2; + + if((y < extents->y1) || (y >= extents->y2)) return; + + x2 = x1 + width; + if(x1 < extents->x1) x1 = extents->x1; + if(x2 > extents->x2) x2 = extents->x2; + width = x2 - x1; + + if(width > 0) + (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1); + +} + +#define FixError(x, dx, dy, e, sign, step, h) { \ + e += (h) * dx; \ + x += (h) * step; \ + if(e > 0) { \ + x += e * sign/dy; \ + e %= dy; \ + if(e) { \ + x += sign; \ + e -= dy; \ + } \ + } \ +} + + +static void +XAAFillPolyHelper ( + GCPtr pGC, + int y, /* start y coordinate */ + int overall_height, /* height of entire segment */ + PolyEdgePtr left, PolyEdgePtr right, + int left_count, int right_count ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + BoxPtr extents = infoRec->ClipBox; + int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx; + int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx; + int height, left_height, right_height; + int xorg; + Bool hardClip; + + if((y >= extents->y2) || ((y + overall_height) <= extents->y1)) + return; + + /* Muffle compiler */ + left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0; + right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0; + + left_height = right_height = 0; + xorg = 0; + + hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + while ((left_count || left_height) && (right_count || right_height)) { + if (!left_height && left_count) { + left_height = left->height; + left_x = left->x + xorg; + left_stepx = left->stepx; + left_signdx = left->signdx; + left_e = left->e; + left_dy = left->dy; + left_dx = left->dx; + left_count--; + left++; + } + if (!right_height && right_count) { + right_height = right->height; + right_x = right->x + xorg + 1; + right_stepx = right->stepx; + right_signdx = right->signdx; + right_e = right->e; + right_dy = right->dy; + right_dx = right->dx; + right_count--; + right++; + } + + height = (left_height > right_height) ? right_height : left_height; + + left_height -= height; + right_height -= height; + + if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) { + int right_DX, left_DX; + + right_DX = (right_dx * right_signdx) + (right_stepx * right_dy); + left_DX = (left_dx * left_signdx) + (left_stepx * left_dy); + + (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height, + left_x, left_DX, left_dy, left_e, + right_x - 1, right_DX, right_dy, right_e); + + FixError(left_x, left_dx, left_dy, left_e, left_signdx, + left_stepx, height); + FixError(right_x, right_dx, right_dy, right_e, right_signdx, + right_stepx, height); + y += height; + continue; + } + + while (height--) { + if(right_x > left_x) { + FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x); + } + y++; + + left_x += left_stepx; + left_e += left_dx; + if (left_e > 0) { + left_x += left_signdx; + left_e -= left_dy; + } + right_x += right_stepx; + right_e += right_dx; + if (right_e > 0) { + right_x += right_signdx; + right_e -= right_dy; + } + + } + } +} + + + +static void +XAAWideSegment ( + GCPtr pGC, + int x1, int y1, int x2, int y2, + Bool projectLeft, Bool projectRight, + LineFacePtr leftFace, LineFacePtr rightFace ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + double l, L, r; + double xa, ya; + double projectXoff, projectYoff; + double k; + double maxy; + int x, y; + int dx, dy; + int finaly; + PolyEdgePtr left, right; + PolyEdgePtr top, bottom; + int lefty, righty, topy, bottomy; + int signdx; + PolyEdgeRec lefts[2], rights[2]; + LineFacePtr tface; + int lw = pGC->lineWidth; + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + /* draw top-to-bottom always */ + if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) { + x = x1; + x1 = x2; + x2 = x; + + y = y1; + y1 = y2; + y2 = y; + + x = projectLeft; + projectLeft = projectRight; + projectRight = x; + + tface = leftFace; + leftFace = rightFace; + rightFace = tface; + } + + dy = y2 - y1; + signdx = 1; + dx = x2 - x1; + if (dx < 0) + signdx = -1; + + leftFace->x = x1; + leftFace->y = y1; + leftFace->dx = dx; + leftFace->dy = dy; + + rightFace->x = x2; + rightFace->y = y2; + rightFace->dx = -dx; + rightFace->dy = -dy; + + if (!dy) { + rightFace->xa = 0; + rightFace->ya = (double) lw / 2.0; + rightFace->k = -(double) (lw * dx) / 2.0; + leftFace->xa = 0; + leftFace->ya = -rightFace->ya; + leftFace->k = rightFace->k; + x = x1; + if (projectLeft) + x -= (lw >> 1); + y = y1 - (lw >> 1); + dx = x2 - x; + if (projectRight) + dx += ((lw + 1) >> 1); + dy = lw; + FILL_RECT(infoRec->pScrn, x, y, dx, dy); + } else if (!dx) { + leftFace->xa = (double) lw / 2.0; + leftFace->ya = 0; + leftFace->k = (double) (lw * dy) / 2.0; + rightFace->xa = -leftFace->xa; + rightFace->ya = 0; + rightFace->k = leftFace->k; + y = y1; + if (projectLeft) + y -= lw >> 1; + x = x1 - (lw >> 1); + dy = y2 - y; + if (projectRight) + dy += ((lw + 1) >> 1); + dx = lw; + FILL_RECT(infoRec->pScrn, x, y, dx, dy); + } else { + l = ((double) lw) / 2.0; + L = sqrt((double)(dx*dx + dy*dy)); + + if (dx < 0) { + right = &rights[1]; + left = &lefts[0]; + top = &rights[0]; + bottom = &lefts[1]; + } else { + right = &rights[0]; + left = &lefts[1]; + top = &lefts[0]; + bottom = &rights[1]; + } + r = l / L; + + /* coord of upper bound at integral y */ + ya = -r * dx; + xa = r * dy; + + projectXoff = -ya; + projectYoff = xa; + + /* xa * dy - ya * dx */ + k = l * L; + + leftFace->xa = xa; + leftFace->ya = ya; + leftFace->k = k; + rightFace->xa = -xa; + rightFace->ya = -ya; + rightFace->k = k; + + if (projectLeft) + righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, + k, dx, dy, x1, y1, 0, right); + else + righty = miPolyBuildEdge (xa, ya, + k, dx, dy, x1, y1, 0, right); + + /* coord of lower bound at integral y */ + ya = -ya; + xa = -xa; + + /* xa * dy - ya * dx */ + k = - k; + + if (projectLeft) + lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff, + k, dx, dy, x1, y1, 1, left); + else + lefty = miPolyBuildEdge (xa, ya, + k, dx, dy, x1, y1, 1, left); + + /* coord of top face at integral y */ + + if (signdx > 0) { + ya = -ya; + xa = -xa; + } + + if (projectLeft) { + double xap = xa - projectXoff; + double yap = ya - projectYoff; + topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, + -dy, dx, x1, y1, dx > 0, top); + } + else + topy = miPolyBuildEdge(xa, ya, 0.0, + -dy, dx, x1, y1, dx > 0, top); + + /* coord of bottom face at integral y */ + + if (projectRight) { + double xap = xa + projectXoff; + double yap = ya + projectYoff; + bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy, + -dy, dx, x2, y2, dx < 0, bottom); + maxy = -ya + projectYoff; + } else { + bottomy = miPolyBuildEdge (xa, ya, 0.0, + -dy, dx, x2, y2, dx < 0, bottom); + maxy = -ya; + } + + finaly = ICEIL (maxy) + y2; + + if (dx < 0) { + left->height = bottomy - lefty; + right->height = finaly - righty; + top->height = righty - topy; + } else { + right->height = bottomy - righty; + left->height = finaly - lefty; + top->height = lefty - topy; + } + bottom->height = finaly - bottomy; + XAAFillPolyHelper (pGC, topy, + bottom->height + bottomy - topy, lefts, rights, 2, 2); + } +} + + +static void +XAALineArcI (GCPtr pGC, int xorg, int yorg) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int x, y, e, ex; + int slw = pGC->lineWidth; + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + y = (slw >> 1) + 1; + if (slw & 1) + e = - ((y << 2) + 3); + else + e = - (y << 3); + ex = -4; + x = 0; + while (y) { + e += (y << 3) - 4; + while (e >= 0) { + x++; + e += (ex = -((x << 3) + 4)); + } + y--; + slw = (x << 1) + 1; + if ((e == ex) && (slw > 1)) + slw--; + + FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw); + + if ((y != 0) && ((slw > 1) || (e != ex))) { + FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw); + } + } +} + + +static void +XAALineArcD ( + GCPtr pGC, + double xorg, + double yorg, + PolyEdgePtr edge1, + int edgey1, + Bool edgeleft1, + PolyEdgePtr edge2, + int edgey2, + Bool edgeleft2 ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + double radius, x0, y0, el, er, yk, xlk, xrk, k; + int xbase, ybase, y, boty, xl, xr, xcl, xcr; + int ymin, ymax; + Bool edge1IsMin, edge2IsMin; + int ymin1, ymin2; + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + + + xbase = floor(xorg); + x0 = xorg - xbase; + ybase = ICEIL (yorg); + y0 = yorg - ybase; + + xlk = x0 + x0 + 1.0; + xrk = x0 + x0 - 1.0; + yk = y0 + y0 - 1.0; + radius = ((double)pGC->lineWidth) / 2.0; + y = floor(radius - y0 + 1.0); + ybase -= y; + ymin = ybase; + ymax = 65536; + edge1IsMin = FALSE; + ymin1 = edgey1; + if (edge1->dy >= 0) { + if (!edge1->dy) { + if (edgeleft1) + edge1IsMin = TRUE; + else + ymax = edgey1; + edgey1 = 65536; + } else if ((edge1->signdx < 0) == edgeleft1) + edge1IsMin = TRUE; + } + edge2IsMin = FALSE; + ymin2 = edgey2; + if (edge2->dy >= 0) { + if (!edge2->dy) { + if (edgeleft2) + edge2IsMin = TRUE; + else + ymax = edgey2; + edgey2 = 65536; + } else if ((edge2->signdx < 0) == edgeleft2) + edge2IsMin = TRUE; + } + if (edge1IsMin) { + ymin = ymin1; + if (edge2IsMin && (ymin1 > ymin2)) + ymin = ymin2; + } else if (edge2IsMin) + ymin = ymin2; + el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0); + er = el + xrk; + xl = 1; + xr = 0; + if (x0 < 0.5) { + xl = 0; + el -= xlk; + } + boty = (y0 < -0.5) ? 1 : 0; + if (ybase + y - boty > ymax) + boty = ymax - ybase - y; + while (y > boty) { + k = (y << 1) + yk; + er += k; + while (er > 0.0) { + xr++; + er += xrk - (xr << 1); + } + el += k; + while (el >= 0.0) { + xl--; + el += (xl << 1) - xlk; + } + y--; + ybase++; + if (ybase < ymin) + continue; + xcl = xl + xbase; + xcr = xr + xbase; + CLIPSTEPEDGE(edgey1, edge1, edgeleft1); + CLIPSTEPEDGE(edgey2, edge2, edgeleft2); + if(xcr >= xcl) { + FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); + } + } + er = xrk - (xr << 1) - er; + el = (xl << 1) - xlk - el; + boty = floor(-y0 - radius + 1.0); + if (ybase + y - boty > ymax) + boty = ymax - ybase - y; + while (y > boty) { + k = (y << 1) + yk; + er -= k; + while ((er >= 0.0) && (xr >= 0)) { + xr--; + er += xrk - (xr << 1); + } + el -= k; + while ((el > 0.0) && (xl <= 0)) { + xl++; + el += (xl << 1) - xlk; + } + y--; + ybase++; + if (ybase < ymin) + continue; + xcl = xl + xbase; + xcr = xr + xbase; + CLIPSTEPEDGE(edgey1, edge1, edgeleft1); + CLIPSTEPEDGE(edgey2, edge2, edgeleft2); + if(xcr >= xcl) { + FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1); + } + } +} + + +static void +XAALineArc ( + GCPtr pGC, + LineFacePtr leftFace, + LineFacePtr rightFace, + double xorg, + double yorg, + Bool isInt ) +{ + int xorgi, yorgi; + PolyEdgeRec edge1, edge2; + int edgey1, edgey2; + Bool edgeleft1, edgeleft2; + + if (isInt) { + xorgi = leftFace ? leftFace->x : rightFace->x; + yorgi = leftFace ? leftFace->y : rightFace->y; + } else { /* Muffle compiler */ + xorgi = yorgi = 0; + } + edgey1 = 65536; + edgey2 = 65536; + edge1.x = 0; /* not used, keep memory checkers happy */ + edge1.dy = -1; + edge2.x = 0; /* not used, keep memory checkers happy */ + edge2.dy = -1; + edgeleft1 = FALSE; + edgeleft2 = FALSE; + + if ((pGC->lineWidth > 2) && + ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) || + (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) { + if (isInt) { + xorg = (double) xorgi; + yorg = (double) yorgi; + } + + if (leftFace && rightFace) + miRoundJoinClip (leftFace, rightFace, &edge1, &edge2, + &edgey1, &edgey2, &edgeleft1, &edgeleft2); + else if (leftFace) + edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1); + else if (rightFace) + edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2); + + isInt = FALSE; + } + + if (isInt) { + if(pGC->lineWidth == 1) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + DRAW_POINT(infoRec->pScrn, xorgi, yorgi); + } else + XAALineArcI(pGC, xorgi, yorgi); + } else + XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1, + &edge2, edgey2, edgeleft2); + +} + + +static void +XAALineJoin ( + GCPtr pGC, + LineFacePtr pLeft, + LineFacePtr pRight ) +{ + double mx = 0, my = 0; + double denom = 0; + PolyVertexRec vertices[4]; + PolySlopeRec slopes[4]; + int edgecount; + PolyEdgeRec left[4], right[4]; + int nleft, nright; + int y, height; + int swapslopes; + int joinStyle = pGC->joinStyle; + int lw = pGC->lineWidth; + + if (lw == 1) { + /* Lines going in the same direction have no join */ + if ((pLeft->dx >= 0) == (pRight->dx <= 0)) + return; + if (joinStyle != JoinRound) { + denom = - pLeft->dx * (double)pRight->dy + pRight->dx * + (double)pLeft->dy; + if (denom == 0.0) + return; /* no join to draw */ + } + if (joinStyle != JoinMiter) { + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL); + DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y); + return; + } + } else { + if (joinStyle == JoinRound) { + XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE); + return; + } + denom = - pLeft->dx * (double)pRight->dy + pRight->dx * + (double)pLeft->dy; + if (denom == 0.0) + return; /* no join to draw */ + } + + swapslopes = 0; + if (denom > 0) { + pLeft->xa = -pLeft->xa; + pLeft->ya = -pLeft->ya; + pLeft->dx = -pLeft->dx; + pLeft->dy = -pLeft->dy; + } else { + swapslopes = 1; + pRight->xa = -pRight->xa; + pRight->ya = -pRight->ya; + pRight->dx = -pRight->dx; + pRight->dy = -pRight->dy; + } + + vertices[0].x = pRight->xa; + vertices[0].y = pRight->ya; + slopes[0].dx = -pRight->dy; + slopes[0].dy = pRight->dx; + slopes[0].k = 0; + + vertices[1].x = 0; + vertices[1].y = 0; + slopes[1].dx = pLeft->dy; + slopes[1].dy = -pLeft->dx; + slopes[1].k = 0; + + vertices[2].x = pLeft->xa; + vertices[2].y = pLeft->ya; + + if (joinStyle == JoinMiter) { + my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) - + pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/ + denom; + if (pLeft->dy != 0) + mx = pLeft->xa + (my - pLeft->ya) * + (double) pLeft->dx / (double) pLeft->dy; + else + mx = pRight->xa + (my - pRight->ya) * + (double) pRight->dx / (double) pRight->dy; + + /* check miter limit */ + if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw) + joinStyle = JoinBevel; + } + + if (joinStyle == JoinMiter) { + slopes[2].dx = pLeft->dx; + slopes[2].dy = pLeft->dy; + slopes[2].k = pLeft->k; + if (swapslopes) { + slopes[2].dx = -slopes[2].dx; + slopes[2].dy = -slopes[2].dy; + slopes[2].k = -slopes[2].k; + } + vertices[3].x = mx; + vertices[3].y = my; + slopes[3].dx = pRight->dx; + slopes[3].dy = pRight->dy; + slopes[3].k = pRight->k; + if (swapslopes) { + slopes[3].dx = -slopes[3].dx; + slopes[3].dy = -slopes[3].dy; + slopes[3].k = -slopes[3].k; + } + edgecount = 4; + } else { + double scale, dx, dy, adx, ady; + + adx = dx = pRight->xa - pLeft->xa; + ady = dy = pRight->ya - pLeft->ya; + if (adx < 0) + adx = -adx; + if (ady < 0) + ady = -ady; + scale = ady; + if (adx > ady) + scale = adx; + slopes[2].dx = (dx * 65536) / scale; + slopes[2].dy = (dy * 65536) / scale; + slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy - + (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0; + edgecount = 3; + } + + y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y, + left, right, &nleft, &nright, &height); + XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright); +} + + +void +XAAPolylinesWideSolid ( + DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr pPts ) +{ + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); + int x1, y1, x2, y2; + Bool projectLeft, projectRight; + LineFaceRec leftFace, rightFace, prevRightFace, firstFace; + int first = TRUE; + Bool somethingDrawn = FALSE; + Bool selfJoin = FALSE; + int xorg = pDrawable->x; + int yorg = pDrawable->y; + Bool hardClip = FALSE; + + if(!RegionNumRects(pGC->pCompositeClip)) + return; + + if(RegionNumRects(pGC->pCompositeClip) != 1) { + miWideLine(pDrawable, pGC, mode, npt, pPts); + return; + } + + x2 = pPts->x; + y2 = pPts->y; + if (npt > 1) { + if (mode == CoordModePrevious) { + int nptTmp; + register DDXPointPtr pPtsTmp; + + x1 = x2; + y1 = y2; + nptTmp = npt; + pPtsTmp = pPts + 1; + while (--nptTmp) { + x1 += pPtsTmp->x; + y1 += pPtsTmp->y; + ++pPtsTmp; + } + if ((x2 == x1) && (y2 == y1)) + selfJoin = TRUE; + } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y)) + selfJoin = TRUE; + } + + projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin); + projectRight = FALSE; + + (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu, + pGC->planemask); + + infoRec->ClipBox = &pGC->pCompositeClip->extents; + + if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) { + hardClip = TRUE; + (*infoRec->SetClippingRectangle)(infoRec->pScrn, + infoRec->ClipBox->x1, infoRec->ClipBox->y1, + infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1); + } + + x2 += xorg; + y2 += yorg; + while (--npt) { + x1 = x2; + y1 = y2; + ++pPts; + x2 = pPts->x; + y2 = pPts->y; + if (mode == CoordModePrevious) { + x2 += x1; + y2 += y1; + } else { + x2 += xorg; + y2 += yorg; + } + if ((x1 != x2) || (y1 != y2)) { + somethingDrawn = TRUE; + if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin) + projectRight = TRUE; + XAAWideSegment(pGC, x1, y1, x2, y2, + projectLeft, projectRight, &leftFace, &rightFace); + if (first) { + if (selfJoin) + firstFace = leftFace; + else if (pGC->capStyle == CapRound) { + if (pGC->lineWidth == 1) { + DRAW_POINT(infoRec->pScrn, x1, y1); + } else + XAALineArc(pGC,&leftFace, (LineFacePtr) NULL, + (double)0.0, (double)0.0,TRUE); + } + } else + XAALineJoin (pGC, &leftFace, &prevRightFace); + + prevRightFace = rightFace; + first = FALSE; + projectLeft = FALSE; + } + if (npt == 1 && somethingDrawn) { + if (selfJoin) + XAALineJoin (pGC, &firstFace, &rightFace); + else if (pGC->capStyle == CapRound) { + if (pGC->lineWidth == 1) { + DRAW_POINT(infoRec->pScrn, x2, y2); + } else + XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, + (double)0.0, (double)0.0,TRUE); + } + } + } + /* handle crock where all points are coincedent */ + if (!somethingDrawn) { + projectLeft = (pGC->capStyle == CapProjecting); + XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft, + &leftFace, &rightFace); + if (pGC->capStyle == CapRound) { + XAALineArc (pGC, &leftFace, (LineFacePtr) NULL, + (double)0.0, (double)0.0, TRUE); + rightFace.dx = -1; /* sleezy hack to make it work */ + XAALineArc (pGC, (LineFacePtr) NULL, &rightFace, + (double)0.0, (double)0.0, TRUE); + } + } + + infoRec->ClipBox = NULL; + if(hardClip) + (*infoRec->DisableClipping)(infoRec->pScrn); + + SET_SYNC_FLAG(infoRec); +} diff --git a/xorg-server/hw/xfree86/xaa/xaaWrapper.c b/xorg-server/hw/xfree86/xaa/xaaWrapper.c index f709d0b35..09644c9ac 100644 --- a/xorg-server/hw/xfree86/xaa/xaaWrapper.c +++ b/xorg-server/hw/xfree86/xaa/xaaWrapper.c @@ -125,10 +125,10 @@ typedef struct _xaaWrapperGCPriv { #define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC) -static int xaaWrapperScrPrivateKeyIndex; -static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKeyIndex; -static int xaaWrapperGCPrivateKeyIndex; -static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKeyIndex; +static DevPrivateKeyRec xaaWrapperScrPrivateKeyRec; +#define xaaWrapperScrPrivateKey (&xaaWrapperScrPrivateKeyRec) +static DevPrivateKeyRec xaaWrapperGCPrivateKeyRec; +#define xaaWrapperGCPrivateKey (&xaaWrapperGCPrivateKeyRec) static Bool xaaWrapperCreateScreenResources(ScreenPtr pScreen) @@ -268,7 +268,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f xaaWrapperScrPrivPtr pScrPriv; PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); - if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec))) + if (!dixRegisterPrivateKey(&xaaWrapperGCPrivateKeyRec, PRIVATE_GC, sizeof(xaaWrapperGCPrivRec))) + return FALSE; + + if (!dixRegisterPrivateKey(&xaaWrapperScrPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; pScrPriv = (xaaWrapperScrPrivPtr) malloc(sizeof (xaaWrapperScrPrivRec)); diff --git a/xorg-server/hw/xfree86/xaa/xaawrap.h b/xorg-server/hw/xfree86/xaa/xaawrap.h index 86ba003d6..1b7595e95 100644 --- a/xorg-server/hw/xfree86/xaa/xaawrap.h +++ b/xorg-server/hw/xfree86/xaa/xaawrap.h @@ -1,79 +1,79 @@ - -#define XAA_SCREEN_PROLOGUE(pScreen, field)\ - ((pScreen)->field = \ - ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) - -#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ - ((pScreen)->field = wrapper) - - -#define XAA_GC_FUNC_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - (pGC)->funcs = pGCPriv->wrapFuncs;\ - if(pGCPriv->flags)\ - (pGC)->ops = pGCPriv->wrapOps - -#define XAA_GC_FUNC_EPILOGUE(pGC)\ - pGCPriv->wrapFuncs = (pGC)->funcs;\ - (pGC)->funcs = &XAAGCFuncs;\ - if(pGCPriv->flags) {\ - pGCPriv->wrapOps = (pGC)->ops;\ - (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\ - &XAAPixmapOps;\ - } - - -#define XAA_GC_OP_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - GCFuncs *oldFuncs = pGC->funcs;\ - pGC->funcs = pGCPriv->wrapFuncs;\ - pGC->ops = pGCPriv->wrapOps - -#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - GCFuncs *oldFuncs = pGC->funcs;\ - if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \ - pGC->funcs = pGCPriv->wrapFuncs;\ - pGC->ops = pGCPriv->wrapOps - - -#define XAA_GC_OP_EPILOGUE(pGC)\ - pGCPriv->wrapOps = pGC->ops;\ - pGC->funcs = oldFuncs;\ - pGC->ops = pGCPriv->XAAOps - - -#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ - XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ - XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ - GCFuncs *oldFuncs = pGC->funcs;\ - pGC->funcs = pGCPriv->wrapFuncs;\ - pGC->ops = pGCPriv->wrapOps; \ - SYNC_CHECK(pGC) - -#define XAA_PIXMAP_OP_EPILOGUE(pGC)\ - pGCPriv->wrapOps = pGC->ops;\ - pGC->funcs = oldFuncs;\ - pGC->ops = &XAAPixmapOps;\ - pixPriv->flags |= DIRTY - -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#define XAA_RENDER_PROLOGUE(pScreen,field)\ - (GetPictureScreen(pScreen)->field = \ - ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) - -#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ - (GetPictureScreen(pScreen)->field = wrapper) - -/* This also works fine for drawables */ - -#define SYNC_CHECK(pGC) {\ - XAAInfoRecPtr infoRec =\ -((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \ - if(infoRec->NeedToSync) {\ - (*infoRec->Sync)(infoRec->pScrn);\ - infoRec->NeedToSync = FALSE;\ - }} + +#define XAA_SCREEN_PROLOGUE(pScreen, field)\ + ((pScreen)->field = \ + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) + +#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ + ((pScreen)->field = wrapper) + + +#define XAA_GC_FUNC_PROLOGUE(pGC)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + (pGC)->funcs = pGCPriv->wrapFuncs;\ + if(pGCPriv->flags)\ + (pGC)->ops = pGCPriv->wrapOps + +#define XAA_GC_FUNC_EPILOGUE(pGC)\ + pGCPriv->wrapFuncs = (pGC)->funcs;\ + (pGC)->funcs = &XAAGCFuncs;\ + if(pGCPriv->flags) {\ + pGCPriv->wrapOps = (pGC)->ops;\ + (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\ + &XAAPixmapOps;\ + } + + +#define XAA_GC_OP_PROLOGUE(pGC)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + GCFuncs *oldFuncs = pGC->funcs;\ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + +#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + GCFuncs *oldFuncs = pGC->funcs;\ + if(!RegionNumRects(pGC->pCompositeClip)) return; \ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps + + +#define XAA_GC_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = pGC->ops;\ + pGC->funcs = oldFuncs;\ + pGC->ops = pGCPriv->XAAOps + + +#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \ + XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ + GCFuncs *oldFuncs = pGC->funcs;\ + pGC->funcs = pGCPriv->wrapFuncs;\ + pGC->ops = pGCPriv->wrapOps; \ + SYNC_CHECK(pGC) + +#define XAA_PIXMAP_OP_EPILOGUE(pGC)\ + pGCPriv->wrapOps = pGC->ops;\ + pGC->funcs = oldFuncs;\ + pGC->ops = &XAAPixmapOps;\ + pixPriv->flags |= DIRTY + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#define XAA_RENDER_PROLOGUE(pScreen,field)\ + (GetPictureScreen(pScreen)->field = \ + ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field) + +#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ + (GetPictureScreen(pScreen)->field = wrapper) + +/* This also works fine for drawables */ + +#define SYNC_CHECK(pGC) {\ + XAAInfoRecPtr infoRec =\ +((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \ + if(infoRec->NeedToSync) {\ + (*infoRec->Sync)(infoRec->pScrn);\ + infoRec->NeedToSync = FALSE;\ + }} -- cgit v1.2.3