]> source.dussan.org Git - tigervnc.git/commitdiff
Make sure we list fallback encodings in a preferable order.
authorPierre Ossman <ossman@cendio.se>
Thu, 12 Mar 2009 10:16:07 +0000 (10:16 +0000)
committerPierre Ossman <ossman@cendio.se>
Thu, 12 Mar 2009 10:16:07 +0000 (10:16 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3661 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/CMsgWriter.cxx

index 094ba368ae1cfe5979bb290a99eb677936182895..82f7189d01ff84933fb75f7ebeb23c12093e0999 100644 (file)
@@ -72,11 +72,38 @@ void CMsgWriter::writeSetEncodings(int preferredEncoding, bool useCopyRect)
   if (useCopyRect) {
     encodings[nEncodings++] = encodingCopyRect;
   }
+
+  /*
+   * Prefer encodings in this order:
+   *
+   *   Tight, ZRLE, Hextile, *
+   */
+
+  if ((preferredEncoding != encodingTight) &&
+      Decoder::supported(encodingTight))
+    encodings[nEncodings++] = encodingTight;
+
+  if ((preferredEncoding != encodingZRLE) &&
+      Decoder::supported(encodingZRLE))
+    encodings[nEncodings++] = encodingZRLE;
+
+  if ((preferredEncoding != encodingHextile) &&
+      Decoder::supported(encodingHextile))
+    encodings[nEncodings++] = encodingHextile;
+
+  // Remaining encodings
   for (int i = encodingMax; i >= 0; i--) {
-    if (i != preferredEncoding && Decoder::supported(i)) {
-      encodings[nEncodings++] = i;
+    switch (i) {
+    case encodingTight:
+    case encodingZRLE:
+    case encodingHextile:
+      break;
+    default:
+      if ((i != preferredEncoding) && Decoder::supported(i))
+        encodings[nEncodings++] = i;
     }
   }
+
   encodings[nEncodings++] = pseudoEncodingLastRect;
   if (cp->customCompressLevel && cp->compressLevel >= 0 && cp->compressLevel <= 9)
       encodings[nEncodings++] = pseudoEncodingCompressLevel0 + cp->compressLevel;