diff options
author | Constantin Kaplinsky <const@tightvnc.com> | 2006-02-03 11:42:00 +0000 |
---|---|---|
committer | Constantin Kaplinsky <const@tightvnc.com> | 2006-02-03 11:42:00 +0000 |
commit | 6df6990dc8766fbe31d4a193d5d72d0c5bc7105e (patch) | |
tree | 7779f9252e13a472a6c05488a891decd2885050d /x0vncserver | |
parent | c42eab2c890d5ec29df3e9fb6b2a4b9387c22835 (diff) | |
download | tigervnc-6df6990dc8766fbe31d4a193d5d72d0c5bc7105e.tar.gz tigervnc-6df6990dc8766fbe31d4a193d5d72d0c5bc7105e.zip |
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
Diffstat (limited to 'x0vncserver')
-rw-r--r-- | x0vncserver/PollingManager.cxx | 90 | ||||
-rw-r--r-- | x0vncserver/PollingManager.h | 4 |
2 files changed, 94 insertions, 0 deletions
diff --git a/x0vncserver/PollingManager.cxx b/x0vncserver/PollingManager.cxx index c02e5092..9491d766 100644 --- a/x0vncserver/PollingManager.cxx +++ b/x0vncserver/PollingManager.cxx @@ -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); +} diff --git a/x0vncserver/PollingManager.h b/x0vncserver/PollingManager.h index 253c237f..8f7f820a 100644 --- a/x0vncserver/PollingManager.h +++ b/x0vncserver/PollingManager.h @@ -61,6 +61,10 @@ protected: int m_widthTiles; int m_heightTiles; +private: + + void adjustVideoArea(); + Image *m_rowImage; Image *m_tileImage; |