Commit ce8d6c24 authored by dscho's avatar dscho

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: 's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
parent 5b9b4543
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
* data. * data.
*/ */
/* TODO: put into rfbClient struct */
static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4]; static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4];
...@@ -114,17 +115,16 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) ...@@ -114,17 +115,16 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h)
if (cl->preferredEncoding == rfbEncodingZYWRLE) { if (cl->preferredEncoding == rfbEncodingZYWRLE) {
if (cl->tightQualityLevel < 0) { if (cl->tightQualityLevel < 0) {
zywrle_level = 1; cl->zywrleLevel = 1;
} else if (cl->tightQualityLevel < 3) { } else if (cl->tightQualityLevel < 3) {
zywrle_level = 3; cl->zywrleLevel = 3;
} else if (cl->tightQualityLevel < 6) { } else if (cl->tightQualityLevel < 6) {
zywrle_level = 2; cl->zywrleLevel = 2;
} else { } else {
zywrle_level = 1; cl->zywrleLevel = 1;
}
} else {
zywrle_level = 0;
} }
} else
cl->zywrleLevel = 0;
if (!cl->zrleData) if (!cl->zrleData)
cl->zrleData = zrleOutStreamNew(); cl->zrleData = zrleOutStreamNew();
......
...@@ -84,14 +84,12 @@ static const int bitsPerPackedPixel[] = { ...@@ -84,14 +84,12 @@ static const int bitsPerPackedPixel[] = {
0, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 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; static zrlePaletteHelper paletteHelper;
#endif /* ZRLE_ONCE */ #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 #if BPP!=8
#define ZYWRLE_ENCODE #define ZYWRLE_ENCODE
...@@ -113,14 +111,16 @@ static void ZRLE_ENCODE (int x, int y, int w, int h, ...@@ -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); 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); 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 */ /* 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) ...@@ -288,10 +288,8 @@ void ZRLE_ENCODE_TILE(PIXEL_T* data, int w, int h, zrleOutStream* os)
#if BPP!=8 #if BPP!=8
if (zywrle_level > 0 && !(zywrle_level & 0x80)) { if (zywrle_level > 0 && !(zywrle_level & 0x80)) {
ZYWRLE_ANALYZE( data, data, w, h, w, zywrle_level, zywrleBuf ); ZYWRLE_ANALYZE(data, data, w, h, w, zywrle_level, zywrleBuf);
zywrle_level |= 0x80; ZRLE_ENCODE_TILE(data, w, h, os, zywrle_level | 0x80, zywrleBuf);
ZRLE_ENCODE_TILE( data, w, h, os );
zywrle_level &= 0x7F;
} }
else else
#endif #endif
......
...@@ -579,6 +579,8 @@ typedef struct _rfbClientRec { ...@@ -579,6 +579,8 @@ typedef struct _rfbClientRec {
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
void* zrleData; void* zrleData;
int zywrleLevel;
int zywrleBuf[rfbZRLETileWidth * rfbZRLETileHeight];
#endif #endif
/* if progressive updating is on, this variable holds the current /* if progressive updating is on, this variable holds the current
......
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