Commit 83388cb2 authored by Keith Packard's avatar Keith Packard
Browse files

kdrive/i810: bit swap for i810 cursor (from Pontus Lidman)

parent 4646a6c3
...@@ -167,13 +167,19 @@ _i810SetCursorColors(ScreenPtr pScreen) { /* int bg, int fg */ ...@@ -167,13 +167,19 @@ _i810SetCursorColors(ScreenPtr pScreen) { /* int bg, int fg */
OUTREG8( PIXPIPE_CONFIG_0, tmp ); OUTREG8( PIXPIPE_CONFIG_0, tmp );
} }
#define InvertBits32(v) { \
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
}
static void i810LoadCursor(ScreenPtr pScreen, int x, int y) { static void i810LoadCursor(ScreenPtr pScreen, int x, int y) {
SetupCursor(pScreen); SetupCursor(pScreen);
int w, h; int w, h;
unsigned short r; unsigned short r;
unsigned char *msk, *mskLine, *src, *srcLine; unsigned int *msk, *mskLine, *src, *srcLine;
int i, j; int i, j;
int src_stride, src_width; int src_stride, src_width;
...@@ -181,35 +187,36 @@ static void i810LoadCursor(ScreenPtr pScreen, int x, int y) { ...@@ -181,35 +187,36 @@ static void i810LoadCursor(ScreenPtr pScreen, int x, int y) {
CursorPtr pCursor = pCurPriv->pCursor; CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits; CursorBitsPtr bits = pCursor->bits;
CARD8 tmp; CARD8 tmp;
unsigned char *ram, *ramLine; unsigned int *ram, *ramLine;
pCurPriv->pCursor = pCursor; pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot; pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot; pCurPriv->yhot = pCursor->bits->yhot;
ramLine = (unsigned char *)(i810c->FbBase + i810c->CursorStart); ramLine = (unsigned int *) (i810c->FbBase + i810c->CursorStart);
mskLine = (unsigned char *) bits->mask; mskLine = (unsigned int *) (bits->mask);
srcLine = (unsigned char *) bits->source; srcLine = (unsigned int *) (bits->source);
h = bits->height; h = bits->height;
if (h > I810_CURSOR_HEIGHT) if (h > I810_CURSOR_HEIGHT)
h = I810_CURSOR_HEIGHT; h = I810_CURSOR_HEIGHT;
src_stride = BitmapBytePad(bits->width); /* bytes per line */ src_stride = BitmapBytePad(bits->width); /* bytes per line */
src_width = (bits->width + 7) >> 3; src_stride = (src_stride +3) >> 2;
src_width = (bits->width + 31) >> 5;
for (i = 0; i < I810_CURSOR_HEIGHT; i++) { for (i = 0; i < I810_CURSOR_HEIGHT; i++) {
msk = mskLine; msk = mskLine;
src = srcLine; src = srcLine;
ram = ramLine; ram = ramLine;
mskLine += src_stride; mskLine += src_stride;
srcLine += src_stride; srcLine += src_stride;
ramLine += I810_CURSOR_WIDTH / 4; ramLine += I810_CURSOR_WIDTH / 16;
for (j = 0; j < I810_CURSOR_WIDTH / 8; j++) { for (j = 0; j < I810_CURSOR_WIDTH / 32; j++) {
unsigned short m, s, b1, b2; unsigned long m, s, b1, b2;
if (i < h && j < src_width) if (i < h && j < src_width)
{ {
...@@ -217,23 +224,22 @@ static void i810LoadCursor(ScreenPtr pScreen, int x, int y) { ...@@ -217,23 +224,22 @@ static void i810LoadCursor(ScreenPtr pScreen, int x, int y) {
s = *src++ & m; s = *src++ & m;
m = ~m; m = ~m;
/* mask off right side */ /* mask off right side */
if (j == src_width - 1 && (bits->width & 7)) if (j == src_width - 1 && (bits->width & 31))
{ {
m |= 0xff << (bits->width & 7); m |= 0xffffffff << (bits->width & 31);
} }
} }
else else
{ {
m = 0xff; m = 0xffffffff;
s = 0x00; s = 0x00000000;
} }
/* The i810 stores the cursor in an interleaved bitmap format, InvertBits32(s);
in reverse byte order */ InvertBits32(m);
/* Not tested with cursors bigger than 16x16 !!! */
ram[8+(j ^ 1)] = s; /* b2 */ ram[2+j]=s;
ram[0+(j ^ 1)] = m; /* b1 */ ram[0+j]=m;
} }
} }
/* Set new color */ /* Set new color */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment