Improved algorighm of detecting constantly-changed areas on the
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
diff --git a/x0vncserver/PollingManager.cxx b/x0vncserver/PollingManager.cxx
index c02e509..9491d76 100644
--- a/x0vncserver/PollingManager.cxx
+++ b/x0vncserver/PollingManager.cxx
@@ -214,6 +214,9 @@
}
}
+ if (grandStep)
+ adjustVideoArea();
+
return (nTilesChanged != 0);
}
@@ -340,3 +343,90 @@
// 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);
+}
diff --git a/x0vncserver/PollingManager.h b/x0vncserver/PollingManager.h
index 253c237..8f7f820 100644
--- a/x0vncserver/PollingManager.h
+++ b/x0vncserver/PollingManager.h
@@ -61,6 +61,10 @@
int m_widthTiles;
int m_heightTiles;
+private:
+
+ void adjustVideoArea();
+
Image *m_rowImage;
Image *m_tileImage;