diff options
author | Pierre Ossman <ossman@cendio.se> | 2011-06-08 17:04:13 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2011-06-08 17:04:13 +0000 |
commit | e4ad7b1f33564c7dc2d9a7d11fdd18964775a053 (patch) | |
tree | 7bf6663405677aa767987b942a2ce3c8a7020a31 /unix | |
parent | 835b4ef7cdf7df1f91aa0d337a5a4537011d4742 (diff) | |
download | tigervnc-e4ad7b1f33564c7dc2d9a7d11fdd18964775a053.tar.gz tigervnc-e4ad7b1f33564c7dc2d9a7d11fdd18964775a053.zip |
Server support for full colour cursors (no support for alpha though).
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4473 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'unix')
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 118 |
1 files changed, 75 insertions, 43 deletions
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index 5672847d..b8b7851a 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -351,61 +351,93 @@ void XserverDesktop::setCursor(CursorPtr cursor) try { int w = cursor->bits->width; int h = cursor->bits->height; + rdr::U8* cursorData = new rdr::U8[w * h * (getPF().bpp / 8)]; - xColorItem fg, bg; - fg.red = cursor->foreRed; - fg.green = cursor->foreGreen; - fg.blue = cursor->foreBlue; - FakeAllocColor(cmap, &fg); - bg.red = cursor->backRed; - bg.green = cursor->backGreen; - bg.blue = cursor->backBlue; - FakeAllocColor(cmap, &bg); - FakeFreeColor(cmap, fg.pixel); - FakeFreeColor(cmap, bg.pixel); - - int xMaskBytesPerRow = BitmapBytePad(w); - - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - int byte = y * xMaskBytesPerRow + x / 8; + int rfbMaskBytesPerRow = (w + 7) / 8; + + rdr::U8* cursorMask = new rdr::U8[rfbMaskBytesPerRow * h]; + +#ifdef ARGB_CURSOR + if (cursor->bits->argb) { + rdr::U8 *out; + CARD32 *in; + + rdr::U8 rgb[3]; + + memset(cursorMask, 0, rfbMaskBytesPerRow * h); + + in = cursor->bits->argb; + out = cursorData; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + rgb[0] = (*in >> 16) & 0xff; + rgb[1] = (*in >> 8) & 0xff; + rgb[2] = (*in >> 0) & 0xff; + + getPF().bufferFromRGB(out, rgb, 1, this); + + if (((*in >> 24) & 0xff) > 127) + cursorMask[y * rfbMaskBytesPerRow + x/8] |= 0x80>>(x%8); + + in++; + out += getPF().bpp/8; + } + } + } else { +#endif + xColorItem fg, bg; + fg.red = cursor->foreRed; + fg.green = cursor->foreGreen; + fg.blue = cursor->foreBlue; + FakeAllocColor(cmap, &fg); + bg.red = cursor->backRed; + bg.green = cursor->backGreen; + bg.blue = cursor->backBlue; + FakeAllocColor(cmap, &bg); + FakeFreeColor(cmap, fg.pixel); + FakeFreeColor(cmap, bg.pixel); + + int xMaskBytesPerRow = BitmapBytePad(w); + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + int byte = y * xMaskBytesPerRow + x / 8; #if (BITMAP_BIT_ORDER == MSBFirst) - int bit = 7 - x % 8; + int bit = 7 - x % 8; #else - int bit = x % 8; + int bit = x % 8; #endif - switch (getPF().bpp) { - case 8: - ((rdr::U8*)cursorData)[y * w + x] - = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel; - break; - case 16: - ((rdr::U16*)cursorData)[y * w + x] - = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel; - break; - case 32: - ((rdr::U32*)cursorData)[y * w + x] - = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel; - break; + switch (getPF().bpp) { + case 8: + ((rdr::U8*)cursorData)[y * w + x] + = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel; + break; + case 16: + ((rdr::U16*)cursorData)[y * w + x] + = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel; + break; + case 32: + ((rdr::U32*)cursorData)[y * w + x] + = (cursor->bits->source[byte] & (1 << bit)) ? fg.pixel : bg.pixel; + break; + } } } - } - int rfbMaskBytesPerRow = (w + 7) / 8; - - rdr::U8* cursorMask = new rdr::U8[rfbMaskBytesPerRow * h]; - - for (int j = 0; j < h; j++) { - for (int i = 0; i < rfbMaskBytesPerRow; i++) + for (int j = 0; j < h; j++) { + for (int i = 0; i < rfbMaskBytesPerRow; i++) #if (BITMAP_BIT_ORDER == MSBFirst) - cursorMask[j * rfbMaskBytesPerRow + i] - = cursor->bits->mask[j * xMaskBytesPerRow + i]; + cursorMask[j * rfbMaskBytesPerRow + i] + = cursor->bits->mask[j * xMaskBytesPerRow + i]; #else - cursorMask[j * rfbMaskBytesPerRow + i] - = reverseBits[cursor->bits->mask[j * xMaskBytesPerRow + i]]; + cursorMask[j * rfbMaskBytesPerRow + i] + = reverseBits[cursor->bits->mask[j * xMaskBytesPerRow + i]]; #endif + } +#ifdef ARGB_CURSOR } +#endif server->setCursor(cursor->bits->width, cursor->bits->height, Point(cursor->bits->xhot, cursor->bits->yhot), |