Ported encoding optimizations from TurboVNC.  The changes to the Tight parameters were determined through extensive low-level profiling (see http://www.virtualgl.org/pmwiki/uploads/About/turbototiger.pdf).  The other enhancements involved: (1) porting the solid subrectangle pre-computation code from TightVNC/TurboVNC (it makes a pretty big difference-- see report), (2) encapsulating the JPEG encoder in its own class (this eliminates a buffer copy, and the JPEG buffer is now set to a decent size where it shouldn't ever need to be paged or re-allocated, except in rare corner cases), (3) adding support for last rect. encoding (necessary to support the solid rectangle pre-computation enhancements.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4626 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 5add7ea..4ca58ac 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -722,8 +722,14 @@
     std::vector<Rect>::const_iterator i;
     ui.changed.get_rects(&rects);
     for (i = rects.begin(); i != rects.end(); i++) {
-      if (i->width() && i->height())
-        nRects += writer()->getNumRects(*i);
+      if (i->width() && i->height()) {
+        int nUpdateRects = writer()->getNumRects(*i);
+        if (nUpdateRects == 0 && cp.currentEncoding() == encodingTight) {
+          nRects = 0xFFFF;  break;
+        }
+        else
+          nRects += nUpdateRects;
+      }
     }
     
     writer()->writeFramebufferUpdateStart(nRects);