From 474b12f7b2476830c76bab455f06dcbc23748561 Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Wed, 9 Jan 2008 10:25:34 +0000 Subject: [PATCH] Checking neighbor pixels above and below changed tiles, as well as pixels at the left and at the right. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2396 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- unix/x0vncserver/PollingManager.cxx | 50 ++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/unix/x0vncserver/PollingManager.cxx b/unix/x0vncserver/PollingManager.cxx index 8c75b291..325bed1f 100644 --- a/unix/x0vncserver/PollingManager.cxx +++ b/unix/x0vncserver/PollingManager.cxx @@ -364,19 +364,61 @@ void PollingManager::flagVideoArea(bool *pChangeFlags, bool value) void PollingManager::checkNeighbors(bool *pChangeFlags) { - // Check neighboring pixels at the right of changed tiles. - for (int x = 0; x < m_widthTiles - 1; x++) { - for (int y = 0; y < m_heightTiles; y++) { + int x, y; + + // Check neighboring pixels above and below changed tiles. + // FIXME: Fast skip to the first changed tile (and to the last, too). + // FIXME: Check the full-width line above the first changed tile? + for (y = 0; y < m_heightTiles; y++) { + bool doneAbove = false; + bool doneBelow = false; + for (x = 0; x < m_widthTiles; x++) { + if (!doneAbove && y > 0 && + pChangeFlags[y * m_widthTiles + x] && + !pChangeFlags[(y - 1) * m_widthTiles + x]) { + // FIXME: Check pChangeFlags[] to decrease height of the row. + checkRow(x * 32, y * 32 - 1, m_width - x * 32, + &pChangeFlags[(y - 1) * m_widthTiles + x]); + doneAbove = true; + } + if (!doneBelow && y < m_heightTiles - 1 && + pChangeFlags[y * m_widthTiles + x] && + !pChangeFlags[(y + 1) * m_widthTiles + x]) { + // FIXME: Check pChangeFlags[] to decrease height of the row. + checkRow(x * 32, (y + 1) * 32, m_width - x * 32, + &pChangeFlags[(y + 1) * m_widthTiles + x]); + doneBelow = true; + } + if (doneBelow && doneAbove) + break; + } + } + + // Check neighboring pixels at the right side of changed tiles. + for (x = 0; x < m_widthTiles - 1; x++) { + for (y = 0; y < m_heightTiles; y++) { if (pChangeFlags[y * m_widthTiles + x] && !pChangeFlags[y * m_widthTiles + x + 1]) { // FIXME: Check pChangeFlags[] to decrease height of the column. - // FIXME: Check _only_ the tiles neighboring to changed tiles? checkColumn((x + 1) * 32, y * 32, m_height - y * 32, &pChangeFlags[y * m_widthTiles + x + 1]); break; } } } + + // Check neighboring pixels at the left side of changed tiles. + for (x = m_widthTiles - 1; x > 0; x--) { + for (y = 0; y < m_heightTiles; y++) { + if (pChangeFlags[y * m_widthTiles + x] && + !pChangeFlags[y * m_widthTiles + x - 1]) { + // FIXME: Check pChangeFlags[] to decrease height of the column. + checkColumn(x * 32 - 1, y * 32, m_height - y * 32, + &pChangeFlags[y * m_widthTiles + x - 1]); + break; + } + } + } } void -- 2.39.5