2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86_OSproc.h"
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "xf86str.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "mi.h"
|
|
|
|
#include "mipointer.h"
|
|
|
|
#include "xf86CursorPriv.h"
|
|
|
|
|
|
|
|
#include "servermd.h"
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
static CARD32
|
|
|
|
xf86ReverseBitOrder(CARD32 v)
|
|
|
|
{
|
|
|
|
return (((0x01010101 & v) << 7) | ((0x02020202 & v) << 5) |
|
|
|
|
((0x04040404 & v) << 3) | ((0x08080808 & v) << 1) |
|
|
|
|
((0x10101010 & v) >> 1) | ((0x20202020 & v) >> 3) |
|
|
|
|
((0x40404040 & v) >> 5) | ((0x80808080 & v) >> 7));
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#if BITMAP_SCANLINE_PAD == 64
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
/* Cursors might be only 32 wide. Give'em a chance */
|
|
|
|
#define SCANLINE CARD32
|
|
|
|
#define CUR_BITMAP_SCANLINE_PAD 32
|
|
|
|
#define CUR_LOG2_BITMAP_PAD 5
|
|
|
|
#define REVERSE_BIT_ORDER(w) xf86ReverseBitOrder(w)
|
|
|
|
#else
|
|
|
|
#define SCANLINE CARD64
|
|
|
|
#define CUR_BITMAP_SCANLINE_PAD BITMAP_SCANLINE_PAD
|
|
|
|
#define CUR_LOG2_BITMAP_PAD LOG2_BITMAP_PAD
|
|
|
|
#define REVERSE_BIT_ORDER(w) xf86CARD64ReverseBits(w)
|
|
|
|
static CARD64 xf86CARD64ReverseBits(CARD64 w);
|
|
|
|
|
|
|
|
static CARD64
|
|
|
|
xf86CARD64ReverseBits(CARD64 w)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
unsigned char *p = (unsigned char *) &w;
|
|
|
|
|
|
|
|
p[0] = byte_reversed[p[0]];
|
|
|
|
p[1] = byte_reversed[p[1]];
|
|
|
|
p[2] = byte_reversed[p[2]];
|
|
|
|
p[3] = byte_reversed[p[3]];
|
|
|
|
p[4] = byte_reversed[p[4]];
|
|
|
|
p[5] = byte_reversed[p[5]];
|
|
|
|
p[6] = byte_reversed[p[6]];
|
|
|
|
p[7] = byte_reversed[p[7]];
|
|
|
|
|
|
|
|
return w;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define SCANLINE CARD32
|
|
|
|
#define CUR_BITMAP_SCANLINE_PAD BITMAP_SCANLINE_PAD
|
|
|
|
#define CUR_LOG2_BITMAP_PAD LOG2_BITMAP_PAD
|
|
|
|
#define REVERSE_BIT_ORDER(w) xf86ReverseBitOrder(w)
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* BITMAP_SCANLINE_PAD == 64 */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *RealizeCursorInterleave0(xf86CursorInfoPtr, CursorPtr);
|
|
|
|
static unsigned char *RealizeCursorInterleave1(xf86CursorInfoPtr, CursorPtr);
|
|
|
|
static unsigned char *RealizeCursorInterleave8(xf86CursorInfoPtr, CursorPtr);
|
|
|
|
static unsigned char *RealizeCursorInterleave16(xf86CursorInfoPtr, CursorPtr);
|
|
|
|
static unsigned char *RealizeCursorInterleave32(xf86CursorInfoPtr, CursorPtr);
|
|
|
|
static unsigned char *RealizeCursorInterleave64(xf86CursorInfoPtr, CursorPtr);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
Bool
|
|
|
|
xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
|
|
|
|
{
|
|
|
|
if ((infoPtr->MaxWidth <= 0) || (infoPtr->MaxHeight <= 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* These are required for now */
|
|
|
|
if (!infoPtr->SetCursorPosition ||
|
2014-09-27 11:52:59 -06:00
|
|
|
!xf86DriverHasLoadCursorImage(infoPtr) ||
|
2012-06-10 07:21:05 -06:00
|
|
|
!infoPtr->HideCursor ||
|
|
|
|
!infoPtr->ShowCursor || !infoPtr->SetCursorColors)
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (infoPtr->RealizeCursor) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Don't overwrite a driver provided Realize Cursor function */
|
|
|
|
}
|
|
|
|
else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 & infoPtr->Flags) {
|
|
|
|
infoPtr->RealizeCursor = RealizeCursorInterleave1;
|
|
|
|
}
|
|
|
|
else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 & infoPtr->Flags) {
|
|
|
|
infoPtr->RealizeCursor = RealizeCursorInterleave8;
|
|
|
|
}
|
|
|
|
else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 & infoPtr->Flags) {
|
|
|
|
infoPtr->RealizeCursor = RealizeCursorInterleave16;
|
|
|
|
}
|
|
|
|
else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 & infoPtr->Flags) {
|
|
|
|
infoPtr->RealizeCursor = RealizeCursorInterleave32;
|
|
|
|
}
|
|
|
|
else if (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 & infoPtr->Flags) {
|
|
|
|
infoPtr->RealizeCursor = RealizeCursorInterleave64;
|
|
|
|
}
|
|
|
|
else { /* not interleaved */
|
|
|
|
infoPtr->RealizeCursor = RealizeCursorInterleave0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
infoPtr->pScrn = xf86ScreenToScrn(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
Bool
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CursorScreenPtr ScreenPriv =
|
|
|
|
(xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86CursorScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
|
|
|
|
unsigned char *bits;
|
|
|
|
|
|
|
|
if (pCurs == NullCursor) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->HideCursor) (infoPtr->pScrn);
|
2014-09-27 11:52:59 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
bits =
|
|
|
|
dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
|
|
|
|
y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
|
|
|
|
|
|
|
|
#ifdef ARGB_CURSOR
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!pCurs->bits->argb || !xf86DriverHasLoadCursorARGB(infoPtr))
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!bits) {
|
|
|
|
bits = (*infoPtr->RealizeCursor) (infoPtr, pCurs);
|
|
|
|
dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
|
|
|
|
bits);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->HideCursor) (infoPtr->pScrn);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef ARGB_CURSOR
|
2014-09-27 11:52:59 -06:00
|
|
|
if (pCurs->bits->argb && xf86DriverHasLoadCursorARGB(infoPtr)) {
|
|
|
|
if (!xf86DriverLoadCursorARGB (infoPtr, pCurs))
|
|
|
|
return FALSE;
|
|
|
|
} else
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
if (bits)
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!xf86DriverLoadCursorImage (infoPtr, bits))
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
xf86RecolorCursor(pScreen, pCurs, 1);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->ShowCursor) (infoPtr->pScrn);
|
2014-09-27 11:52:59 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86SetTransparentCursor(ScreenPtr pScreen)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CursorScreenPtr ScreenPriv =
|
|
|
|
(xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86CursorScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
|
|
|
|
|
|
|
|
if (!ScreenPriv->transparentData)
|
2012-06-10 07:21:05 -06:00
|
|
|
ScreenPriv->transparentData =
|
|
|
|
(*infoPtr->RealizeCursor) (infoPtr, NullCursor);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->HideCursor) (infoPtr->pScrn);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (ScreenPriv->transparentData)
|
2014-09-27 11:52:59 -06:00
|
|
|
xf86DriverLoadCursorImage (infoPtr,
|
|
|
|
ScreenPriv->transparentData);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->ShowCursor) (infoPtr->pScrn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86MoveCursor(ScreenPtr pScreen, int x, int y)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CursorScreenPtr ScreenPriv =
|
|
|
|
(xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86CursorScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
|
|
|
|
|
|
|
|
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
|
|
|
|
y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86CursorScreenPtr ScreenPriv =
|
|
|
|
(xf86CursorScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
xf86CursorScreenKey);
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
|
|
|
|
|
|
|
|
#ifdef ARGB_CURSOR
|
|
|
|
/* recoloring isn't applicable to ARGB cursors and drivers
|
|
|
|
shouldn't have to ignore SetCursorColors requests */
|
|
|
|
if (pCurs->bits->argb)
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ScreenPriv->PalettedCursor) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xColorItem sourceColor, maskColor;
|
|
|
|
ColormapPtr pmap = ScreenPriv->pInstalledMap;
|
|
|
|
|
|
|
|
if (!pmap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sourceColor.red = pCurs->foreRed;
|
|
|
|
sourceColor.green = pCurs->foreGreen;
|
|
|
|
sourceColor.blue = pCurs->foreBlue;
|
|
|
|
FakeAllocColor(pmap, &sourceColor);
|
|
|
|
maskColor.red = pCurs->backRed;
|
|
|
|
maskColor.green = pCurs->backGreen;
|
|
|
|
maskColor.blue = pCurs->backBlue;
|
|
|
|
FakeAllocColor(pmap, &maskColor);
|
|
|
|
FakeFreeColor(pmap, sourceColor.pixel);
|
|
|
|
FakeFreeColor(pmap, maskColor.pixel);
|
|
|
|
(*infoPtr->SetCursorColors) (infoPtr->pScrn,
|
|
|
|
maskColor.pixel, sourceColor.pixel);
|
|
|
|
}
|
|
|
|
else { /* Pass colors in 8-8-8 RGB format */
|
|
|
|
(*infoPtr->SetCursorColors) (infoPtr->pScrn,
|
|
|
|
(pCurs->backBlue >> 8) |
|
|
|
|
((pCurs->backGreen >> 8) << 8) |
|
|
|
|
((pCurs->backRed >> 8) << 16),
|
|
|
|
(pCurs->foreBlue >> 8) |
|
|
|
|
((pCurs->foreGreen >> 8) << 8) |
|
|
|
|
((pCurs->foreRed >> 8) << 16)
|
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* These functions assume that MaxWidth is a multiple of 32 */
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeCursorInterleave0(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
|
|
|
|
{
|
|
|
|
|
|
|
|
SCANLINE *SrcS, *SrcM, *DstS, *DstM;
|
|
|
|
SCANLINE *pSrc, *pMsk;
|
|
|
|
unsigned char *mem;
|
|
|
|
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
|
|
|
|
int SrcPitch, DstPitch, Pitch, y, x;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* how many words are in the source or mask */
|
|
|
|
int words = size / (CUR_BITMAP_SCANLINE_PAD / 4);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!(mem = calloc(1, size)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pCurs == NullCursor) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) {
|
|
|
|
DstM = (SCANLINE *) mem;
|
|
|
|
if (!(infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK))
|
|
|
|
DstM += words;
|
|
|
|
memset(DstM, -1, words * sizeof(SCANLINE));
|
|
|
|
}
|
|
|
|
return mem;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SrcPitch == the number of scanlines wide the cursor image is */
|
|
|
|
SrcPitch = (pCurs->bits->width + (BITMAP_SCANLINE_PAD - 1)) >>
|
2012-06-10 07:21:05 -06:00
|
|
|
CUR_LOG2_BITMAP_PAD;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* DstPitch is the width of the hw cursor in scanlines */
|
|
|
|
DstPitch = infoPtr->MaxWidth >> CUR_LOG2_BITMAP_PAD;
|
|
|
|
Pitch = SrcPitch < DstPitch ? SrcPitch : DstPitch;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
SrcS = (SCANLINE *) pCurs->bits->source;
|
|
|
|
SrcM = (SCANLINE *) pCurs->bits->mask;
|
|
|
|
DstS = (SCANLINE *) mem;
|
2006-11-26 11:13:41 -07:00
|
|
|
DstM = DstS + words;
|
|
|
|
|
|
|
|
if (infoPtr->Flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK) {
|
2012-06-10 07:21:05 -06:00
|
|
|
SCANLINE *tmp;
|
|
|
|
|
|
|
|
tmp = DstS;
|
|
|
|
DstS = DstM;
|
|
|
|
DstM = tmp;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (infoPtr->Flags & HARDWARE_CURSOR_AND_SOURCE_WITH_MASK) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
|
|
|
|
y--;
|
|
|
|
pSrc += DstPitch, pMsk += DstPitch, SrcS += SrcPitch, SrcM +=
|
|
|
|
SrcPitch) {
|
|
|
|
for (x = 0; x < Pitch; x++) {
|
|
|
|
pSrc[x] = SrcS[x] & SrcM[x];
|
|
|
|
pMsk[x] = SrcM[x];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
|
|
|
|
y--;
|
|
|
|
pSrc += DstPitch, pMsk += DstPitch, SrcS += SrcPitch, SrcM +=
|
|
|
|
SrcPitch) {
|
|
|
|
for (x = 0; x < Pitch; x++) {
|
|
|
|
pSrc[x] = SrcS[x];
|
|
|
|
pMsk[x] = SrcM[x];
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (infoPtr->Flags & HARDWARE_CURSOR_NIBBLE_SWAPPED) {
|
2012-06-10 07:21:05 -06:00
|
|
|
int count = size;
|
|
|
|
unsigned char *pntr1 = (unsigned char *) DstS;
|
|
|
|
unsigned char *pntr2 = (unsigned char *) DstM;
|
|
|
|
unsigned char a, b;
|
|
|
|
|
|
|
|
while (count) {
|
|
|
|
|
|
|
|
a = *pntr1;
|
|
|
|
b = *pntr2;
|
|
|
|
*pntr1 = ((a & 0xF0) >> 4) | ((a & 0x0F) << 4);
|
|
|
|
*pntr2 = ((b & 0xF0) >> 4) | ((b & 0x0F) << 4);
|
|
|
|
pntr1++;
|
|
|
|
pntr2++;
|
|
|
|
count -= 2;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Must be _after_ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK to avoid wiping
|
|
|
|
* out entire source mask.
|
|
|
|
*/
|
|
|
|
if (infoPtr->Flags & HARDWARE_CURSOR_INVERT_MASK) {
|
2012-06-10 07:21:05 -06:00
|
|
|
int count = words;
|
|
|
|
SCANLINE *pntr = DstM;
|
|
|
|
|
|
|
|
while (count--) {
|
|
|
|
*pntr = ~(*pntr);
|
|
|
|
pntr++;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (infoPtr->Flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (y = pCurs->bits->height, pSrc = DstS, pMsk = DstM;
|
|
|
|
y--; pSrc += DstPitch, pMsk += DstPitch) {
|
|
|
|
for (x = 0; x < Pitch; x++) {
|
|
|
|
pSrc[x] = REVERSE_BIT_ORDER(pSrc[x]);
|
|
|
|
pMsk[x] = REVERSE_BIT_ORDER(pMsk[x]);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeCursorInterleave1(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
|
|
|
|
{
|
|
|
|
unsigned char *DstS, *DstM;
|
|
|
|
unsigned char *pntr;
|
|
|
|
unsigned char *mem, *mem2;
|
|
|
|
int count;
|
|
|
|
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
|
|
|
|
|
|
|
|
/* Realize the cursor without interleaving */
|
|
|
|
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!(mem = calloc(1, size))) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(mem2);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* 1 bit interleave */
|
2006-11-26 11:13:41 -07:00
|
|
|
DstS = mem2;
|
|
|
|
DstM = DstS + (size >> 1);
|
|
|
|
pntr = mem;
|
|
|
|
count = size;
|
|
|
|
while (count) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*pntr++ = ((*DstS & 0x01)) | ((*DstM & 0x01) << 1) |
|
|
|
|
((*DstS & 0x02) << 1) | ((*DstM & 0x02) << 2) |
|
|
|
|
((*DstS & 0x04) << 2) | ((*DstM & 0x04) << 3) |
|
|
|
|
((*DstS & 0x08) << 3) | ((*DstM & 0x08) << 4);
|
|
|
|
*pntr++ = ((*DstS & 0x10) >> 4) | ((*DstM & 0x10) >> 3) |
|
|
|
|
((*DstS & 0x20) >> 3) | ((*DstM & 0x20) >> 2) |
|
|
|
|
((*DstS & 0x40) >> 2) | ((*DstM & 0x40) >> 1) |
|
|
|
|
((*DstS & 0x80) >> 1) | ((*DstM & 0x80));
|
|
|
|
DstS++;
|
|
|
|
DstM++;
|
|
|
|
count -= 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the uninterleaved cursor */
|
2010-12-05 08:36:02 -07:00
|
|
|
free(mem2);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeCursorInterleave8(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
|
|
|
|
{
|
|
|
|
unsigned char *DstS, *DstM;
|
|
|
|
unsigned char *pntr;
|
|
|
|
unsigned char *mem, *mem2;
|
|
|
|
int count;
|
|
|
|
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
|
|
|
|
|
|
|
|
/* Realize the cursor without interleaving */
|
|
|
|
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!(mem = calloc(1, size))) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(mem2);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 8 bit interleave */
|
|
|
|
DstS = mem2;
|
|
|
|
DstM = DstS + (size >> 1);
|
|
|
|
pntr = mem;
|
|
|
|
count = size;
|
|
|
|
while (count) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*pntr++ = *DstS++;
|
|
|
|
*pntr++ = *DstM++;
|
|
|
|
count -= 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the uninterleaved cursor */
|
2010-12-05 08:36:02 -07:00
|
|
|
free(mem2);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeCursorInterleave16(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
|
|
|
|
{
|
|
|
|
unsigned short *DstS, *DstM;
|
|
|
|
unsigned short *pntr;
|
|
|
|
unsigned char *mem, *mem2;
|
|
|
|
int count;
|
|
|
|
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
|
|
|
|
|
|
|
|
/* Realize the cursor without interleaving */
|
|
|
|
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!(mem = calloc(1, size))) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(mem2);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 16 bit interleave */
|
2014-09-27 11:52:59 -06:00
|
|
|
DstS = (void *) mem2;
|
2006-11-26 11:13:41 -07:00
|
|
|
DstM = DstS + (size >> 2);
|
2014-09-27 11:52:59 -06:00
|
|
|
pntr = (void *) mem;
|
2006-11-26 11:13:41 -07:00
|
|
|
count = (size >> 1);
|
|
|
|
while (count) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*pntr++ = *DstS++;
|
|
|
|
*pntr++ = *DstM++;
|
|
|
|
count -= 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the uninterleaved cursor */
|
2010-12-05 08:36:02 -07:00
|
|
|
free(mem2);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeCursorInterleave32(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
|
|
|
|
{
|
|
|
|
CARD32 *DstS, *DstM;
|
|
|
|
CARD32 *pntr;
|
|
|
|
unsigned char *mem, *mem2;
|
|
|
|
int count;
|
|
|
|
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
|
|
|
|
|
|
|
|
/* Realize the cursor without interleaving */
|
|
|
|
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!(mem = calloc(1, size))) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(mem2);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 32 bit interleave */
|
2014-09-27 11:52:59 -06:00
|
|
|
DstS = (void *) mem2;
|
2006-11-26 11:13:41 -07:00
|
|
|
DstM = DstS + (size >> 3);
|
2014-09-27 11:52:59 -06:00
|
|
|
pntr = (void *) mem;
|
2006-11-26 11:13:41 -07:00
|
|
|
count = (size >> 2);
|
|
|
|
while (count) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*pntr++ = *DstS++;
|
|
|
|
*pntr++ = *DstM++;
|
|
|
|
count -= 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the uninterleaved cursor */
|
2010-12-05 08:36:02 -07:00
|
|
|
free(mem2);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *
|
2006-11-26 11:13:41 -07:00
|
|
|
RealizeCursorInterleave64(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
|
|
|
|
{
|
|
|
|
CARD32 *DstS, *DstM;
|
|
|
|
CARD32 *pntr;
|
|
|
|
unsigned char *mem, *mem2;
|
|
|
|
int count;
|
|
|
|
int size = (infoPtr->MaxWidth * infoPtr->MaxHeight) >> 2;
|
|
|
|
|
|
|
|
/* Realize the cursor without interleaving */
|
|
|
|
if (!(mem2 = RealizeCursorInterleave0(infoPtr, pCurs)))
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!(mem = calloc(1, size))) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(mem2);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 64 bit interleave */
|
2014-09-27 11:52:59 -06:00
|
|
|
DstS = (void *) mem2;
|
2006-11-26 11:13:41 -07:00
|
|
|
DstM = DstS + (size >> 3);
|
2014-09-27 11:52:59 -06:00
|
|
|
pntr = (void *) mem;
|
2006-11-26 11:13:41 -07:00
|
|
|
count = (size >> 2);
|
|
|
|
while (count) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*pntr++ = *DstS++;
|
|
|
|
*pntr++ = *DstS++;
|
|
|
|
*pntr++ = *DstM++;
|
|
|
|
*pntr++ = *DstM++;
|
|
|
|
count -= 4;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the uninterleaved cursor */
|
2010-12-05 08:36:02 -07:00
|
|
|
free(mem2);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|