aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CMsgReader.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-02-19 15:48:17 +0100
committerPierre Ossman <ossman@cendio.se>2017-02-22 16:58:10 +0100
commit6a1a0d0c578e39338e757edf59cf8806a9d86b0f (patch)
treea82ede30f7e9d1f36b3169acb6a7a6a4f936ad78 /common/rfb/CMsgReader.cxx
parente20cf62bbdefd48979603105d60c3a170eb2ece6 (diff)
downloadtigervnc-6a1a0d0c578e39338e757edf59cf8806a9d86b0f.tar.gz
tigervnc-6a1a0d0c578e39338e757edf59cf8806a9d86b0f.zip
Change cursor API to use RGBA data
This will allow us to use better formats that preserve the entire alpha channel.
Diffstat (limited to 'common/rfb/CMsgReader.cxx')
-rw-r--r--common/rfb/CMsgReader.cxx29
1 files changed, 27 insertions, 2 deletions
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 96ddf443..bbb99096 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- * Copyright 2009-2014 Pierre Ossman for Cendio AB
+ * Copyright 2009-2017 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -198,10 +198,35 @@ void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
rdr::U8Array data(data_len);
rdr::U8Array mask(mask_len);
+ int x, y;
+ rdr::U8 buf[width*height*4];
+ rdr::U8* in;
+ rdr::U8* out;
+
is->readBytes(data.buf, data_len);
is->readBytes(mask.buf, mask_len);
- handler->setCursor(width, height, hotspot, data.buf, mask.buf);
+ int maskBytesPerRow = (width+7)/8;
+ in = data.buf;
+ out = buf;
+ for (y = 0;y < height;y++) {
+ for (x = 0;x < width;x++) {
+ int byte = y * maskBytesPerRow + x / 8;
+ int bit = 7 - x % 8;
+
+ handler->cp.pf().rgbFromBuffer(out, in, 1);
+
+ if (mask.buf[byte] & (1 << bit))
+ out[3] = 255;
+ else
+ out[3] = 0;
+
+ in += handler->cp.pf().bpp/8;
+ out += 4;
+ }
+ }
+
+ handler->setCursor(width, height, hotspot, buf);
}
void CMsgReader::readSetDesktopName(int x, int y, int w, int h)