From: Pierre Ossman Date: Wed, 29 Jan 2014 15:42:48 +0000 (+0100) Subject: Avoid reader/writer duplication in every encoder/decoder X-Git-Tag: v1.3.90~45^2~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4aba19e287b0105bb47777762ce14b3786d91019;p=tigervnc.git Avoid reader/writer duplication in every encoder/decoder --- diff --git a/common/rfb/Decoder.cxx b/common/rfb/Decoder.cxx index e201821f..9982c932 100644 --- a/common/rfb/Decoder.cxx +++ b/common/rfb/Decoder.cxx @@ -27,6 +27,10 @@ using namespace rfb; +Decoder::Decoder(CMsgReader* reader_) : reader(reader_) +{ +} + Decoder::~Decoder() { } diff --git a/common/rfb/Decoder.h b/common/rfb/Decoder.h index 025d63f5..842491fb 100644 --- a/common/rfb/Decoder.h +++ b/common/rfb/Decoder.h @@ -27,11 +27,14 @@ namespace rfb { class Decoder { public: + Decoder(CMsgReader* reader); virtual ~Decoder(); virtual void readRect(const Rect& r, CMsgHandler* handler)=0; static bool supported(int encoding); static Decoder* createDecoder(int encoding, CMsgReader* reader); + protected: + CMsgReader* reader; }; } diff --git a/common/rfb/Encoder.cxx b/common/rfb/Encoder.cxx index 1733c8ec..6b2321c4 100644 --- a/common/rfb/Encoder.cxx +++ b/common/rfb/Encoder.cxx @@ -25,9 +25,14 @@ #include #include #include +#include using namespace rfb; +Encoder::Encoder(SMsgWriter* writer_) : writer(writer_) +{ +} + Encoder::~Encoder() { } diff --git a/common/rfb/Encoder.h b/common/rfb/Encoder.h index 8712c09a..485b850c 100644 --- a/common/rfb/Encoder.h +++ b/common/rfb/Encoder.h @@ -29,6 +29,7 @@ namespace rfb { class Encoder { public: + Encoder(SMsgWriter* writer); virtual ~Encoder(); virtual void setCompressLevel(int level) {}; @@ -43,6 +44,9 @@ namespace rfb { static bool supported(int encoding); static Encoder* createEncoder(int encoding, SMsgWriter* writer); + + protected: + SMsgWriter* writer; }; } diff --git a/common/rfb/HextileDecoder.cxx b/common/rfb/HextileDecoder.cxx index ae612676..04ef956b 100644 --- a/common/rfb/HextileDecoder.cxx +++ b/common/rfb/HextileDecoder.cxx @@ -34,7 +34,7 @@ using namespace rfb; #include #undef BPP -HextileDecoder::HextileDecoder(CMsgReader* reader_) : reader(reader_) +HextileDecoder::HextileDecoder(CMsgReader* reader) : Decoder(reader) { } diff --git a/common/rfb/HextileDecoder.h b/common/rfb/HextileDecoder.h index 95a7f8a4..287b49d5 100644 --- a/common/rfb/HextileDecoder.h +++ b/common/rfb/HextileDecoder.h @@ -27,8 +27,6 @@ namespace rfb { HextileDecoder(CMsgReader* reader); virtual ~HextileDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); - private: - CMsgReader* reader; }; } #endif diff --git a/common/rfb/HextileEncoder.cxx b/common/rfb/HextileEncoder.cxx index 19fb1a3e..c31e608c 100644 --- a/common/rfb/HextileEncoder.cxx +++ b/common/rfb/HextileEncoder.cxx @@ -45,7 +45,7 @@ BoolParameter improvedHextile("ImprovedHextile", #include #undef BPP -HextileEncoder::HextileEncoder(SMsgWriter* writer_) : writer(writer_) +HextileEncoder::HextileEncoder(SMsgWriter* writer_) : Encoder(writer_) { } diff --git a/common/rfb/HextileEncoder.h b/common/rfb/HextileEncoder.h index 5540c642..705cbc6f 100644 --- a/common/rfb/HextileEncoder.h +++ b/common/rfb/HextileEncoder.h @@ -27,8 +27,6 @@ namespace rfb { HextileEncoder(SMsgWriter* writer); virtual ~HextileEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); - private: - SMsgWriter* writer; }; } #endif diff --git a/common/rfb/RREDecoder.cxx b/common/rfb/RREDecoder.cxx index b81a4a82..97d7a71d 100644 --- a/common/rfb/RREDecoder.cxx +++ b/common/rfb/RREDecoder.cxx @@ -34,7 +34,7 @@ using namespace rfb; #include #undef BPP -RREDecoder::RREDecoder(CMsgReader* reader_) : reader(reader_) +RREDecoder::RREDecoder(CMsgReader* reader) : Decoder(reader) { } diff --git a/common/rfb/RREDecoder.h b/common/rfb/RREDecoder.h index 98abf982..bee634fb 100644 --- a/common/rfb/RREDecoder.h +++ b/common/rfb/RREDecoder.h @@ -27,8 +27,6 @@ namespace rfb { RREDecoder(CMsgReader* reader); virtual ~RREDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); - private: - CMsgReader* reader; }; } #endif diff --git a/common/rfb/RREEncoder.cxx b/common/rfb/RREEncoder.cxx index 09702cf7..b37b7588 100644 --- a/common/rfb/RREEncoder.cxx +++ b/common/rfb/RREEncoder.cxx @@ -33,7 +33,7 @@ using namespace rfb; #include #undef BPP -RREEncoder::RREEncoder(SMsgWriter* writer_) : writer(writer_) +RREEncoder::RREEncoder(SMsgWriter* writer) : Encoder(writer) { } diff --git a/common/rfb/RREEncoder.h b/common/rfb/RREEncoder.h index 4b990f5b..c5e65569 100644 --- a/common/rfb/RREEncoder.h +++ b/common/rfb/RREEncoder.h @@ -29,7 +29,6 @@ namespace rfb { virtual ~RREEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); private: - SMsgWriter* writer; rdr::MemOutStream mos; }; } diff --git a/common/rfb/RawDecoder.cxx b/common/rfb/RawDecoder.cxx index 5fd3b7c1..eab92e53 100644 --- a/common/rfb/RawDecoder.cxx +++ b/common/rfb/RawDecoder.cxx @@ -22,7 +22,7 @@ using namespace rfb; -RawDecoder::RawDecoder(CMsgReader* reader_) : reader(reader_) +RawDecoder::RawDecoder(CMsgReader* reader) : Decoder(reader) { } diff --git a/common/rfb/RawDecoder.h b/common/rfb/RawDecoder.h index e09cca2d..9d0dc300 100644 --- a/common/rfb/RawDecoder.h +++ b/common/rfb/RawDecoder.h @@ -27,8 +27,6 @@ namespace rfb { RawDecoder(CMsgReader* reader); virtual ~RawDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); - private: - CMsgReader* reader; }; } #endif diff --git a/common/rfb/RawEncoder.cxx b/common/rfb/RawEncoder.cxx index b4e38dbf..2fc5741c 100644 --- a/common/rfb/RawEncoder.cxx +++ b/common/rfb/RawEncoder.cxx @@ -23,7 +23,7 @@ using namespace rfb; -RawEncoder::RawEncoder(SMsgWriter* writer_) : writer(writer_) +RawEncoder::RawEncoder(SMsgWriter* writer) : Encoder(writer) { } diff --git a/common/rfb/RawEncoder.h b/common/rfb/RawEncoder.h index 628f32fd..42d38508 100644 --- a/common/rfb/RawEncoder.h +++ b/common/rfb/RawEncoder.h @@ -27,8 +27,6 @@ namespace rfb { RawEncoder(SMsgWriter* writer); virtual ~RawEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); - private: - SMsgWriter* writer; }; } #endif diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx index d4ee877f..83e84f70 100644 --- a/common/rfb/TightDecoder.cxx +++ b/common/rfb/TightDecoder.cxx @@ -37,7 +37,7 @@ using namespace rfb; #include #undef BPP -TightDecoder::TightDecoder(CMsgReader* reader_) : reader(reader_) +TightDecoder::TightDecoder(CMsgReader* reader) : Decoder(reader) { } diff --git a/common/rfb/TightDecoder.h b/common/rfb/TightDecoder.h index 8200d2b8..0b915f92 100644 --- a/common/rfb/TightDecoder.h +++ b/common/rfb/TightDecoder.h @@ -54,7 +54,6 @@ namespace rfb { void directFillRect16(const Rect& r, Pixel pix); void directFillRect32(const Rect& r, Pixel pix); - CMsgReader* reader; CMsgHandler* handler; rdr::InStream* is; rdr::ZlibInStream zis[4]; diff --git a/common/rfb/TightEncoder.cxx b/common/rfb/TightEncoder.cxx index f4633f88..622dc3d4 100644 --- a/common/rfb/TightEncoder.cxx +++ b/common/rfb/TightEncoder.cxx @@ -93,7 +93,7 @@ const int TightEncoder::defaultCompressLevel = 2; #include #undef BPP -TightEncoder::TightEncoder(SMsgWriter* writer_) : writer(writer_) +TightEncoder::TightEncoder(SMsgWriter* writer) : Encoder(writer) { setCompressLevel(defaultCompressLevel); setQualityLevel(-1); diff --git a/common/rfb/TightEncoder.h b/common/rfb/TightEncoder.h index a499783d..e2fa96e8 100644 --- a/common/rfb/TightEncoder.h +++ b/common/rfb/TightEncoder.h @@ -142,7 +142,6 @@ namespace rfb { void encodeJpegRect32(rdr::U32 *buf, int stride, const Rect& r, rdr::OutStream *os); - SMsgWriter* writer; rdr::MemOutStream mos; rdr::ZlibOutStream zos[4]; JpegCompressor jc; diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx index 111e2de6..20fe853c 100644 --- a/common/rfb/ZRLEDecoder.cxx +++ b/common/rfb/ZRLEDecoder.cxx @@ -40,7 +40,7 @@ using namespace rfb; #undef CPIXEL #undef BPP -ZRLEDecoder::ZRLEDecoder(CMsgReader* reader_) : reader(reader_) +ZRLEDecoder::ZRLEDecoder(CMsgReader* reader) : Decoder(reader) { } diff --git a/common/rfb/ZRLEDecoder.h b/common/rfb/ZRLEDecoder.h index 2128ab91..dee20685 100644 --- a/common/rfb/ZRLEDecoder.h +++ b/common/rfb/ZRLEDecoder.h @@ -29,7 +29,6 @@ namespace rfb { virtual ~ZRLEDecoder(); virtual void readRect(const Rect& r, CMsgHandler* handler); private: - CMsgReader* reader; rdr::ZlibInStream zis; }; } diff --git a/common/rfb/ZRLEEncoder.cxx b/common/rfb/ZRLEEncoder.cxx index 7e00fad2..df7cfbdb 100644 --- a/common/rfb/ZRLEEncoder.cxx +++ b/common/rfb/ZRLEEncoder.cxx @@ -46,8 +46,8 @@ IntParameter zlibLevel("ZlibLevel","Zlib compression level",-1); #undef CPIXEL #undef BPP -ZRLEEncoder::ZRLEEncoder(SMsgWriter* writer_) - : writer(writer_), zos(0,0,zlibLevel), mos(129*1024) +ZRLEEncoder::ZRLEEncoder(SMsgWriter* writer) + : Encoder(writer), zos(0,0,zlibLevel), mos(129*1024) { } diff --git a/common/rfb/ZRLEEncoder.h b/common/rfb/ZRLEEncoder.h index acc6d362..9679887a 100644 --- a/common/rfb/ZRLEEncoder.h +++ b/common/rfb/ZRLEEncoder.h @@ -30,7 +30,6 @@ namespace rfb { virtual ~ZRLEEncoder(); virtual void writeRect(const Rect& r, TransImageGetter* ig); private: - SMsgWriter* writer; rdr::ZlibOutStream zos; rdr::MemOutStream mos; };