#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdlib.h>
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
#include <X11/fonts/font.h>
#include "dixfontstr.h"
#include <X11/fonts/fontstruct.h>
#include "mi.h"
#include "regionstr.h"
#include "globals.h"
#include "gcstruct.h"
#include "shadow.h"
#include "fb.h"
#define PL_SHIFT 8
#define PL_UNIT (1 << PL_SHIFT)
#define PL_MASK (PL_UNIT - 1)
#if 0
#define GetBits(p,o,d) { \
CARD32 m1,m2,m3,m4,m5,m6,m7,m8; \
m1 = sha[o] << (7 - (p)); \
m2 = sha[(o)+1] << (3 - (p)); \
m3 = m1 & 0x80808080; \
m4 = m2 & 0x08080808; \
m5 = m3 | m4; \
m6 = m5 >> 9; \
m7 = m5 | m6; \
m8 = m7 >> 18; \
d = m7 | m8; \
}
#else
#define GetBits(p,o,d) { \
CARD32 m5,m7; \
m5 = ((sha[o] << (7 - (p))) & 0x80808080) | ((sha[(o)+1] << (3 - (p))) & 0x08080808); \
m7 = m5 | (m5 >> 9); \
d = m7 | (m7 >> 18); \
}
#endif
void
shadowUpdatePlanar4x8 (ScreenPtr pScreen,
shadowBufPtr pBuf)
{
RegionPtr damage = shadowDamage (pBuf);
PixmapPtr pShadow = pBuf->pPixmap;
int nbox = REGION_NUM_RECTS (damage);
BoxPtr pbox = REGION_RECTS (damage);
CARD32 *shaBase, *shaLine, *sha;
CARD8 s1, s2, s3, s4;
FbStride shaStride;
int scrBase, scrLine, scr;
int shaBpp;
int shaXoff, shaYoff;
int x, y, w, h, width;
int i;
CARD32 *winBase = NULL, *win;
CARD32 winSize;
int plane;
fbGetStipDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
while (nbox--)
{
x = pbox->x1 * shaBpp;
y = pbox->y1;
w = (pbox->x2 - pbox->x1) * shaBpp;
h = pbox->y2 - pbox->y1;
w = (w + (x & PL_MASK) + PL_MASK) >> PL_SHIFT;
x &= ~PL_MASK;
scrLine = (x >> PL_SHIFT);
shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
while (h--)
{
for (plane = 0; plane < 4; plane++)
{
width = w;
scr = scrLine;
sha = shaLine;
winSize = 0;
scrBase = 0;
while (width) {
i = scrBase + winSize - scr;
if (i <= 0 || scr < scrBase)
{
winBase = (CARD32 *) (*pBuf->window) (pScreen,
y,
(scr << 4) | (plane),
SHADOW_WINDOW_WRITE,
&winSize,
pBuf->closure);
if(!winBase)
return;
winSize >>= 2;
scrBase = scr;
i = winSize;
}
win = winBase + (scr - scrBase);
if (i > width)
i = width;
width -= i;
scr += i;
while (i--)
{
GetBits(plane,0,s1);
GetBits(plane,2,s2);
GetBits(plane,4,s3);
GetBits(plane,6,s4);
*win++ = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
sha += 8;
}
}
}
shaLine += shaStride;
y++;
}
pbox++;
}
}