summaryrefslogtreecommitdiffstats
path: root/common/rfb/ComparingUpdateTracker.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-11-20 15:36:11 +0000
committerPierre Ossman <ossman@cendio.se>2011-11-20 15:36:11 +0000
commitb114cec89edf6d69c545712f29decac1631c94a2 (patch)
treede7d752926e99c906db2e718703a7a8a59b475c4 /common/rfb/ComparingUpdateTracker.cxx
parent53fd544c2f68b2ff97fb3f5e60734b281ce75ad3 (diff)
downloadtigervnc-b114cec89edf6d69c545712f29decac1631c94a2.tar.gz
tigervnc-b114cec89edf6d69c545712f29decac1631c94a2.zip
Make the comparing update tracker a bit more flexible. It can now be in an
"auto" state where it will be enabled until we deem that the client is better of without it (currently triggered by explicitly stating a low compression level). git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4809 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/ComparingUpdateTracker.cxx')
-rw-r--r--common/rfb/ComparingUpdateTracker.cxx49
1 files changed, 37 insertions, 12 deletions
diff --git a/common/rfb/ComparingUpdateTracker.cxx b/common/rfb/ComparingUpdateTracker.cxx
index 42a9e192..43287e07 100644
--- a/common/rfb/ComparingUpdateTracker.cxx
+++ b/common/rfb/ComparingUpdateTracker.cxx
@@ -25,7 +25,7 @@
using namespace rfb;
ComparingUpdateTracker::ComparingUpdateTracker(PixelBuffer* buffer)
- : fb(buffer), oldFb(fb->getPF(), 0, 0), firstCompare(true)
+ : fb(buffer), oldFb(fb->getPF(), 0, 0), firstCompare(true), enabled(true)
{
changed.assign_union(fb->getRect());
}
@@ -37,35 +37,60 @@ ComparingUpdateTracker::~ComparingUpdateTracker()
#define BLOCK_SIZE 16
-void ComparingUpdateTracker::compare()
+bool ComparingUpdateTracker::compare()
{
std::vector<Rect> rects;
std::vector<Rect>::iterator i;
+ if (!enabled)
+ return false;
+
if (firstCompare) {
// NB: We leave the change region untouched on this iteration,
// since in effect the entire framebuffer has changed.
oldFb.setSize(fb->width(), fb->height());
+
for (int y=0; y<fb->height(); y+=BLOCK_SIZE) {
Rect pos(0, y, fb->width(), __rfbmin(fb->height(), y+BLOCK_SIZE));
int srcStride;
const rdr::U8* srcData = fb->getPixelsR(pos, &srcStride);
oldFb.imageRect(pos, srcData, srcStride);
}
+
firstCompare = false;
- } else {
- copied.get_rects(&rects, copy_delta.x<=0, copy_delta.y<=0);
- for (i = rects.begin(); i != rects.end(); i++)
- oldFb.copyRect(*i, copy_delta);
- changed.get_rects(&rects);
+ return false;
+ }
+
+ copied.get_rects(&rects, copy_delta.x<=0, copy_delta.y<=0);
+ for (i = rects.begin(); i != rects.end(); i++)
+ oldFb.copyRect(*i, copy_delta);
- Region newChanged;
- for (i = rects.begin(); i != rects.end(); i++)
- compareRect(*i, &newChanged);
+ changed.get_rects(&rects);
- changed = newChanged;
- }
+ Region newChanged;
+ for (i = rects.begin(); i != rects.end(); i++)
+ compareRect(*i, &newChanged);
+
+ if (changed.equals(newChanged))
+ return false;
+
+ changed = newChanged;
+
+ return true;
+}
+
+void ComparingUpdateTracker::enable()
+{
+ enabled = true;
+}
+
+void ComparingUpdateTracker::disable()
+{
+ enabled = false;
+
+ // Make sure we update the framebuffer next time we get enabled
+ firstCompare = true;
}
void ComparingUpdateTracker::compareRect(const Rect& r, Region* newChanged)