]> source.dussan.org Git - tigervnc.git/commitdiff
Move preferred encoding tracking into a server object 33/head
authorPierre Ossman <ossman@cendio.se>
Wed, 17 Sep 2014 15:11:56 +0000 (17:11 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 18 Sep 2014 12:08:42 +0000 (14:08 +0200)
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.

common/rfb/ConnParams.cxx
common/rfb/ConnParams.h
common/rfb/EncodeManager.cxx
common/rfb/SConnection.cxx
common/rfb/SConnection.h

index cc0a7688edbe1241cbdeeef11c6a24cc5b0a8be2..615f49ae1f1b9c0c3b34fa1a4f04faf59f897134 100644 (file)
@@ -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]);
   }
index 625f2658db0ddcb6a1cee3eea1d6b16e0b7deb3c..0b8a89cd784b8ffaa48ed39729a60c1dbba3c615 100644 (file)
@@ -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;
index 1bd00c7f06116ab695a40bd52c85dcb446aff82b..ca60da488d56a92de20ecaf110fe5d3fdee68235 100644 (file)
@@ -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
index 48acf0ac1d0787b0ad2dd7040d2664af2b430d7d..eeaeafe46190be3beb1bd68ed1c2115897784603 100644 (file)
@@ -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()
 {
 }
index b6ff7cd564b5a931526ed76913e6fe280b167aee..7718f4c171e2e2a259a677603557f1b96b647570 100644 (file)
@@ -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