diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-01-31 12:37:32 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-07-07 14:50:28 +0200 |
commit | 668468b3d43d5ea1562ebc0be8de0c98c5601a60 (patch) | |
tree | 80bbb90fb5f00335a7e85c297eadd40b0780dc92 /common | |
parent | fdba3fe884d5b43e07d7d49033c83f2f11bf524c (diff) | |
download | tigervnc-668468b3d43d5ea1562ebc0be8de0c98c5601a60.tar.gz tigervnc-668468b3d43d5ea1562ebc0be8de0c98c5601a60.zip |
Encoders/decoders should track the connection object
The connection object is a much more appropriate object for the
decoders and encoders to keep track of. Besides the streams, it also
contains state like connection parameters.
Diffstat (limited to 'common')
34 files changed, 102 insertions, 109 deletions
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx index 37612ea3..04846ef4 100644 --- a/common/rfb/CMsgReader.cxx +++ b/common/rfb/CMsgReader.cxx @@ -262,8 +262,3 @@ rdr::U8* CMsgReader::getImageBuf(int required, int requested, int* nPixels) *nPixels = imageBufSize / (handler->cp.pf().bpp / 8); return imageBuf; } - -int CMsgReader::bpp() -{ - return handler->cp.pf().bpp; -} diff --git a/common/rfb/CMsgReader.h b/common/rfb/CMsgReader.h index 97b57ce7..3592ef87 100644 --- a/common/rfb/CMsgReader.h +++ b/common/rfb/CMsgReader.h @@ -47,7 +47,6 @@ namespace rfb { rdr::InStream* getInStream() { return is; } rdr::U8* getImageBuf(int required, int requested=0, int* nPixels=0); - int bpp(); int imageBufIdealSize; diff --git a/common/rfb/CMsgWriter.h b/common/rfb/CMsgWriter.h index fb18cdf7..06ecbe7d 100644 --- a/common/rfb/CMsgWriter.h +++ b/common/rfb/CMsgWriter.h @@ -53,9 +53,6 @@ namespace rfb { void writeFence(rdr::U32 flags, unsigned len, const char data[]); - ConnParams* getConnParams() { return cp; } - rdr::OutStream* getOutStream() { return os; } - // InputHandler implementation virtual void keyEvent(rdr::U32 key, bool down); diff --git a/common/rfb/CopyRectDecoder.cxx b/common/rfb/CopyRectDecoder.cxx index 4c835832..bb3084fd 100644 --- a/common/rfb/CopyRectDecoder.cxx +++ b/common/rfb/CopyRectDecoder.cxx @@ -16,14 +16,14 @@ * USA. */ #include <rdr/InStream.h> -#include <rfb/CMsgReader.h> +#include <rfb/CConnection.h> #include <rfb/CMsgHandler.h> #include <rfb/PixelBuffer.h> #include <rfb/CopyRectDecoder.h> using namespace rfb; -CopyRectDecoder::CopyRectDecoder(CMsgReader* reader) : Decoder(reader) +CopyRectDecoder::CopyRectDecoder(CConnection* conn) : Decoder(conn) { } @@ -33,7 +33,7 @@ CopyRectDecoder::~CopyRectDecoder() void CopyRectDecoder::readRect(const Rect& r, CMsgHandler* handler) { - int srcX = reader->getInStream()->readU16(); - int srcY = reader->getInStream()->readU16(); + int srcX = conn->getInStream()->readU16(); + int srcY = conn->getInStream()->readU16(); handler->copyRect(r, srcX, srcY); } diff --git a/common/rfb/CopyRectDecoder.h b/common/rfb/CopyRectDecoder.h index e265ee42..5932066b 100644 --- a/common/rfb/CopyRectDecoder.h +++ b/common/rfb/CopyRectDecoder.h @@ -24,7 +24,7 @@ namespace rfb { class CopyRectDecoder : public Decoder { public: - CopyRectDecoder(CMsgReader* reader); + CopyRectDecoder(CConnection* conn); virtual ~CopyRectDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); }; diff --git a/common/rfb/Decoder.cxx b/common/rfb/Decoder.cxx index f774f28c..3faa9753 100644 --- a/common/rfb/Decoder.cxx +++ b/common/rfb/Decoder.cxx @@ -28,7 +28,7 @@ using namespace rfb; -Decoder::Decoder(CMsgReader* reader_) : reader(reader_) +Decoder::Decoder(CConnection* conn_) : conn(conn_) { } @@ -51,21 +51,21 @@ bool Decoder::supported(int encoding) } } -Decoder* Decoder::createDecoder(int encoding, CMsgReader* reader) +Decoder* Decoder::createDecoder(int encoding, CConnection* conn) { switch (encoding) { case encodingRaw: - return new RawDecoder(reader); + return new RawDecoder(conn); case encodingCopyRect: - return new CopyRectDecoder(reader); + return new CopyRectDecoder(conn); case encodingRRE: - return new RREDecoder(reader); + return new RREDecoder(conn); case encodingHextile: - return new HextileDecoder(reader); + return new HextileDecoder(conn); case encodingZRLE: - return new ZRLEDecoder(reader); + return new ZRLEDecoder(conn); case encodingTight: - return new TightDecoder(reader); + return new TightDecoder(conn); default: return NULL; } diff --git a/common/rfb/Decoder.h b/common/rfb/Decoder.h index 842491fb..870fa80e 100644 --- a/common/rfb/Decoder.h +++ b/common/rfb/Decoder.h @@ -22,19 +22,19 @@ #include <rfb/Rect.h> namespace rfb { - class CMsgReader; + class CConnection; class CMsgHandler; class Decoder { public: - Decoder(CMsgReader* reader); + Decoder(CConnection* conn); virtual ~Decoder(); virtual void readRect(const Rect& r, CMsgHandler* handler)=0; static bool supported(int encoding); - static Decoder* createDecoder(int encoding, CMsgReader* reader); + static Decoder* createDecoder(int encoding, CConnection* conn); protected: - CMsgReader* reader; + CConnection* conn; }; } diff --git a/common/rfb/Encoder.cxx b/common/rfb/Encoder.cxx index 6b2321c4..89a5f149 100644 --- a/common/rfb/Encoder.cxx +++ b/common/rfb/Encoder.cxx @@ -25,11 +25,11 @@ #include <rfb/HextileEncoder.h> #include <rfb/ZRLEEncoder.h> #include <rfb/TightEncoder.h> -#include <rfb/SMsgWriter.h> +#include <rfb/SConnection.h> using namespace rfb; -Encoder::Encoder(SMsgWriter* writer_) : writer(writer_) +Encoder::Encoder(SConnection *conn_) : conn(conn_) { } @@ -51,19 +51,19 @@ bool Encoder::supported(int encoding) } } -Encoder* Encoder::createEncoder(int encoding, SMsgWriter* writer) +Encoder* Encoder::createEncoder(int encoding, SConnection* conn) { switch (encoding) { case encodingRaw: - return new RawEncoder(writer); + return new RawEncoder(conn); case encodingRRE: - return new RREEncoder(writer); + return new RREEncoder(conn); case encodingHextile: - return new HextileEncoder(writer); + return new HextileEncoder(conn); case encodingZRLE: - return new ZRLEEncoder(writer); + return new ZRLEEncoder(conn); case encodingTight: - return new TightEncoder(writer); + return new TightEncoder(conn); default: return NULL; } diff --git a/common/rfb/Encoder.h b/common/rfb/Encoder.h index 485b850c..2897f9f8 100644 --- a/common/rfb/Encoder.h +++ b/common/rfb/Encoder.h @@ -24,12 +24,12 @@ #include <rfb/TransImageGetter.h> namespace rfb { - class SMsgWriter; + class SConnection; class TransImageGetter; class Encoder { public: - Encoder(SMsgWriter* writer); + Encoder(SConnection* conn); virtual ~Encoder(); virtual void setCompressLevel(int level) {}; @@ -43,10 +43,10 @@ namespace rfb { virtual void writeRect(const Rect& r, TransImageGetter* ig)=0; static bool supported(int encoding); - static Encoder* createEncoder(int encoding, SMsgWriter* writer); + static Encoder* createEncoder(int encoding, SConnection* conn); protected: - SMsgWriter* writer; + SConnection* conn; }; } diff --git a/common/rfb/HextileDecoder.cxx b/common/rfb/HextileDecoder.cxx index dbf75c94..9b335fe9 100644 --- a/common/rfb/HextileDecoder.cxx +++ b/common/rfb/HextileDecoder.cxx @@ -16,6 +16,7 @@ * USA. */ #include <rfb/CMsgReader.h> +#include <rfb/CConnection.h> #include <rfb/CMsgHandler.h> #include <rfb/HextileDecoder.h> @@ -31,7 +32,7 @@ using namespace rfb; #include <rfb/hextileDecode.h> #undef BPP -HextileDecoder::HextileDecoder(CMsgReader* reader) : Decoder(reader) +HextileDecoder::HextileDecoder(CConnection* conn) : Decoder(conn) { } @@ -41,9 +42,9 @@ HextileDecoder::~HextileDecoder() void HextileDecoder::readRect(const Rect& r, CMsgHandler* handler) { - rdr::InStream* is = reader->getInStream(); - rdr::U8* buf = reader->getImageBuf(16 * 16 * 4); - switch (reader->bpp()) { + rdr::InStream* is = conn->getInStream(); + rdr::U8* buf = conn->reader()->getImageBuf(16 * 16 * 4); + switch (conn->cp.pf().bpp) { case 8: hextileDecode8 (r, is, (rdr::U8*) buf, handler); break; case 16: hextileDecode16(r, is, (rdr::U16*)buf, handler); break; case 32: hextileDecode32(r, is, (rdr::U32*)buf, handler); break; diff --git a/common/rfb/HextileDecoder.h b/common/rfb/HextileDecoder.h index 287b49d5..67dc791a 100644 --- a/common/rfb/HextileDecoder.h +++ b/common/rfb/HextileDecoder.h @@ -24,7 +24,7 @@ namespace rfb { class HextileDecoder : public Decoder { public: - HextileDecoder(CMsgReader* reader); + HextileDecoder(CConnection* conn); virtual ~HextileDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); }; diff --git a/common/rfb/HextileEncoder.cxx b/common/rfb/HextileEncoder.cxx index 69b522f8..aa1b218a 100644 --- a/common/rfb/HextileEncoder.cxx +++ b/common/rfb/HextileEncoder.cxx @@ -19,6 +19,7 @@ #include <rfb/TransImageGetter.h> #include <rfb/encodings.h> #include <rfb/SMsgWriter.h> +#include <rfb/SConnection.h> #include <rfb/HextileEncoder.h> #include <rfb/Configuration.h> @@ -43,7 +44,7 @@ BoolParameter improvedHextile("ImprovedHextile", #include <rfb/hextileEncodeBetter.h> #undef BPP -HextileEncoder::HextileEncoder(SMsgWriter* writer_) : Encoder(writer_) +HextileEncoder::HextileEncoder(SConnection* conn) : Encoder(conn) { } @@ -53,9 +54,9 @@ HextileEncoder::~HextileEncoder() void HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig) { - writer->startRect(r, encodingHextile); - rdr::OutStream* os = writer->getOutStream(); - switch (writer->bpp()) { + conn->writer()->startRect(r, encodingHextile); + rdr::OutStream* os = conn->getOutStream(); + switch (conn->cp.pf().bpp) { case 8: if (improvedHextile) { hextileEncodeBetter8(r, os, ig); @@ -78,5 +79,5 @@ void HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig) } break; } - writer->endRect(); + conn->writer()->endRect(); } diff --git a/common/rfb/HextileEncoder.h b/common/rfb/HextileEncoder.h index 705cbc6f..723f5391 100644 --- a/common/rfb/HextileEncoder.h +++ b/common/rfb/HextileEncoder.h @@ -24,7 +24,7 @@ namespace rfb { class HextileEncoder : public Encoder { public: - HextileEncoder(SMsgWriter* writer); + HextileEncoder(SConnection* conn); virtual ~HextileEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); }; diff --git a/common/rfb/RREDecoder.cxx b/common/rfb/RREDecoder.cxx index b7808421..ecc97136 100644 --- a/common/rfb/RREDecoder.cxx +++ b/common/rfb/RREDecoder.cxx @@ -16,6 +16,7 @@ * USA. */ #include <rfb/CMsgReader.h> +#include <rfb/CConnection.h> #include <rfb/CMsgHandler.h> #include <rfb/RREDecoder.h> @@ -31,7 +32,7 @@ using namespace rfb; #include <rfb/rreDecode.h> #undef BPP -RREDecoder::RREDecoder(CMsgReader* reader) : Decoder(reader) +RREDecoder::RREDecoder(CConnection* conn) : Decoder(conn) { } @@ -41,8 +42,8 @@ RREDecoder::~RREDecoder() void RREDecoder::readRect(const Rect& r, CMsgHandler* handler) { - rdr::InStream* is = reader->getInStream(); - switch (reader->bpp()) { + rdr::InStream* is = conn->getInStream(); + switch (conn->cp.pf().bpp) { case 8: rreDecode8 (r, is, handler); break; case 16: rreDecode16(r, is, handler); break; case 32: rreDecode32(r, is, handler); break; diff --git a/common/rfb/RREDecoder.h b/common/rfb/RREDecoder.h index bee634fb..7b6cc458 100644 --- a/common/rfb/RREDecoder.h +++ b/common/rfb/RREDecoder.h @@ -24,7 +24,7 @@ namespace rfb { class RREDecoder : public Decoder { public: - RREDecoder(CMsgReader* reader); + RREDecoder(CConnection* conn); virtual ~RREDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); }; diff --git a/common/rfb/RREEncoder.cxx b/common/rfb/RREEncoder.cxx index dc2d74ed..a7af25db 100644 --- a/common/rfb/RREEncoder.cxx +++ b/common/rfb/RREEncoder.cxx @@ -19,6 +19,7 @@ #include <rfb/TransImageGetter.h> #include <rfb/encodings.h> #include <rfb/SMsgWriter.h> +#include <rfb/SConnection.h> #include <rfb/RREEncoder.h> using namespace rfb; @@ -33,7 +34,7 @@ using namespace rfb; #include <rfb/rreEncode.h> #undef BPP -RREEncoder::RREEncoder(SMsgWriter* writer) : RawEncoder(writer) +RREEncoder::RREEncoder(SConnection* conn) : RawEncoder(conn) { } @@ -45,13 +46,13 @@ void RREEncoder::writeRect(const Rect& r, TransImageGetter* ig) { int w = r.width(); int h = r.height(); - rdr::U8* imageBuf = writer->getImageBuf(w*h); + rdr::U8* imageBuf = conn->writer()->getImageBuf(w*h); ig->getImage(imageBuf, r); mos.clear(); int nSubrects = -1; - switch (writer->bpp()) { + switch (conn->cp.pf().bpp) { case 8: nSubrects = rreEncode8(imageBuf, w, h, &mos); break; case 16: nSubrects = rreEncode16(imageBuf, w, h, &mos); break; case 32: nSubrects = rreEncode32(imageBuf, w, h, &mos); break; @@ -62,9 +63,9 @@ void RREEncoder::writeRect(const Rect& r, TransImageGetter* ig) return; } - writer->startRect(r, encodingRRE); - rdr::OutStream* os = writer->getOutStream(); + conn->writer()->startRect(r, encodingRRE); + rdr::OutStream* os = conn->getOutStream(); os->writeU32(nSubrects); os->writeBytes(mos.data(), mos.length()); - writer->endRect(); + conn->writer()->endRect(); } diff --git a/common/rfb/RREEncoder.h b/common/rfb/RREEncoder.h index b263967e..487344f2 100644 --- a/common/rfb/RREEncoder.h +++ b/common/rfb/RREEncoder.h @@ -25,7 +25,7 @@ namespace rfb { class RREEncoder : public RawEncoder { public: - RREEncoder(SMsgWriter* writer); + RREEncoder(SConnection* conn); virtual ~RREEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); private: diff --git a/common/rfb/RawDecoder.cxx b/common/rfb/RawDecoder.cxx index eab92e53..6ca02026 100644 --- a/common/rfb/RawDecoder.cxx +++ b/common/rfb/RawDecoder.cxx @@ -17,12 +17,13 @@ */ #include <rdr/InStream.h> #include <rfb/CMsgReader.h> +#include <rfb/CConnection.h> #include <rfb/CMsgHandler.h> #include <rfb/RawDecoder.h> using namespace rfb; -RawDecoder::RawDecoder(CMsgReader* reader) : Decoder(reader) +RawDecoder::RawDecoder(CConnection* conn) : Decoder(conn) { } @@ -37,12 +38,12 @@ void RawDecoder::readRect(const Rect& r, CMsgHandler* handler) int w = r.width(); int h = r.height(); int nPixels; - rdr::U8* imageBuf = reader->getImageBuf(w, w*h, &nPixels); - int bytesPerRow = w * (reader->bpp() / 8); + rdr::U8* imageBuf = conn->reader()->getImageBuf(w, w*h, &nPixels); + int bytesPerRow = w * (conn->cp.pf().bpp / 8); while (h > 0) { int nRows = nPixels / w; if (nRows > h) nRows = h; - reader->getInStream()->readBytes(imageBuf, nRows * bytesPerRow); + conn->getInStream()->readBytes(imageBuf, nRows * bytesPerRow); handler->imageRect(Rect(x, y, x+w, y+nRows), imageBuf); h -= nRows; y += nRows; diff --git a/common/rfb/RawDecoder.h b/common/rfb/RawDecoder.h index 9d0dc300..ca7c4017 100644 --- a/common/rfb/RawDecoder.h +++ b/common/rfb/RawDecoder.h @@ -24,7 +24,7 @@ namespace rfb { class RawDecoder : public Decoder { public: - RawDecoder(CMsgReader* reader); + RawDecoder(CConnection* conn); virtual ~RawDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); }; diff --git a/common/rfb/RawEncoder.cxx b/common/rfb/RawEncoder.cxx index 2fc5741c..f7a4f3b8 100644 --- a/common/rfb/RawEncoder.cxx +++ b/common/rfb/RawEncoder.cxx @@ -19,11 +19,12 @@ #include <rfb/TransImageGetter.h> #include <rfb/encodings.h> #include <rfb/SMsgWriter.h> +#include <rfb/SConnection.h> #include <rfb/RawEncoder.h> using namespace rfb; -RawEncoder::RawEncoder(SMsgWriter* writer) : Encoder(writer) +RawEncoder::RawEncoder(SConnection* conn) : Encoder(conn) { } @@ -38,16 +39,16 @@ void RawEncoder::writeRect(const Rect& r, TransImageGetter* ig) int w = r.width(); int h = r.height(); int nPixels; - rdr::U8* imageBuf = writer->getImageBuf(w, w*h, &nPixels); - int bytesPerRow = w * (writer->bpp() / 8); - writer->startRect(r, encodingRaw); + rdr::U8* imageBuf = conn->writer()->getImageBuf(w, w*h, &nPixels); + int bytesPerRow = w * (conn->cp.pf().bpp / 8); + conn->writer()->startRect(r, encodingRaw); while (h > 0) { int nRows = nPixels / w; if (nRows > h) nRows = h; ig->getImage(imageBuf, Rect(x, y, x+w, y+nRows)); - writer->getOutStream()->writeBytes(imageBuf, nRows * bytesPerRow); + conn->getOutStream()->writeBytes(imageBuf, nRows * bytesPerRow); h -= nRows; y += nRows; } - writer->endRect(); + conn->writer()->endRect(); } diff --git a/common/rfb/RawEncoder.h b/common/rfb/RawEncoder.h index 42d38508..59e3a6de 100644 --- a/common/rfb/RawEncoder.h +++ b/common/rfb/RawEncoder.h @@ -24,7 +24,7 @@ namespace rfb { class RawEncoder : public Encoder { public: - RawEncoder(SMsgWriter* writer); + RawEncoder(SConnection* conn); virtual ~RawEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); }; diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx index 67590fe6..40e6d7f6 100644 --- a/common/rfb/SMsgWriter.cxx +++ b/common/rfb/SMsgWriter.cxx @@ -320,7 +320,7 @@ void SMsgWriter::startRect(const Rect& r, int encoding) currentEncoding = encoding; lenBeforeRect = os->length(); if (encoding != encodingCopyRect) - rawBytesEquivalent += 12 + r.width() * r.height() * (bpp()/8); + rawBytesEquivalent += 12 + r.width() * r.height() * (cp->pf().bpp/8); os->writeS16(r.tl.x); os->writeS16(r.tl.y); @@ -357,11 +357,6 @@ rdr::U8* SMsgWriter::getImageBuf(int required, int requested, int* nPixels) return imageBuf; } -int SMsgWriter::bpp() -{ - return cp->pf().bpp; -} - void SMsgWriter::startMsg(int type) { os->writeU8(type); diff --git a/common/rfb/SMsgWriter.h b/common/rfb/SMsgWriter.h index ccc8f803..c3ee4577 100644 --- a/common/rfb/SMsgWriter.h +++ b/common/rfb/SMsgWriter.h @@ -120,10 +120,7 @@ namespace rfb { void startRect(const Rect& r, int enc); void endRect(); - ConnParams* getConnParams() { return cp; } - rdr::OutStream* getOutStream() { return os; } rdr::U8* getImageBuf(int required, int requested=0, int* nPixels=0); - int bpp(); int getUpdatesSent() { return updatesSent; } int getRectsSent(int encoding) { return rectsSent[encoding]; } diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx index a317d250..bfc3352b 100644 --- a/common/rfb/TightDecoder.cxx +++ b/common/rfb/TightDecoder.cxx @@ -18,6 +18,7 @@ * USA. */ #include <rfb/CMsgReader.h> +#include <rfb/CConnection.h> #include <rfb/CMsgHandler.h> #include <rfb/TightDecoder.h> @@ -35,7 +36,7 @@ using namespace rfb; #include <rfb/tightDecode.h> #undef BPP -TightDecoder::TightDecoder(CMsgReader* reader) : Decoder(reader) +TightDecoder::TightDecoder(CConnection* conn) : Decoder(conn) { } @@ -45,7 +46,7 @@ TightDecoder::~TightDecoder() void TightDecoder::readRect(const Rect& r, CMsgHandler* handler) { - is = reader->getInStream(); + is = conn->getInStream(); this->handler = handler; clientpf = handler->getPreferredPF(); serverpf = handler->cp.pf(); diff --git a/common/rfb/TightDecoder.h b/common/rfb/TightDecoder.h index 18b01f8a..2ca4ecd6 100644 --- a/common/rfb/TightDecoder.h +++ b/common/rfb/TightDecoder.h @@ -28,7 +28,7 @@ namespace rfb { class TightDecoder : public Decoder { public: - TightDecoder(CMsgReader* reader); + TightDecoder(CConnection* conn); virtual ~TightDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx index 800d3316..c3f87dab 100644 --- a/common/rfb/TightEncoder.cxx +++ b/common/rfb/TightEncoder.cxx @@ -22,6 +22,7 @@ #include <rfb/encodings.h> #include <rfb/ConnParams.h> #include <rfb/SMsgWriter.h> +#include <rfb/SConnection.h> #include <rfb/TightEncoder.h> using namespace rfb; @@ -93,7 +94,7 @@ const int TightEncoder::defaultCompressLevel = 2; #include <rfb/tightEncode.h> #undef BPP -TightEncoder::TightEncoder(SMsgWriter* writer) : Encoder(writer) +TightEncoder::TightEncoder(SConnection* conn) : Encoder(conn) { setCompressLevel(defaultCompressLevel); setQualityLevel(-1); @@ -226,7 +227,7 @@ void TightEncoder::extendSolidArea(const Rect& r, rdr::U32 colorValue, int TightEncoder::getNumRects(const Rect &r) { - ConnParams* cp = writer->getConnParams(); + ConnParams* cp = &conn->cp; const unsigned int w = r.width(); const unsigned int h = r.height(); @@ -290,7 +291,7 @@ void TightEncoder::writeRect(const Rect& _r, TransImageGetter* _ig) { ig = _ig; serverpf = ig->getPixelBuffer()->getPF(); - ConnParams* cp = writer->getConnParams(); + ConnParams* cp = &conn->cp; clientpf = cp->pf(); // Shortcuts to rectangle coordinates and dimensions. @@ -405,10 +406,10 @@ void TightEncoder::writeSubrect(const Rect& r, bool forceSolid) tightEncode32(r, &mos, forceSolid); break; } - writer->startRect(r, encodingTight); - rdr::OutStream* os = writer->getOutStream(); + conn->writer()->startRect(r, encodingTight); + rdr::OutStream* os = conn->getOutStream(); os->writeBytes(mos.data(), mos.length()); - writer->endRect(); + conn->writer()->endRect(); } void TightEncoder::writeCompact(rdr::OutStream* os, rdr::U32 value) diff --git a/common/rfb/TightEncoder.h b/common/rfb/TightEncoder.h index b633512f..8a58985e 100644 --- a/common/rfb/TightEncoder.h +++ b/common/rfb/TightEncoder.h @@ -58,7 +58,7 @@ namespace rfb { class TightEncoder : public Encoder { public: - TightEncoder(SMsgWriter* writer); + TightEncoder(SConnection* conn); virtual ~TightEncoder(); virtual void setCompressLevel(int level); diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 0000c1ea..a4b704a4 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -1074,7 +1074,7 @@ void VNCSConnectionST::writeFramebufferUpdate() encoding = cp.currentEncoding(); if (!encoders[encoding]) - encoders[encoding] = Encoder::createEncoder(encoding, writer()); + encoders[encoding] = Encoder::createEncoder(encoding, this); encoders[encoding]->setCompressLevel(cp.compressLevel); encoders[encoding]->setQualityLevel(cp.qualityLevel); diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx index d4d3444d..7e933a8f 100644 --- a/common/rfb/ZRLEDecoder.cxx +++ b/common/rfb/ZRLEDecoder.cxx @@ -16,6 +16,7 @@ * USA. */ #include <rfb/CMsgReader.h> +#include <rfb/CConnection.h> #include <rfb/CMsgHandler.h> #include <rfb/ZRLEDecoder.h> @@ -57,7 +58,7 @@ static inline rdr::U32 readOpaque24B(rdr::InStream* is) #undef CPIXEL #undef BPP -ZRLEDecoder::ZRLEDecoder(CMsgReader* reader) : Decoder(reader) +ZRLEDecoder::ZRLEDecoder(CConnection* conn) : Decoder(conn) { } @@ -67,9 +68,9 @@ ZRLEDecoder::~ZRLEDecoder() void ZRLEDecoder::readRect(const Rect& r, CMsgHandler* handler) { - rdr::InStream* is = reader->getInStream(); - rdr::U8* buf = reader->getImageBuf(64 * 64 * 4); - switch (reader->bpp()) { + rdr::InStream* is = conn->getInStream(); + rdr::U8* buf = conn->reader()->getImageBuf(64 * 64 * 4); + switch (conn->cp.pf().bpp) { case 8: zrleDecode8 (r, is, &zis, (rdr::U8*) buf, handler); break; case 16: zrleDecode16(r, is, &zis, (rdr::U16*)buf, handler); break; case 32: diff --git a/common/rfb/ZRLEDecoder.h b/common/rfb/ZRLEDecoder.h index dee20685..e7e2b8cb 100644 --- a/common/rfb/ZRLEDecoder.h +++ b/common/rfb/ZRLEDecoder.h @@ -25,7 +25,7 @@ namespace rfb { class ZRLEDecoder : public Decoder { public: - ZRLEDecoder(CMsgReader* reader); + ZRLEDecoder(CConnection* conn); virtual ~ZRLEDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); private: diff --git a/common/rfb/ZRLEEncoder.cxx b/common/rfb/ZRLEEncoder.cxx index 5a65703d..968edcfb 100644 --- a/common/rfb/ZRLEEncoder.cxx +++ b/common/rfb/ZRLEEncoder.cxx @@ -21,6 +21,7 @@ #include <rfb/encodings.h> #include <rfb/ConnParams.h> #include <rfb/SMsgWriter.h> +#include <rfb/SConnection.h> #include <rfb/ZRLEEncoder.h> #include <rfb/Configuration.h> @@ -59,8 +60,8 @@ static inline void writeOpaque24B(rdr::OutStream* os, rdr::U32 u) #undef CPIXEL #undef BPP -ZRLEEncoder::ZRLEEncoder(SMsgWriter* writer) - : Encoder(writer), zos(0,0,zlibLevel), mos(129*1024) +ZRLEEncoder::ZRLEEncoder(SConnection* conn) + : Encoder(conn), zos(0,0,zlibLevel), mos(129*1024) { } @@ -70,10 +71,10 @@ ZRLEEncoder::~ZRLEEncoder() void ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig) { - rdr::U8* imageBuf = writer->getImageBuf(64 * 64 * 4 + 4); + rdr::U8* imageBuf = conn->writer()->getImageBuf(64 * 64 * 4 + 4); mos.clear(); - switch (writer->bpp()) { + switch (conn->cp.pf().bpp) { case 8: zrleEncode8(r, &mos, &zos, imageBuf, ig); break; @@ -82,7 +83,7 @@ void ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig) break; case 32: { - const PixelFormat& pf = writer->getConnParams()->pf(); + const PixelFormat& pf = conn->cp.pf(); Pixel maxPixel = pf.pixelFromRGB((rdr::U16)-1, (rdr::U16)-1, (rdr::U16)-1); bool fitsInLS3Bytes = maxPixel < (1<<24); @@ -106,9 +107,9 @@ void ZRLEEncoder::writeRect(const Rect& r, TransImageGetter* ig) } } - writer->startRect(r, encodingZRLE); - rdr::OutStream* os = writer->getOutStream(); + conn->writer()->startRect(r, encodingZRLE); + rdr::OutStream* os = conn->getOutStream(); os->writeU32(mos.length()); os->writeBytes(mos.data(), mos.length()); - writer->endRect(); + conn->writer()->endRect(); } diff --git a/common/rfb/ZRLEEncoder.h b/common/rfb/ZRLEEncoder.h index 9679887a..d285967e 100644 --- a/common/rfb/ZRLEEncoder.h +++ b/common/rfb/ZRLEEncoder.h @@ -26,7 +26,7 @@ namespace rfb { class ZRLEEncoder : public Encoder { public: - ZRLEEncoder(SMsgWriter* writer); + ZRLEEncoder(SConnection* conn); virtual ~ZRLEEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); private: diff --git a/common/rfb/tightDecode.h b/common/rfb/tightDecode.h index 1c7cf5e5..a5963119 100644 --- a/common/rfb/tightDecode.h +++ b/common/rfb/tightDecode.h @@ -154,7 +154,7 @@ void TIGHT_DECODE (const Rect& r) PIXEL_T *buf; int stride = r.width(); if (directDecode) buf = (PIXEL_T *)handler->getRawBufferRW(r, &stride); - else buf = (PIXEL_T *)reader->getImageBuf(r.area()); + else buf = (PIXEL_T *)conn->reader()->getImageBuf(r.area()); if (palSize == 0) { // Truecolor data diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h index 3f0647de..5d32cce3 100644 --- a/common/rfb/tightEncode.h +++ b/common/rfb/tightEncode.h @@ -147,14 +147,14 @@ void TIGHT_ENCODE (const Rect& r, rdr::OutStream *os, bool forceSolid) // JPEG can read from the raw buffer, but for the other methods, we need // to translate the raw pixels into an intermediate buffer. if(palette.size() != 0 || jpegQuality == -1) { - pixels = (PIXEL_T *)writer->getImageBuf(r.area()); + pixels = (PIXEL_T *)conn->writer()->getImageBuf(r.area()); stride = r.width(); ig->getImage(pixels, r); } } else { // Pixel translation will be required, so create an intermediate buffer, // translate the raw pixels into it, and count its colors. - pixels = (PIXEL_T *)writer->getImageBuf(r.area()); + pixels = (PIXEL_T *)conn->writer()->getImageBuf(r.area()); stride = r.width(); ig->getImage(pixels, r); |