summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordscho <dscho>2008-01-30 20:38:51 +0000
committerdscho <dscho>2008-01-30 20:38:51 +0000
commitce8d6c2409ca15f0fb5800b1c2c0a03e86683fc2 (patch)
treec3c6200b7442bab417b05ae90bdf08037c98dc83
parent5b9b4543616db4cefc5eb052287a32f03fdd8e85 (diff)
downloadlibtdevnc-ce8d6c2409ca15f0fb5800b1c2c0a03e86683fc2.tar.gz
libtdevnc-ce8d6c2409ca15f0fb5800b1c2c0a03e86683fc2.zip
Make ZYWRLE thread-safe for multiple clients
ZYWRLE used a static buffer, which does not work too well if you have more than one client in a threaded server. Instead, we have the data in the client structure now. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
-rw-r--r--libvncserver/zrle.c14
-rw-r--r--libvncserver/zrleencodetemplate.c18
-rw-r--r--rfb/rfb.h2
3 files changed, 17 insertions, 17 deletions
diff --git a/libvncserver/zrle.c b/libvncserver/zrle.c
index ae65061..2475fc0 100644
--- a/libvncserver/zrle.c
+++ b/libvncserver/zrle.c
@@ -96,6 +96,7 @@
* data.
*/
+/* TODO: put into rfbClient struct */
static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4];
@@ -114,17 +115,16 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
if (cl->preferredEncoding == rfbEncodingZYWRLE) {
if (cl->tightQualityLevel < 0) {
- zywrle_level = 1;
+ cl->zywrleLevel = 1;
} else if (cl->tightQualityLevel < 3) {
- zywrle_level = 3;
+ cl->zywrleLevel = 3;
} else if (cl->tightQualityLevel < 6) {
- zywrle_level = 2;
+ cl->zywrleLevel = 2;
} else {
- zywrle_level = 1;
+ cl->zywrleLevel = 1;
}
- } else {
- zywrle_level = 0;
- }
+ } else
+ cl->zywrleLevel = 0;
if (!cl->zrleData)
cl->zrleData = zrleOutStreamNew();
diff --git a/libvncserver/zrleencodetemplate.c b/libvncserver/zrleencodetemplate.c
index 7d19766..6e81b3c 100644
--- a/libvncserver/zrleencodetemplate.c
+++ b/libvncserver/zrleencodetemplate.c
@@ -84,14 +84,12 @@ static const int bitsPerPackedPixel[] = {
0, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
};
-int zywrle_level;
-int zywrleBuf[rfbZRLETileWidth*rfbZRLETileHeight];
-
static zrlePaletteHelper paletteHelper;
#endif /* ZRLE_ONCE */
-void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os);
+void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, zrleOutStream* os,
+ int zywrle_level, int *zywrleBuf);
#if BPP!=8
#define ZYWRLE_ENCODE
@@ -113,14 +111,16 @@ static void ZRLE_ENCODE (int x, int y, int w, int h,
GET_IMAGE_INTO_BUF(tx,ty,tw,th,buf);
- ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, os);
+ ZRLE_ENCODE_TILE((PIXEL_T*)buf, tw, th, os,
+ cl->zywrleLevel, cl->zywrleBuf);
}
}
zrleOutStreamFlush(os);
}
-void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os)
+void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os,
+ int zywrle_level, int *zywrleBuf)
{
/* First find the palette and the number of runs */
@@ -288,10 +288,8 @@ void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os)
#if BPP!=8
if (zywrle_level > 0 && !(zywrle_level & 0x80)) {
- ZYWRLE_ANALYZE( data, data, w, h, w, zywrle_level, zywrleBuf );
- zywrle_level |= 0x80;
- ZRLE_ENCODE_TILE( data, w, h, os );
- zywrle_level &= 0x7F;
+ ZYWRLE_ANALYZE(data, data, w, h, w, zywrle_level, zywrleBuf);
+ ZRLE_ENCODE_TILE(data, w, h, os, zywrle_level | 0x80, zywrleBuf);
}
else
#endif
diff --git a/rfb/rfb.h b/rfb/rfb.h
index 0dad2b9..aed454c 100644
--- a/rfb/rfb.h
+++ b/rfb/rfb.h
@@ -579,6 +579,8 @@ typedef struct _rfbClientRec {
#ifdef LIBVNCSERVER_HAVE_LIBZ
void* zrleData;
+ int zywrleLevel;
+ int zywrleBuf[rfbZRLETileWidth * rfbZRLETileHeight];
#endif
/* if progressive updating is on, this variable holds the current