if (pptSrc->x < pbox->x1)
if (pptSrc->x <= pbox->x1)
pxDoBitblt(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int alu,	   RegionPtr prgnDst, DDXPointPtr pptSrc, unsigned long pmask,	   unsigned long bitplane){	BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;	DDXPointPtr pptTmp, pptNew1, pptNew2;	pxScreenPrivPtr sp;	int w, h, ydir, nbox, src, dst, umet, yStrideSrc, srcDir, careful;	int xStrideSrc;	u_int8_t *psrc, *psrcBase;	u_int32_t *pb;	PixmapPtr pPix;	pxPacket pxp;	PX_TRACE("pxDoBitblt");	sp = pSrcDrawable->pScreen->devPrivates[pxScreenPrivateIndex].ptr;	pmask &= 0x00ffffff;	pbox = REGION_RECTS(prgnDst);	nbox = REGION_NUM_RECTS(prgnDst);	pboxNew1 = NULL;	pptNew1 = NULL;	pboxNew2 = NULL;	pptNew2 = NULL;	careful = (pSrcDrawable == pDstDrawable ||	    (pSrcDrawable->type == DRAWABLE_WINDOW &&	    pDstDrawable->type == DRAWABLE_WINDOW));	if (careful && pptSrc->y < pbox->y1) {		/*		 * Walk source bottom to top.		 */		ydir = -1;		if (nbox > 1) {			/*			 * Keep ordering in each band, reverse order of			 * bands.			 */			pboxNew1 = (BoxPtr)			    ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);			if (!pboxNew1)				return;			pptNew1 = (DDXPointPtr)			    ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);			if (!pptNew1) {				DEALLOCATE_LOCAL(pboxNew1);				return;			}			pboxBase = pboxNext = pbox + nbox - 1;			while (pboxBase >= pbox) {				while (pboxNext >= pbox &&				   pboxBase->y1 == pboxNext->y1)					pboxNext--;				pboxTmp = pboxNext + 1;				pptTmp = pptSrc + (pboxTmp - pbox);				while (pboxTmp <= pboxBase) {					*pboxNew1++ = *pboxTmp++;					*pptNew1++ = *pptTmp++;				}				pboxBase = pboxNext;			}			pboxNew1 -= nbox;			pbox = pboxNew1;			pptNew1 -= nbox;			pptSrc = pptNew1;		}	} else {		/*		 * Walk source top to bottom.		 */		ydir = 1;	}	if (careful && pptSrc->x < pbox->x1) {		/*		 * Walk source right to left.		 */		if (nbox > 1) {			/*			 * Reverse order of rects in each band.			 */			pboxNew2 =			    (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);			pptNew2 =			    (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);			if (!pboxNew2 || !pptNew2) {				if (pptNew2)					DEALLOCATE_LOCAL(pptNew2);				if (pboxNew2)					DEALLOCATE_LOCAL(pboxNew2);				if (pboxNew1) {					DEALLOCATE_LOCAL(pptNew1);					DEALLOCATE_LOCAL(pboxNew1);				}				return;			}			pboxBase = pboxNext = pbox;			while (pboxBase < pbox+nbox) {				while ((pboxNext < pbox+nbox) &&				   (pboxNext->y1 == pboxBase->y1))				pboxNext++;				pboxTmp = pboxNext;				pptTmp = pptSrc + (pboxTmp - pbox);				while (pboxTmp != pboxBase) {					*pboxNew2++ = *--pboxTmp;					*pptNew2++ = *--pptTmp;				}				pboxBase = pboxNext;			}			pboxNew2 -= nbox;			pbox = pboxNew2;			pptNew2 -= nbox;			pptSrc = pptNew2;		}	}	if (pSrcDrawable->type == DRAWABLE_WINDOW) {		umet = pxRopTable[alu] | STAMP_SPAN;		ydir *= 8;		/*		 * The stamp goes bananas if you mix span widths, or don't		 * properly specify COPYSPAN_ALIGNED.  I'm not sure which it		 * is, but to make it happy we emit a seperate packet for		 * each box.		 */		while (nbox--) {			pb = pxPacketStart(sp, &pxp, 5, 3);			pb[0] = STAMP_CMD_COPYSPANS | STAMP_LW_PERPACKET;			pb[1] = pmask;			pb[2] = 0x0;			pb[3] = umet;			pb[4] = 1;			w = pbox->x2 - pbox->x1;			h = pbox->y2 - pbox->y1;			/*			 * XXX This is necessary when copying right -> left,			 * as the PixelStamp seems to interpret the length			 * incorrectly; most probably something to do with			 * the sub-pixel coordinate system.  More testing			 * required.			 */			if (pptSrc->x < pbox->x1)				w--;			if (pptSrc->x == pbox->x1)				pb[3] |= STAMP_COPYSPAN_ALIGNED;#ifdef notdef			/*			 * XXX This also makes the PixelStamp go bananas,			 * but works just fine in the kernel.  Why?			 */			else if (pptSrc->y == pbox->y1 &&			    pptSrc->x <= pbox->x1 && pptSrc->x + w > pbox->x1)				pb[3] |= STAMP_HALF_BUFF;#endif			if (ydir < 0) {				src = (pptSrc->x << 19) |				    ((pptSrc->y + h - 1) << 3);				dst = (pbox->x1 << 19) |				    ((pbox->y1 + h - 1) << 3);			} else {				src = (pptSrc->x << 19) | (pptSrc->y << 3);				dst = (pbox->x1 << 19) | (pbox->y1 << 3);			}			for (w <<= 3; h-- != 0; src += ydir, dst += ydir) {				pb = pxPacketAddPrim(sp, &pxp);				pb[0] = w;				pb[1] = src;				pb[2] = dst;			}			pxPacketFlush(sp, &pxp);			pbox++;			pptSrc++;		}	} else /* if (pSrcDrawable->type == DRAWABLE_PIXMAP) */ {		umet = pxRopTable[alu];		pPix = (PixmapPtr)pSrcDrawable;		xStrideSrc = sp->bpp >> 3;		yStrideSrc = pPix->devKind;		psrcBase = (u_int8_t *)pPix->devPrivate.ptr;		srcDir = ydir * yStrideSrc;		while (nbox--) {			h = pbox->y2 - pbox->y1;			if (ydir < 0) {				src = pptSrc->y + h - 1;				dst = pbox->y2 - 1;			} else {				src = pptSrc->y;				dst = pbox->y1;			}			psrc = psrcBase + pptSrc->x * xStrideSrc +			    src * yStrideSrc;			for (; h != 0; h--) {				pxSetScanline(sp, dst, pbox->x1, pbox->x1,				    pbox->x2, (u_int32_t *)psrc, umet, pmask);				dst += ydir;				psrc += srcDir;			}			pbox++;			pptSrc++;		}	}	if (pboxNew1) {		DEALLOCATE_LOCAL(pptNew1);		DEALLOCATE_LOCAL(pboxNew1);	}	if (pboxNew2) {		DEALLOCATE_LOCAL(pptNew2);		DEALLOCATE_LOCAL(pboxNew2);	}}