diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-09-17 17:11:56 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-09-18 14:08:42 +0200 |
commit | 487008102e35ccbde59c54500700ba2b85f981c2 (patch) | |
tree | 6585b5fddd2d7a9ec272b53cd28aaa083c8e8b55 | |
parent | 1ec4531ca6b37db1fa9b9cc5d5db289be32d4241 (diff) | |
download | tigervnc-487008102e35ccbde59c54500700ba2b85f981c2.tar.gz tigervnc-487008102e35ccbde59c54500700ba2b85f981c2.zip |
Move preferred encoding tracking into a server object
Having it in ConnParams made the linker pull all the encoder objects
into vncviewer, making it larger than necessary and giving it extra
parameters in its help output that weren't relevant.
-rw-r--r-- | common/rfb/ConnParams.cxx | 8 | ||||
-rw-r--r-- | common/rfb/ConnParams.h | 2 | ||||
-rw-r--r-- | common/rfb/EncodeManager.cxx | 2 | ||||
-rw-r--r-- | common/rfb/SConnection.cxx | 20 | ||||
-rw-r--r-- | common/rfb/SConnection.h | 8 |
5 files changed, 29 insertions, 11 deletions
diff --git a/common/rfb/ConnParams.cxx b/common/rfb/ConnParams.cxx index cc0a7688..615f49ae 100644 --- a/common/rfb/ConnParams.cxx +++ b/common/rfb/ConnParams.cxx @@ -22,7 +22,6 @@ #include <rdr/OutStream.h> #include <rfb/Exception.h> #include <rfb/encodings.h> -#include <rfb/EncodeManager.h> #include <rfb/ConnParams.h> #include <rfb/util.h> @@ -37,8 +36,7 @@ ConnParams::ConnParams() supportsSetDesktopSize(false), supportsFence(false), supportsContinuousUpdates(false), compressLevel(2), qualityLevel(-1), fineQualityLevel(-1), - subsampling(subsampleUndefined), name_(0), - preferredEncoding_(encodingRaw), verStrPos(0) + subsampling(subsampleUndefined), name_(0), verStrPos(0) { setName(""); } @@ -118,7 +116,6 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings) qualityLevel = -1; fineQualityLevel = -1; subsampling = subsampleUndefined; - preferredEncoding_ = encodingRaw; encodings_.clear(); encodings_.insert(encodingRaw); @@ -184,9 +181,6 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings) encodings[i] <= pseudoEncodingFineQualityLevel100) fineQualityLevel = encodings[i] - pseudoEncodingFineQualityLevel0; - if (EncodeManager::supported(encodings[i])) - preferredEncoding_ = encodings[i]; - if (encodings[i] > 0) encodings_.insert(encodings[i]); } diff --git a/common/rfb/ConnParams.h b/common/rfb/ConnParams.h index 625f2658..0b8a89cd 100644 --- a/common/rfb/ConnParams.h +++ b/common/rfb/ConnParams.h @@ -80,7 +80,6 @@ namespace rfb { const Cursor& cursor() { return cursor_; } void setCursor(const Cursor& cursor); - rdr::S32 preferredEncoding() { return preferredEncoding_; } bool supportsEncoding(rdr::S32 encoding); void setEncodings(int nEncodings, const rdr::S32* encodings); @@ -108,7 +107,6 @@ namespace rfb { PixelFormat pf_; char* name_; Cursor cursor_; - rdr::S32 preferredEncoding_; std::set<rdr::S32> encodings_; char verStr[13]; int verStrPos; diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx index 1bd00c7f..ca60da48 100644 --- a/common/rfb/EncodeManager.cxx +++ b/common/rfb/EncodeManager.cxx @@ -164,7 +164,7 @@ void EncodeManager::prepareEncoders() indexed = indexedRLE = fullColour = encoderRaw; // Try to respect the client's wishes - preferred = conn->cp.preferredEncoding(); + preferred = conn->getPreferredEncoding(); switch (preferred) { case encodingRRE: // Horrible for anything high frequency and/or lots of colours diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx index 48acf0ac..eeaeafe4 100644 --- a/common/rfb/SConnection.cxx +++ b/common/rfb/SConnection.cxx @@ -26,6 +26,8 @@ #include <rfb/SMsgWriter.h> #include <rfb/SConnection.h> #include <rfb/ServerCore.h> +#include <rfb/encodings.h> +#include <rfb/EncodeManager.h> #include <rfb/LogWriter.h> @@ -47,7 +49,8 @@ SConnection::SConnection(bool reverseConnection_) : readyForSetColourMapEntries(false), is(0), os(0), reader_(0), writer_(0), security(0), ssecurity(0), state_(RFBSTATE_UNINITIALISED), - reverseConnection(reverseConnection_) + reverseConnection(reverseConnection_), + preferredEncoding(encodingRaw) { defaultMajorVersion = 3; defaultMinorVersion = 8; @@ -264,6 +267,21 @@ void SConnection::writeConnFailedFromScratch(const char* msg, os->flush(); } +void SConnection::setEncodings(int nEncodings, rdr::S32* encodings) +{ + int i; + + preferredEncoding = encodingRaw; + for (i = 0;i < nEncodings;i++) { + if (EncodeManager::supported(encodings[i])) { + preferredEncoding = encodings[i]; + break; + } + } + + SMsgHandler::setEncodings(nEncodings, encodings); +} + void SConnection::versionReceived() { } diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h index b6ff7cd5..7718f4c1 100644 --- a/common/rfb/SConnection.h +++ b/common/rfb/SConnection.h @@ -70,6 +70,11 @@ namespace rfb { void approveConnection(bool accept, const char* reason=0); + // Overridden from SMsgHandler + + virtual void setEncodings(int nEncodings, rdr::S32* encodings); + + // Methods to be overridden in a derived class // versionReceived() indicates that the version number has just been read @@ -173,6 +178,8 @@ namespace rfb { stateEnum state() { return state_; } + rdr::S32 getPreferredEncoding() { return preferredEncoding; } + protected: void setState(stateEnum s) { state_ = s; } void writeFakeColourMap(void); @@ -194,6 +201,7 @@ namespace rfb { SSecurity* ssecurity; stateEnum state_; bool reverseConnection; + rdr::S32 preferredEncoding; }; } #endif |