]> source.dussan.org Git - tigervnc.git/commitdiff
Clean up the encoding parser in ConnParams
authorPierre Ossman <ossman@cendio.se>
Wed, 15 Jan 2014 12:44:04 +0000 (13:44 +0100)
committerPierre Ossman <ossman@cendio.se>
Mon, 7 Jul 2014 11:27:09 +0000 (13:27 +0200)
common/rfb/ConnParams.cxx

index 4d14dac500096db22a8fee3c0ce55cd939a750fa..be9d48c07d0083975dc9546fd7e2562499cc8830 100644 (file)
@@ -104,66 +104,73 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings)
   currentEncoding_ = encodingRaw;
 
   for (int i = nEncodings-1; i >= 0; i--) {
-    if (encodings[i] == encodingCopyRect)
+    switch (encodings[i]) {
+    case encodingCopyRect:
       useCopyRect = true;
-    else if (encodings[i] == pseudoEncodingCursor)
+      break;
+    case pseudoEncodingCursor:
       supportsLocalCursor = true;
-    else if (encodings[i] == pseudoEncodingXCursor)
+      break;
+    case pseudoEncodingXCursor:
       supportsLocalXCursor = true;
-    else if (encodings[i] == pseudoEncodingDesktopSize)
+      break;
+    case pseudoEncodingDesktopSize:
       supportsDesktopResize = true;
-    else if (encodings[i] == pseudoEncodingExtendedDesktopSize)
+      break;
+    case pseudoEncodingExtendedDesktopSize:
       supportsExtendedDesktopSize = true;
-    else if (encodings[i] == pseudoEncodingDesktopName)
+      break;
+    case pseudoEncodingDesktopName:
       supportsDesktopRename = true;
-    else if (encodings[i] == pseudoEncodingLastRect)
+      break;
+    case pseudoEncodingLastRect:
       supportsLastRect = true;
-    else if (encodings[i] == pseudoEncodingFence)
+      break;
+    case pseudoEncodingFence:
       supportsFence = true;
-    else if (encodings[i] == pseudoEncodingContinuousUpdates)
+      break;
+    case pseudoEncodingContinuousUpdates:
       supportsContinuousUpdates = true;
-    else if (encodings[i] >= pseudoEncodingCompressLevel0 &&
-            encodings[i] <= pseudoEncodingCompressLevel9) {
-      customCompressLevel = true;
+      break;
+    case pseudoEncodingSubsamp1X:
+      subsampling = subsampleNone;
+      break;
+    case pseudoEncodingSubsampGray:
+      subsampling = subsampleGray;
+      break;
+    case pseudoEncodingSubsamp2X:
+      subsampling = subsample2X;
+      break;
+    case pseudoEncodingSubsamp4X:
+      subsampling = subsample4X;
+      break;
+    case pseudoEncodingSubsamp8X:
+      subsampling = subsample8X;
+      break;
+    case pseudoEncodingSubsamp16X:
+      subsampling = subsample16X;
+      break;
+    }
+
+    if (encodings[i] >= pseudoEncodingCompressLevel0 &&
+        encodings[i] <= pseudoEncodingCompressLevel9)
       compressLevel = encodings[i] - pseudoEncodingCompressLevel0;
-    } else if (encodings[i] >= pseudoEncodingQualityLevel0 &&
-              encodings[i] <= pseudoEncodingQualityLevel9) {
-      noJpeg = false;
+
+    if (encodings[i] >= pseudoEncodingQualityLevel0 &&
+        encodings[i] <= pseudoEncodingQualityLevel9)
       qualityLevel = encodings[i] - pseudoEncodingQualityLevel0;
-    } else if (Encoder::supported(encodings[i]))
-      currentEncoding_ = encodings[i];
-  }
 
-  // If the TurboVNC fine quality/subsampling encodings exist, let them
-  // override the coarse TightVNC quality level
-  for (int i = nEncodings-1; i >= 0; i--) {
-    if (encodings[i] >= pseudoEncodingFineQualityLevel0 + 1 &&
-        encodings[i] <= pseudoEncodingFineQualityLevel100) {
-      noJpeg = false;
+    if (encodings[i] >= pseudoEncodingFineQualityLevel0 &&
+        encodings[i] <= pseudoEncodingFineQualityLevel100)
       fineQualityLevel = encodings[i] - pseudoEncodingFineQualityLevel0;
-    } else if (encodings[i] >= pseudoEncodingSubsamp1X &&
-               encodings[i] <= pseudoEncodingSubsamp16X) {
-      noJpeg = false;
-      switch (encodings[i]) {
-      case pseudoEncodingSubsamp1X:
-        subsampling = subsampleNone;
-        break;
-      case pseudoEncodingSubsampGray:
-        subsampling = subsampleGray;
-        break;
-      case pseudoEncodingSubsamp2X:
-        subsampling = subsample2X;
-        break;
-      case pseudoEncodingSubsamp4X:
-        subsampling = subsample4X;
-        break;
-      case pseudoEncodingSubsamp8X:
-        subsampling = subsample8X;
-        break;
-      case pseudoEncodingSubsamp16X:
-        subsampling = subsample16X;
-        break;
-      }
-    }
+
+    if (Encoder::supported(encodings[i]))
+      currentEncoding_ = encodings[i];
   }
+
+  if (compressLevel != -1)
+    customCompressLevel = true;
+  if ((qualityLevel != -1) || (fineQualityLevel != -1) ||
+      (subsampling != subsampleUndefined))
+    noJpeg = false;
 }