If defined DEBUG_PRINT_NUM_CHANGED_TILES, print correct final number of changed tiles detected (excluding video area but including tiles found after "neighbors check").


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2395 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx
index b0c0efb..8c75b29 100644
--- a/unix/x0vncserver/PollingManager.cxx
+++ b/unix/x0vncserver/PollingManager.cxx
@@ -219,7 +219,7 @@
     // Inform the server about the changes. This time, we mark the
     // video area as NOT changed, to prevent reading its pixels again.
     flagVideoArea(changeFlags, false);
-    sendChanges(changeFlags);
+    nTilesChanged = sendChanges(changeFlags);
   }
 
   // Cleanup.
@@ -233,7 +233,6 @@
 #endif
 
 #ifdef DEBUG
-  // FIXME: Move this to sendChanges();
   if (nTilesChanged != 0) {
     fprintf(stderr, "#%d# ", nTilesChanged);
   }
@@ -303,8 +302,10 @@
   return nTilesChanged;
 }
 
-void PollingManager::sendChanges(const bool *pChangeFlags)
+int PollingManager::sendChanges(const bool *pChangeFlags)
 {
+  int nTilesChanged = 0;
+
   Rect rect;
   for (int y = 0; y < m_heightTiles; y++) {
     for (int x = 0; x < m_widthTiles; x++) {
@@ -314,6 +315,7 @@
         while (x + count < m_widthTiles && *pChangeFlags++) {
           count++;
         }
+        nTilesChanged += count;
         // Compute the coordinates and the size of this band.
         rect.setXYWH(x * 32, y * 32, count * 32, 32);
         if (rect.br.x > m_width)
@@ -328,6 +330,7 @@
       }
     }
   }
+  return nTilesChanged;
 }
 
 void PollingManager::handleVideo(const bool *pChangeFlags)
diff --git a/unix/x0vncserver/PollingManager.h b/unix/x0vncserver/PollingManager.h
index 9d62f0b..27bbf0f 100644
--- a/unix/x0vncserver/PollingManager.h
+++ b/unix/x0vncserver/PollingManager.h
@@ -99,7 +99,7 @@
 
   int checkRow(int x, int y, int w, bool *pChangeFlags);
   int checkColumn(int x, int y, int h, bool *pChangeFlags);
-  void sendChanges(const bool *pChangeFlags);
+  int sendChanges(const bool *pChangeFlags);
   void handleVideo(const bool *pChangeFlags);
   void flagVideoArea(bool *pChangeFlags, bool value);