#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 "mi.h"
#include "servermd.h"
#define NPT 128
#define LONG2CHARSSAMEORDER(x) ((MiBits)(x))
#define LONG2CHARSDIFFORDER( x ) ( ( ( ( x ) & (MiBits)0x000000FF ) << 0x18 ) \
| ( ( ( x ) & (MiBits)0x0000FF00 ) << 0x08 ) \
| ( ( ( x ) & (MiBits)0x00FF0000 ) >> 0x08 ) \
| ( ( ( x ) & (MiBits)0xFF000000 ) >> 0x18 ) )
#define PGSZB 4
#define PPW (PGSZB<<3)
#define PGSZ PPW
#define PLST (PPW-1)
#define PIM PLST
#define PWSH 5
void
miPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
int dx, int dy, int xOrg, int yOrg)
{
int h, dxDivPPW, ibEnd;
MiBits *pwLineStart;
MiBits *pw, *pwEnd;
MiBits msk;
int ib, w;
int ipt;
Bool fInBox;
DDXPointRec pt[NPT], ptThisLine;
int width[NPT];
#if 1
MiBits 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 = malloc(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;
}
}
}
free(pwLineStart);
if (ipt)
{
(*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
}
}