#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include "gcstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "../mfb/maskbits.h"
#include "mi.h"
#define NPT 128
_X_EXPORT void
miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
GCPtr pGC;
PixmapPtr pBitMap;
DrawablePtr pDrawable;
int dx, dy, xOrg, yOrg;
{
int h, dxDivPPW, ibEnd;
MiBits *pwLineStart;
register MiBits *pw, *pwEnd;
register MiBits msk;
register int ib, w;
register int ipt;
Bool fInBox;
DDXPointRec pt[NPT], ptThisLine;
int width[NPT];
#if 1
PixelType startmask;
if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
if (screenInfo.bitmapBitOrder == LSBFirst)
startmask = (MiBits)(-1) ^
LONG2CHARSSAMEORDER((MiBits)(-1) << 1);
else
startmask = (MiBits)(-1) ^
LONG2CHARSSAMEORDER((MiBits)(-1) >> 1);
else
if (screenInfo.bitmapBitOrder == LSBFirst)
startmask = (MiBits)(-1) ^
LONG2CHARSDIFFORDER((MiBits)(-1) << 1);
else
startmask = (MiBits)(-1) ^
LONG2CHARSDIFFORDER((MiBits)(-1) >> 1);
#endif
pwLineStart = (MiBits *)xalloc(BitmapBytePad(dx));
if (!pwLineStart)
return;
ipt = 0;
dxDivPPW = dx/PPW;
for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0;
h < dy;
h++, ptThisLine.y++)
{
(*pBitMap->drawable.pScreen->GetSpans)((DrawablePtr)pBitMap, dx,
&ptThisLine, &dx, 1, (char *)pwLineStart);
pw = pwLineStart;
fInBox = FALSE;
pwEnd = pwLineStart + dxDivPPW;
while(pw < pwEnd)
{
w = *pw;
#if 1
msk = startmask;
#else
msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
#endif
for(ib = 0; ib < PPW; ib++)
{
if(w & msk)
{
if(!fInBox)
{
pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
pt[ipt].y = h + yOrg;
fInBox = TRUE;
}
}
else
{
if(fInBox)
{
width[ipt] = ((pw - pwLineStart) << PWSH) +
ib + xOrg - pt[ipt].x;
if (++ipt >= NPT)
{
(*pGC->ops->FillSpans)(pDrawable, pGC,
NPT, pt, width, TRUE);
ipt = 0;
}
fInBox = FALSE;
}
}
#if 1
if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
if (screenInfo.bitmapBitOrder == LSBFirst)
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
else
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
else
if (screenInfo.bitmapBitOrder == LSBFirst)
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
else
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
#else
msk = SCRRIGHT(msk, 1);
#endif
}
pw++;
}
ibEnd = dx & PIM;
if(ibEnd)
{
w = *pw;
#if 1
msk = startmask;
#else
msk = (MiBits)(-1) ^ SCRRIGHT((MiBits)(-1), 1);
#endif
for(ib = 0; ib < ibEnd; ib++)
{
if(w & msk)
{
if(!fInBox)
{
pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
pt[ipt].y = h + yOrg;
fInBox = TRUE;
}
}
else
{
if(fInBox)
{
width[ipt] = ((pw - pwLineStart) << PWSH) +
ib + xOrg - pt[ipt].x;
if (++ipt >= NPT)
{
(*pGC->ops->FillSpans)(pDrawable,
pGC, NPT, pt, width, TRUE);
ipt = 0;
}
fInBox = FALSE;
}
}
#if 1
if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
if (screenInfo.bitmapBitOrder == LSBFirst)
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) << 1);
else
msk = LONG2CHARSSAMEORDER(LONG2CHARSSAMEORDER(msk) >> 1);
else
if (screenInfo.bitmapBitOrder == LSBFirst)
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) << 1);
else
msk = LONG2CHARSDIFFORDER(LONG2CHARSDIFFORDER(msk) >> 1);
#else
msk = SCRRIGHT(msk, 1);
#endif
}
}
if(fInBox)
{
width[ipt] = dx + xOrg - pt[ipt].x;
if (++ipt >= NPT)
{
(*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
ipt = 0;
}
}
}
xfree(pwLineStart);
if (ipt)
{
(*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
}
}