Browse Source

Code refactoring and cleanups. Moved a part of handleVideo() back to pollScreen(), changed a few function prototypes, added sanity checking in flagVideoArea().


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2386 3789f03b-4d11-0410-bbf8-ca57d06f2519
tags/v0.0.90
Constantin Kaplinsky 16 years ago
parent
commit
4879263e22
2 changed files with 18 additions and 27 deletions
  1. 16
    25
      unix/x0vncserver/PollingManager.cxx
  2. 2
    2
      unix/x0vncserver/PollingManager.h

+ 16
- 25
unix/x0vncserver/PollingManager.cxx View File

@@ -199,18 +199,21 @@ bool PollingManager::pollScreen()
pChangeFlags += m_widthTiles;
}

// Do the work related to video area detection.
// Do the work related to video area detection, if enabled.
bool haveVideoRect = false;
if ((int)m_videoPriority != 0)
haveVideoRect = handleVideo(changeFlags);
if ((int)m_videoPriority != 0) {
handleVideo(changeFlags);
if (!m_videoRect.is_empty()) {
getScreenRect(m_videoRect);
haveVideoRect = true;
}
}

// Inform the server about the changes.
//
// FIXME: It's possible that (nTilesChanged != 0) but changeFlags[]
// array is empty. That's possible because handleVideo()
// modifies changeFlags[].
if (nTilesChanged)
if (nTilesChanged) {
flagVideoArea(changeFlags, false);
sendChanges(changeFlags);
}

// Cleanup.
delete[] changeFlags;
@@ -254,7 +257,7 @@ int PollingManager::checkRow(int x, int y, int w, bool *pChangeFlags)
return nTilesChanged;
}

void PollingManager::sendChanges(bool *pChangeFlags)
void PollingManager::sendChanges(const bool *pChangeFlags)
{
Rect rect;
for (int y = 0; y < m_heightTiles; y++) {
@@ -281,7 +284,7 @@ void PollingManager::sendChanges(bool *pChangeFlags)
}
}

bool PollingManager::handleVideo(bool *pChangeFlags)
void PollingManager::handleVideo(const bool *pChangeFlags)
{
// Update counters in m_rateMatrix.
int numTiles = m_heightTiles * m_widthTiles;
@@ -294,25 +297,13 @@ bool PollingManager::handleVideo(bool *pChangeFlags)
detectVideo();
memset(m_rateMatrix, 0, numTiles);
}

// FIXME: It looks like the code below rather belongs to
// pollScreen(). Perhaps handleVideo() should be merged back
// to pollScreen(), and then pollScreen() should be split in
// some better way, if needed at all.

// Grab the pixels of video area. Also, exclude video rectangle from
// pChangeFlags[], to prevent grabbing the same pixels twice.
if (!m_videoRect.is_empty()) {
flagVideoArea(pChangeFlags, false);
getScreenRect(m_videoRect);
return true; // we've got a video rectangle
}

return false; // video rectangle is empty
}

void PollingManager::flagVideoArea(bool *pChangeFlags, bool value)
{
if (m_videoRect.is_empty())
return;

Rect r(m_videoRect.tl.x / 32, m_videoRect.tl.y / 32,
m_videoRect.br.x / 32, m_videoRect.br.y / 32);


+ 2
- 2
unix/x0vncserver/PollingManager.h View File

@@ -98,8 +98,8 @@ private:
}

int checkRow(int x, int y, int w, bool *pChangeFlags);
void sendChanges(bool *pChangeFlags);
bool handleVideo(bool *pChangeFlags);
void sendChanges(const bool *pChangeFlags);
void handleVideo(const bool *pChangeFlags);
void flagVideoArea(bool *pChangeFlags, bool value);

// Video detection functions.

Loading…
Cancel
Save