diff options
Diffstat (limited to 'x0vncserver/PollingManager.cxx')
-rw-r--r-- | x0vncserver/PollingManager.cxx | 90 |
1 files changed, 90 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); +} |