]> source.dussan.org Git - tigervnc.git/commitdiff
Improved algorighm of detecting constantly-changed areas on the
authorConstantin Kaplinsky <const@tightvnc.com>
Fri, 3 Feb 2006 11:42:00 +0000 (11:42 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Fri, 3 Feb 2006 11:42:00 +0000 (11:42 +0000)
screen. Some debugging code included but commented out.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@476 3789f03b-4d11-0410-bbf8-ca57d06f2519

x0vncserver/PollingManager.cxx
x0vncserver/PollingManager.h

index c02e509254487cd9c20a722af0c29c9481b2611d..9491d766dbc04b46cc19e61096b8edb57540031c 100644 (file)
@@ -214,6 +214,9 @@ bool PollingManager::poll_DetectVideo()
     }
   }
 
+  if (grandStep)
+    adjustVideoArea();
+
   return (nTilesChanged != 0);
 }
 
@@ -340,3 +343,90 @@ bool PollingManager::poll_Dumb()
   // always report that some changes have been detected.
   return true;
 }
+
+//
+// FIXME: Replace with a normal comment.
+// Make video area pattern more regular.
+//
+
+// FIXME: Is it efficient enough?
+void PollingManager::adjustVideoArea()
+{
+  char newFlags[m_widthTiles * m_heightTiles];
+  char *ptr = newFlags;
+  int x, y;
+
+  // DEBUG:
+  // int nVideoTiles = 0;
+
+  for (y = 0; y < m_heightTiles; y++) {
+    for (x = 0; x < m_widthTiles; x++) {
+
+      // DEBUG:
+      // nVideoTiles += m_videoFlags[y * m_widthTiles + x];
+
+      int weightedSum = 0, n;
+      if (y > 0 && x > 0) {
+        n = (m_videoFlags[ y    * m_widthTiles + (x-1)] +
+             m_videoFlags[(y-1) * m_widthTiles + (x-1)] +
+             m_videoFlags[(y-1) * m_widthTiles +  x   ]);
+        if (n == 3) {
+          *ptr++ = 1;
+          continue;
+        }
+        weightedSum += n;
+      }
+      if (y > 0 && x < m_widthTiles - 1) {
+        n = (m_videoFlags[ y    * m_widthTiles + (x+1)] +
+             m_videoFlags[(y-1) * m_widthTiles + (x+1)] +
+             m_videoFlags[(y-1) * m_widthTiles +  x   ]);
+        if (n == 3) {
+          *ptr++ = 1;
+          continue;
+        }
+        weightedSum += n;
+      }
+      if (y < m_heightTiles - 1 && x > 0) {
+        n = (m_videoFlags[ y    * m_widthTiles + (x-1)] +
+             m_videoFlags[(y+1) * m_widthTiles + (x-1)] +
+             m_videoFlags[(y+1) * m_widthTiles +  x   ]);
+        if (n == 3) {
+          *ptr++ = 1;
+          continue;
+        }
+        weightedSum += n;
+      }
+      if (y < m_heightTiles - 1 && x < m_widthTiles - 1) {
+        n = (m_videoFlags[ y    * m_widthTiles + (x+1)] +
+             m_videoFlags[(y+1) * m_widthTiles + (x+1)] +
+             m_videoFlags[(y+1) * m_widthTiles +  x   ]);
+        if (n == 3) {
+          *ptr++ = 1;
+          continue;
+        }
+        weightedSum += n;
+      }
+      *ptr++ = (weightedSum <= 3) ? 0 : m_videoFlags[y * m_widthTiles + x];
+    }
+  }
+
+  /*
+  /// DEBUG: ------------------------------------------------------
+  if (nVideoTiles) {
+    for (y = 0; y < m_heightTiles; y++) {
+      for (x = 0; x < m_widthTiles; x++) {
+        printf("%c", m_videoFlags[y * m_widthTiles + x] ? '@' : ':');
+      }
+      printf("        ");
+      for (x = 0; x < m_widthTiles; x++) {
+        printf("%c", newFlags[y * m_widthTiles + x] ? '@' : ':');
+      }
+      printf("\n");
+    }
+    printf("\n");
+  }
+  /// -------------------------------------------------------------
+  */
+
+  memcpy(m_videoFlags, newFlags, m_widthTiles * m_heightTiles);
+}
index 253c237f66bb16b4b9a4949b9d59568ef80f822d..8f7f820ae4b43da01a39d5ff6bc697c1b76244f2 100644 (file)
@@ -61,6 +61,10 @@ protected:
   int m_widthTiles;
   int m_heightTiles;
 
+private:
+
+  void adjustVideoArea();
+
   Image *m_rowImage;
   Image *m_tileImage;