From: Pierre Ossman Date: Thu, 13 Mar 2014 14:08:36 +0000 (+0100) Subject: Get rid of unused things in the ZRLE encoder X-Git-Tag: v1.3.90~48^2~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4bca9119848fbafd15dd9dae715ad65162addec5;p=tigervnc.git Get rid of unused things in the ZRLE encoder Get rid of unused shared MemOutStream and variable max length functionality in the ZRLE encoder. --- diff --git a/common/rfb/ZRLEEncoder.cxx b/common/rfb/ZRLEEncoder.cxx index 896b83b5..5ef54d26 100644 --- a/common/rfb/ZRLEEncoder.cxx +++ b/common/rfb/ZRLEEncoder.cxx @@ -26,9 +26,6 @@ using namespace rfb; -rdr::MemOutStream* ZRLEEncoder::sharedMos = 0; -int ZRLEEncoder::maxLen = 4097 * 1024; // enough for width 16384 32-bit pixels - IntParameter zlibLevel("ZlibLevel","Zlib compression level",-1); #define EXTRA_ARGS ImageGetter* ig @@ -55,33 +52,27 @@ Encoder* ZRLEEncoder::create(SMsgWriter* writer) } ZRLEEncoder::ZRLEEncoder(SMsgWriter* writer_) - : writer(writer_), zos(0,0,zlibLevel) + : writer(writer_), zos(0,0,zlibLevel), mos(129*1024) { - if (sharedMos) - mos = sharedMos; - else - mos = new rdr::MemOutStream(129*1024); } ZRLEEncoder::~ZRLEEncoder() { - if (!sharedMos) - delete mos; } bool ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual) { rdr::U8* imageBuf = writer->getImageBuf(64 * 64 * 4 + 4); - mos->clear(); + mos.clear(); bool wroteAll = true; *actual = r; switch (writer->bpp()) { case 8: - wroteAll = zrleEncode8(r, mos, &zos, imageBuf, maxLen, actual, ig); + wroteAll = zrleEncode8(r, &mos, &zos, imageBuf, actual, ig); break; case 16: - wroteAll = zrleEncode16(r, mos, &zos, imageBuf, maxLen, actual, ig); + wroteAll = zrleEncode16(r, &mos, &zos, imageBuf, actual, ig); break; case 32: { @@ -94,16 +85,16 @@ bool ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual) if ((fitsInLS3Bytes && pf.isLittleEndian()) || (fitsInMS3Bytes && pf.isBigEndian())) { - wroteAll = zrleEncode24A(r, mos, &zos, imageBuf, maxLen, actual, ig); + wroteAll = zrleEncode24A(r, &mos, &zos, imageBuf, actual, ig); } else if ((fitsInLS3Bytes && pf.isBigEndian()) || (fitsInMS3Bytes && pf.isLittleEndian())) { - wroteAll = zrleEncode24B(r, mos, &zos, imageBuf, maxLen, actual, ig); + wroteAll = zrleEncode24B(r, &mos, &zos, imageBuf, actual, ig); } else { - wroteAll = zrleEncode32(r, mos, &zos, imageBuf, maxLen, actual, ig); + wroteAll = zrleEncode32(r, &mos, &zos, imageBuf, actual, ig); } break; } @@ -111,8 +102,8 @@ bool ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig, Rect* actual) writer->startRect(*actual, encodingZRLE); rdr::OutStream* os = writer->getOutStream(); - os->writeU32(mos->length()); - os->writeBytes(mos->data(), mos->length()); + os->writeU32(mos.length()); + os->writeBytes(mos.data(), mos.length()); writer->endRect(); return wroteAll; } diff --git a/common/rfb/ZRLEEncoder.h b/common/rfb/ZRLEEncoder.h index 3a0f52a9..61ff6fb0 100644 --- a/common/rfb/ZRLEEncoder.h +++ b/common/rfb/ZRLEEncoder.h @@ -30,25 +30,11 @@ namespace rfb { virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual); virtual ~ZRLEEncoder(); - // setMaxLen() sets the maximum size in bytes of any ZRLE rectangle. This - // can be used to stop the MemOutStream from growing too large. The value - // must be large enough to allow for at least one row of ZRLE tiles. So - // for example for a screen width of 2048 32-bit pixels this is 2K*4*64 = - // 512Kbytes plus a bit of overhead (the overhead is about 1/16 of the - // width, in this example about 128 bytes). - static void setMaxLen(int m) { maxLen = m; } - - // setSharedMos() sets a MemOutStream to be shared amongst all - // ZRLEEncoders. Should be called before any ZRLEEncoders are created. - static void setSharedMos(rdr::MemOutStream* mos_) { sharedMos = mos_; } - private: ZRLEEncoder(SMsgWriter* writer); SMsgWriter* writer; rdr::ZlibOutStream zos; - rdr::MemOutStream* mos; - static rdr::MemOutStream* sharedMos; - static int maxLen; + rdr::MemOutStream mos; }; } #endif diff --git a/common/rfb/zrleEncode.h b/common/rfb/zrleEncode.h index 9b7263b3..0c622b88 100644 --- a/common/rfb/zrleEncode.h +++ b/common/rfb/zrleEncode.h @@ -115,7 +115,7 @@ public: void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os); bool ZRLE_ENCODE (const Rect& r, rdr::OutStream* os, - rdr::ZlibOutStream* zos, void* buf, int maxLen, Rect* actual + rdr::ZlibOutStream* zos, void* buf, Rect* actual #ifdef EXTRA_ARGS , EXTRA_ARGS #endif @@ -132,7 +132,8 @@ bool ZRLE_ENCODE (const Rect& r, rdr::OutStream* os, t.br.y = __rfbmin(r.br.y, t.tl.y + 64); - if (os->length() + worstCaseLine > maxLen) { + // enough for width 16384 32-bit pixels + if (os->length() + worstCaseLine > 4097 * 1024) { if (t.tl.y == r.tl.y) throw Exception("ZRLE: not enough space for first line?"); actual->tl = r.tl;