diff options
Diffstat (limited to 'cfb/cfbtileodd.c')
-rw-r--r-- | cfb/cfbtileodd.c | 255 |
1 files changed, 193 insertions, 62 deletions
diff --git a/cfb/cfbtileodd.c b/cfb/cfbtileodd.c index 2307f6b55..85efd614e 100644 --- a/cfb/cfbtileodd.c +++ b/cfb/cfbtileodd.c @@ -2,6 +2,7 @@ * Fill odd tiled rectangles and spans. * no depth dependencies. */ +/* $XFree86: xc/programs/Xserver/cfb/cfbtileodd.c,v 3.6 2001/12/14 19:59:25 dawes Exp $ */ /* @@ -45,11 +46,11 @@ in this Software without prior written authorization from The Open Group. #include "mergerop.h" -#if PGSZ == 32 +#if PSZ == 24 +#define LEFTSHIFT_AMT (3) +#else /* PSZ != 24 */ #define LEFTSHIFT_AMT (5 - PWSH) -#else /* PGSZ == 64 */ -#define LEFTSHIFT_AMT (6 - PWSH) -#endif /* PGSZ */ +#endif /* PSZ == 24*/ #define LastTileBits {\ tmp = bits; \ @@ -59,6 +60,23 @@ in this Software without prior written authorization from The Open Group. bits = *pSrc; \ } +#if PSZ == 24 +#define ResetTileBits {\ + pSrc = pSrcLine; \ + nlwSrc = widthSrc;\ + if (tileEndPart) { \ + if (4 - xoff + tileEndPart <= 4) {\ + bits = *pSrc++; \ + nlwSrc--; \ + } else \ + bits = BitLeft(tmp, tileEndLeftShift) | \ + BitRight(bits, tileEndRightShift); \ + xoff = (xoff + xoffStep) & 3; \ + leftShift = xoff << LEFTSHIFT_AMT; \ + rightShift = PGSZ - leftShift; \ + }\ +} +#else #define ResetTileBits {\ pSrc = pSrcLine; \ nlwSrc = widthSrc;\ @@ -74,6 +92,7 @@ in this Software without prior written authorization from The Open Group. rightShift = PGSZ - leftShift; \ }\ } +#endif #define NextTileBits {\ if (nlwSrc == 1) {\ @@ -109,8 +128,8 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan int widthDst; /* width in longwords of the dest pixmap */ int w; /* width of current box */ int h; /* height of current box */ - unsigned long startmask; - unsigned long endmask;/* masks for reggedy bits at either end of line */ + CfbBits startmask; + CfbBits endmask;/* masks for reggedy bits at either end of line */ int nlwMiddle; /* number of longwords between sides of boxes */ int nlwSrc; /* number of whole longwords in source */ @@ -122,24 +141,23 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan MROP_DECLARE_REG() - unsigned long *pDstBase; /* pointer to start of dest */ - unsigned long *pDstLine; /* poitner to start of dest box */ - unsigned long *pSrcBase; /* pointer to start of source */ - unsigned long *pSrcLine; /* pointer to start of source line */ - register unsigned long *pDst; - register unsigned long *pSrc; - register unsigned long bits, tmp; - register int nlwPart; + CfbBits *pdstBase; /* pointer to start of dest */ + CfbBits *pDstLine; /* poitner to start of dest box */ + CfbBits *pSrcBase; /* pointer to start of source */ + CfbBits *pSrcLine; /* pointer to start of source line */ + register CfbBits *pDst; + register CfbBits *pSrc; + register CfbBits bits, tmp = 0; int xoffStart, xoff; int leftShiftStart, rightShiftStart, nlwSrcStart; - unsigned long tileEndMask; + CfbBits tileEndMask; int tileEndLeftShift, tileEndRightShift; int xoffStep; int tileEndPart; int needFirst; - unsigned long narrow[2]; - unsigned long narrowMask; - int narrowShift; + CfbBits narrow[2]; + CfbBits narrowMask = 0; + int narrowShift = 0; Bool narrowTile; MROP_INITIALIZE (alu, planemask) @@ -156,15 +174,24 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan widthSrc = 2; narrowTile = TRUE; } - pSrcBase = (unsigned long *)tile->devPrivate.ptr; + pSrcBase = (CfbBits *)tile->devPrivate.ptr; - cfbGetLongWidthAndPointer (pDrawable, widthDst, pDstBase) + cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase) +#if PSZ == 24 + tileEndPart = (4 - tileWidth) & 3; + tileEndMask = cfbendpartial[tileWidth & 3]; +#else tileEndPart = tileWidth & PIM; tileEndMask = cfbendpartial[tileEndPart]; +#endif /* PSZ == 24 */ tileEndLeftShift = (tileEndPart) << LEFTSHIFT_AMT; tileEndRightShift = PGSZ - tileEndLeftShift; +#if PSZ == 24 + xoffStep = 4 - tileEndPart; +#else xoffStep = PPW - tileEndPart; +#endif /* PSZ == 24 */ /* * current assumptions: tile > 32 bits wide. */ @@ -174,8 +201,13 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan h = pBox->y2 - pBox->y1; modulus (pBox->x1 - xrot, tileWidth, srcx); modulus (pBox->y1 - yrot, tileHeight, srcy); +#if PSZ == 24 + xoffDst = (4 - pBox->x1) & 3; + if (w == 1 && (xoffDst == 0 || xoffDst == 1)) +#else xoffDst = pBox->x1 & PIM; if (xoffDst + w < PPW) +#endif { maskpartialbits(pBox->x1, w, startmask); endmask = 0; @@ -185,9 +217,17 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan { maskbits (pBox->x1, w, startmask, endmask, nlwMiddle) } - pDstLine = pDstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH); +#if PSZ == 24 + pDstLine = pdstBase + (pBox->y1 * widthDst) + ((pBox->x1*3) >> 2); +#else + pDstLine = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH); +#endif pSrcLine = pSrcBase + (srcy * widthSrc); +#if PSZ == 24 + xoffSrc = (4 - srcx) & 3; +#else xoffSrc = srcx & PIM; +#endif if (xoffSrc >= xoffDst) { xoffStart = xoffSrc - xoffDst; @@ -195,12 +235,20 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan } else { +#if PSZ == 24 + xoffStart = 4 - (xoffDst - xoffSrc); +#else xoffStart = PPW - (xoffDst - xoffSrc); +#endif needFirst = 0; } leftShiftStart = (xoffStart) << LEFTSHIFT_AMT; rightShiftStart = PGSZ - leftShiftStart; +#if PSZ == 24 + nlwSrcStart = widthSrc - ((srcx*3) >> 2); +#else nlwSrcStart = widthSrc - (srcx >> PWSH); +#endif while (h--) { /* XXX only works when narrowShift >= PPW/2 */ @@ -208,15 +256,24 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan { tmp = pSrcBase[srcy] & narrowMask; /* source width == 1 */ narrow[0] = tmp | SCRRIGHT (tmp, narrowShift); +#if PSZ == 24 + narrow[1] = BitLeft (tmp, 8) | + BitRight(tmp, 16); +#else narrow[1] = SCRLEFT (tmp, PPW - narrowShift) | SCRRIGHT(tmp, 2 * narrowShift - PPW); +#endif pSrcLine = narrow; } xoff = xoffStart; leftShift = leftShiftStart; rightShift = rightShiftStart; nlwSrc = nlwSrcStart; +#if PSZ == 24 + pSrc = pSrcLine + ((srcx * 3) >> 2); +#else pSrc = pSrcLine + (srcx >> PWSH); +#endif pDst = pDstLine; bits = 0; if (needFirst) @@ -238,7 +295,8 @@ MROP_NAME(cfbFillBoxTileOdd) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan #if MROP == Mcopy if (nlwSrc > 1) { - nlwPart = nlw; + int nlwPart = nlw; + if (nlwPart >= nlwSrc) nlwPart = nlwSrc - 1; nlw -= nlwPart; @@ -327,8 +385,8 @@ MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, int widthDst; /* width in longwords of the dest pixmap */ int w; /* width of current span */ - unsigned long startmask; - unsigned long endmask; /* masks for reggedy bits at either end of line */ + CfbBits startmask; + CfbBits endmask; /* masks for reggedy bits at either end of line */ int nlwSrc; /* number of whole longwords in source */ register int nlw; /* loop version of nlwMiddle */ @@ -339,24 +397,23 @@ MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, MROP_DECLARE_REG() - unsigned long *pDstBase; /* pointer to start of dest */ - unsigned long *pDstLine; /* poitner to start of dest box */ - unsigned long *pSrcBase; /* pointer to start of source */ - unsigned long *pSrcLine; /* pointer to start of source line */ - register unsigned long *pDst; - register unsigned long *pSrc; - register unsigned long bits, tmp; - register int nlwPart; + CfbBits *pdstBase; /* pointer to start of dest */ + CfbBits *pDstLine; /* poitner to start of dest box */ + CfbBits *pSrcBase; /* pointer to start of source */ + CfbBits *pSrcLine; /* pointer to start of source line */ + register CfbBits *pDst; + register CfbBits *pSrc; + register CfbBits bits, tmp = 0; int xoffStart, xoff; int leftShiftStart, rightShiftStart, nlwSrcStart; - unsigned long tileEndMask; + CfbBits tileEndMask; int tileEndLeftShift, tileEndRightShift; int xoffStep; int tileEndPart; int needFirst; - unsigned long narrow[2]; - unsigned long narrowMask; - int narrowShift; + CfbBits narrow[2]; + CfbBits narrowMask = 0; + int narrowShift = 0; Bool narrowTile; MROP_INITIALIZE (alu, planemask) @@ -373,22 +430,36 @@ MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, widthSrc = 2; narrowTile = TRUE; } - pSrcBase = (unsigned long *)tile->devPrivate.ptr; + pSrcBase = (CfbBits *)tile->devPrivate.ptr; - cfbGetLongWidthAndPointer (pDrawable, widthDst, pDstBase) + cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase) +#if PSZ == 24 + tileEndPart = (4 - tileWidth) & 3; + tileEndMask = cfbendpartial[tileWidth & 3]; +#else tileEndPart = tileWidth & PIM; tileEndMask = cfbendpartial[tileEndPart]; +#endif tileEndLeftShift = (tileEndPart) << LEFTSHIFT_AMT; tileEndRightShift = PGSZ - tileEndLeftShift; +#if PSZ == 24 + xoffStep = 4 - tileEndPart; +#else xoffStep = PPW - tileEndPart; +#endif while (n--) { w = *pwidth++; modulus (ppt->x - xrot, tileWidth, srcx); modulus (ppt->y - yrot, tileHeight, srcy); +#if PSZ == 24 + xoffDst = (4 - ppt->x) & 3; + if (w == 1 && (xoffDst == 0 || xoffDst == 1)) +#else xoffDst = ppt->x & PIM; if (xoffDst + w < PPW) +#endif { maskpartialbits(ppt->x, w, startmask); endmask = 0; @@ -398,9 +469,17 @@ MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, { maskbits (ppt->x, w, startmask, endmask, nlw) } - pDstLine = pDstBase + (ppt->y * widthDst) + (ppt->x >> PWSH); +#if PSZ == 24 + pDstLine = pdstBase + (ppt->y * widthDst) + ((ppt->x *3)>> 2); +#else + pDstLine = pdstBase + (ppt->y * widthDst) + (ppt->x >> PWSH); +#endif pSrcLine = pSrcBase + (srcy * widthSrc); +#if PSZ == 24 + xoffSrc = (4 - srcx) & 3; +#else xoffSrc = srcx & PIM; +#endif if (xoffSrc >= xoffDst) { xoffStart = xoffSrc - xoffDst; @@ -408,26 +487,43 @@ MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, } else { +#if PSZ == 24 + xoffStart = 4 - (xoffDst - xoffSrc); +#else xoffStart = PPW - (xoffDst - xoffSrc); +#endif needFirst = 0; } leftShiftStart = (xoffStart) << LEFTSHIFT_AMT; rightShiftStart = PGSZ - leftShiftStart; +#if PSZ == 24 + nlwSrcStart = widthSrc - ((srcx*3) >> 2); +#else nlwSrcStart = widthSrc - (srcx >> PWSH); +#endif /* XXX only works when narrowShift >= PPW/2 */ if (narrowTile) { tmp = pSrcBase[srcy] & narrowMask; /* source width == 1 */ narrow[0] = tmp | SCRRIGHT (tmp, narrowShift); +#if PSZ == 24 + narrow[1] = BitLeft (tmp, 8) | + BitRight(tmp, 16); +#else narrow[1] = SCRLEFT (tmp, PPW - narrowShift) | SCRRIGHT(tmp, 2 * narrowShift - PPW); +#endif pSrcLine = narrow; } xoff = xoffStart; leftShift = leftShiftStart; rightShift = rightShiftStart; nlwSrc = nlwSrcStart; +#if PSZ == 24 + pSrc = pSrcLine + ((srcx * 3) >> 2); +#else pSrc = pSrcLine + (srcx >> PWSH); +#endif pDst = pDstLine; bits = 0; if (needFirst) @@ -448,7 +544,8 @@ MROP_NAME(cfbFillSpanTileOdd) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, #if MROP == Mcopy if (nlwSrc > 1) { - nlwPart = nlw; + int nlwPart = nlw; + if (nlwPart >= nlwSrc) nlwPart = nlwSrc - 1; nlw -= nlwPart; @@ -534,8 +631,8 @@ MROP_NAME(cfbFillBoxTile32s) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan int widthDst; /* width in longwords of the dest pixmap */ int w; /* width of current box */ int h; /* height of current box */ - unsigned long startmask; - unsigned long endmask;/* masks for reggedy bits at either end of line */ + CfbBits startmask; + CfbBits endmask;/* masks for reggedy bits at either end of line */ int nlMiddle; /* number of longwords between sides of boxes */ register int nl; /* loop version of nlMiddle */ @@ -548,22 +645,26 @@ MROP_NAME(cfbFillBoxTile32s) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan MROP_DECLARE_REG() - unsigned long *pdstBase; /* pointer to start of dest */ - unsigned long *pdstLine; /* poitner to start of dest box */ - unsigned long *psrcBase; /* pointer to start of source */ - unsigned long *psrcLine; /* pointer to fetch point of source */ - unsigned long *psrcStart; /* pointer to start of source line */ - register unsigned long *pdst; - register unsigned long *psrc; - register unsigned long bits, bits1; + CfbBits *pdstBase; /* pointer to start of dest */ + CfbBits *pdstLine; /* poitner to start of dest box */ + CfbBits *psrcBase; /* pointer to start of source */ + CfbBits *psrcLine; /* pointer to fetch point of source */ + CfbBits *psrcStart; /* pointer to start of source line */ + register CfbBits *pdst; + register CfbBits *psrc; + register CfbBits bits, bits1; register int nlTemp; MROP_INITIALIZE (alu, planemask) - psrcBase = (unsigned long *)tile->devPrivate.ptr; + psrcBase = (CfbBits *)tile->devPrivate.ptr; tileHeight = tile->drawable.height; tileWidth = tile->drawable.width; +#if PSZ == 24 + widthSrc = tile->devKind / PGSZB; +#else widthSrc = tileWidth >> PWSH; +#endif cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase) @@ -575,16 +676,30 @@ MROP_NAME(cfbFillBoxTile32s) (pDrawable, nBox, pBox, tile, xrot, yrot, alu, plan /* set up source */ modulus (pBox->x1 - xrot, tileWidth, srcx); modulus (pBox->y1 - yrot, tileHeight, srcy); +#if PSZ == 24 + xoffSrc = (4 - srcx) & 3; + srcStart = (srcx * 3) >> 2; +#else xoffSrc = srcx & PIM; srcStart = (srcx >> PWSH); +#endif psrcStart = psrcBase + (srcy * widthSrc); psrcLine = psrcStart + srcStart; /* set up dest */ +#if PSZ == 24 + xoffDst = (4 - pBox->x1) & 3; + pdstLine = pdstBase + (pBox->y1 * widthDst) + ((pBox->x1*3) >> 2); +#else xoffDst = pBox->x1 & PIM; pdstLine = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH); +#endif /* set up masks */ +#if PSZ == 24 + if (w == 1 && (xoffDst == 0 || xoffDst == 1)) +#else if (xoffDst + w < PPW) +#endif { maskpartialbits(pBox->x1, w, startmask); endmask = 0; @@ -827,8 +942,8 @@ MROP_NAME(cfbFillSpanTile32s) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, int widthDst; /* width in longwords of the dest pixmap */ int w; /* width of current box */ - unsigned long startmask; - unsigned long endmask;/* masks for reggedy bits at either end of line */ + CfbBits startmask; + CfbBits endmask;/* masks for reggedy bits at either end of line */ int nlMiddle; /* number of longwords between sides of boxes */ register int nl; /* loop version of nlMiddle */ @@ -841,22 +956,26 @@ MROP_NAME(cfbFillSpanTile32s) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, MROP_DECLARE_REG() - unsigned long *pdstBase; /* pointer to start of dest */ - unsigned long *pdstLine; /* poitner to start of dest box */ - unsigned long *psrcBase; /* pointer to start of source */ - unsigned long *psrcLine; /* pointer to fetch point of source */ - unsigned long *psrcStart; /* pointer to start of source line */ - register unsigned long *pdst; - register unsigned long *psrc; - register unsigned long bits, bits1; + CfbBits *pdstBase; /* pointer to start of dest */ + CfbBits *pdstLine; /* poitner to start of dest box */ + CfbBits *psrcBase; /* pointer to start of source */ + CfbBits *psrcLine; /* pointer to fetch point of source */ + CfbBits *psrcStart; /* pointer to start of source line */ + register CfbBits *pdst; + register CfbBits *psrc; + register CfbBits bits, bits1; register int nlTemp; MROP_INITIALIZE (alu, planemask) - psrcBase = (unsigned long *)tile->devPrivate.ptr; + psrcBase = (CfbBits *)tile->devPrivate.ptr; tileHeight = tile->drawable.height; tileWidth = tile->drawable.width; +#if PSZ == 24 + widthSrc = tile->devKind / PGSZB; +#else widthSrc = tileWidth >> PWSH; +#endif cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase) @@ -867,16 +986,28 @@ MROP_NAME(cfbFillSpanTile32s) (pDrawable, n, ppt, pwidth, tile, xrot, yrot, alu, /* set up source */ modulus (ppt->x - xrot, tileWidth, srcx); modulus (ppt->y - yrot, tileHeight, srcy); +#if PSZ == 24 + xoffSrc = (4 - srcx) & 3; + srcStart = (srcx * 3) >> 2; +#else xoffSrc = srcx & PIM; srcStart = (srcx >> PWSH); +#endif psrcStart = psrcBase + (srcy * widthSrc); psrcLine = psrcStart + srcStart; /* set up dest */ +#if PSZ == 24 + xoffDst = (4 - ppt->x) & 3; + pdstLine = pdstBase + (ppt->y * widthDst) + ((ppt->x *3) >> 2); + /* set up masks */ + if (w == 1 && (xoffDst == 0 || xoffDst == 1)) +#else xoffDst = ppt->x & PIM; pdstLine = pdstBase + (ppt->y * widthDst) + (ppt->x >> PWSH); /* set up masks */ if (xoffDst + w < PPW) +#endif { maskpartialbits(ppt->x, w, startmask); endmask = 0; |