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>
pull/1/head
dscho 17 years ago
parent 5b9b454361
commit ce8d6c2409

@ -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();

@ -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

@ -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

Loading…
Cancel
Save