}
#ifdef DEBUG_REPORT_CHANGED_TILES
-#define DBG_REPORT_CHANGES(title) printChanges((title), m_changeFlags)
+#define DBG_REPORT_CHANGES(title) printChanges((title))
#else
#define DBG_REPORT_CHANGES(title)
#endif
// Do the work related to video area detection, if enabled.
bool haveVideoRect = false;
if ((int)m_videoPriority != 0) {
- handleVideo(m_changeFlags);
+ handleVideo();
if (!m_videoRect.is_empty()) {
getScreenRect(m_videoRect);
haveVideoRect = true;
if (nTilesChanged) {
// Try to find more changes around. Before doing that, mark the
// video area as changed, to skip comparisons of its pixels.
- flagVideoArea(m_changeFlags, true);
+ flagVideoArea(true);
DBG_REPORT_CHANGES("Before checking neighbors");
- checkNeighbors(m_changeFlags);
+ checkNeighbors();
DBG_REPORT_CHANGES("After checking neighbors");
// Inform the server about the changes. This time, we mark the
// video area as NOT changed, to prevent reading its pixels again.
- flagVideoArea(m_changeFlags, false);
+ flagVideoArea(false);
DBG_REPORT_CHANGES("Before sending");
- nTilesChanged = sendChanges(m_changeFlags);
+ nTilesChanged = sendChanges();
}
#ifdef DEBUG_PRINT_NUM_CHANGED_TILES
return nTilesChanged;
}
-int PollingManager::sendChanges(const bool *pChangeFlags)
+int PollingManager::sendChanges()
{
+ const bool *pChangeFlags = m_changeFlags;
int nTilesChanged = 0;
Rect rect;
return nTilesChanged;
}
-void PollingManager::handleVideo(const bool *pChangeFlags)
+void PollingManager::handleVideo()
{
// Update counters in m_rateMatrix.
for (int i = 0; i < m_numTiles; i++)
- m_rateMatrix[i] += (pChangeFlags[i] != false);
+ m_rateMatrix[i] += (m_changeFlags[i] != false);
// Once per eight calls: detect video rectangle by examining
// m_rateMatrix[], then reset counters in m_rateMatrix[].
}
}
-void PollingManager::flagVideoArea(bool *pChangeFlags, bool value)
+void PollingManager::flagVideoArea(bool value)
{
if (m_videoRect.is_empty())
return;
for (int y = r.tl.y; y < r.br.y; y++)
for (int x = r.tl.x; x < r.br.x; x++)
- pChangeFlags[y * m_widthTiles + x] = value;
+ m_changeFlags[y * m_widthTiles + x] = value;
}
void
-PollingManager::checkNeighbors(bool *pChangeFlags)
+PollingManager::checkNeighbors()
{
int x, y;
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.
+ m_changeFlags[y * m_widthTiles + x] &&
+ !m_changeFlags[(y - 1) * m_widthTiles + x]) {
+ // FIXME: Check m_changeFlags[] to decrease height of the row.
checkRow(x * 32, y * 32 - 1, m_width - x * 32,
- &pChangeFlags[(y - 1) * m_widthTiles + x]);
+ &m_changeFlags[(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.
+ m_changeFlags[y * m_widthTiles + x] &&
+ !m_changeFlags[(y + 1) * m_widthTiles + x]) {
+ // FIXME: Check m_changeFlags[] to decrease height of the row.
checkRow(x * 32, (y + 1) * 32, m_width - x * 32,
- &pChangeFlags[(y + 1) * m_widthTiles + x]);
+ &m_changeFlags[(y + 1) * m_widthTiles + x]);
doneBelow = true;
}
if (doneBelow && doneAbove)
// 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.
+ if (m_changeFlags[y * m_widthTiles + x] &&
+ !m_changeFlags[y * m_widthTiles + x + 1]) {
+ // FIXME: Check m_changeFlags[] to decrease height of the column.
checkColumn((x + 1) * 32, y * 32, m_height - y * 32,
- &pChangeFlags[y * m_widthTiles + x + 1]);
+ &m_changeFlags[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.
+ if (m_changeFlags[y * m_widthTiles + x] &&
+ !m_changeFlags[y * m_widthTiles + x - 1]) {
+ // FIXME: Check m_changeFlags[] to decrease height of the column.
checkColumn(x * 32 - 1, y * 32, m_height - y * 32,
- &pChangeFlags[y * m_widthTiles + x - 1]);
+ &m_changeFlags[y * m_widthTiles + x - 1]);
break;
}
}
}
void
-PollingManager::printChanges(const char *header, const bool *pChangeFlags)
+PollingManager::printChanges(const char *header) const
{
fprintf(stderr, "%s:", header);
+ const bool *pChangeFlags = m_changeFlags;
+
for (int y = 0; y < m_heightTiles; y++) {
for (int x = 0; x < m_widthTiles; x++) {
if (*pChangeFlags++) {