diff options
author | Constantin Kaplinsky <const@tightvnc.com> | 2007-08-31 15:50:37 +0000 |
---|---|---|
committer | Constantin Kaplinsky <const@tightvnc.com> | 2007-08-31 15:50:37 +0000 |
commit | 604d7814aabe1c5a12bf17173b97e6c4a9305109 (patch) | |
tree | dd4188499ef0c1389d5d042adc9f426099f38502 | |
parent | fe6b569f07f9a768739b3a98292bcbac81b8b70c (diff) | |
download | tigervnc-604d7814aabe1c5a12bf17173b97e6c4a9305109.tar.gz tigervnc-604d7814aabe1c5a12bf17173b97e6c4a9305109.zip |
Code cleanups. The most important change is that we now always use UpdateTracker's getUpdateInfo() and never call get_changed(), get_copied() and get_delta() member functions.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2325 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | common/rfb/UpdateTracker.h | 13 | ||||
-rw-r--r-- | common/rfb/VNCSConnectionST.cxx | 36 | ||||
-rw-r--r-- | common/rfb/VNCServerST.cxx | 11 |
3 files changed, 39 insertions, 21 deletions
diff --git a/common/rfb/UpdateTracker.h b/common/rfb/UpdateTracker.h index 5b51317a..8e96d55e 100644 --- a/common/rfb/UpdateTracker.h +++ b/common/rfb/UpdateTracker.h @@ -33,9 +33,13 @@ namespace rfb { bool is_empty() const { return copied.is_empty() && changed.is_empty(); } + // NOTE: We do not ever use UpdateInfo::numRects(), because Tight encoding + // complicates computing the number of rectangles. + /* int numRects() const { return copied.numRects() + changed.numRects(); } + */ }; class UpdateTracker { @@ -59,7 +63,7 @@ namespace rfb { virtual void add_copied(const Region &dest, const Point &delta); protected: UpdateTracker* ut; - Region clipRect; + Rect clipRect; }; class SimpleUpdateTracker : public UpdateTracker { @@ -74,17 +78,12 @@ namespace rfb { virtual void subtract(const Region& region); // Fill the supplied UpdateInfo structure with update information + // FIXME: Provide getUpdateInfo() with no clipping, for better efficiency. virtual void getUpdateInfo(UpdateInfo* info, const Region& cliprgn); // Copy the contained updates to another tracker virtual void copyTo(UpdateTracker* to) const; - - // Get the changed/copied regions - const Region& get_changed() const {return changed;} - const Region& get_copied() const {return copied;} - const Point& get_delta() const {return copy_delta;} - // Move the entire update region by an offset void translate(const Point& p) {changed.translate(p); copied.translate(p);} diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index bd067be2..974a81e3 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -568,17 +568,28 @@ void VNCSConnectionST::writeFramebufferUpdate() { if (state() != RFBSTATE_NORMAL || requested.is_empty()) return; + updates.enable_copyrect(cp.useCopyRect); + server->checkUpdate(); + // Get the lists of updates. Prior to exporting the data to the `update' object, + // getUpdateInfo() will normalize the `updates' object such way that its + // `changed' and `copied' regions would not intersect. + + UpdateInfo update; + updates.getUpdateInfo(&update, requested); + bool needNewUpdateInfo = false; + // If the previous position of the rendered cursor overlaps the source of the // copy, then when the copy happens the corresponding rectangle in the // destination will be wrong, so add it to the changed region. - if (!updates.get_copied().is_empty() && !renderedCursorRect.is_empty()) { - Rect bogusCopiedCursor = (renderedCursorRect.translate(updates.get_delta()) + if (!update.copied.is_empty() && !renderedCursorRect.is_empty()) { + Rect bogusCopiedCursor = (renderedCursorRect.translate(update.copy_delta) .intersect(server->pb->getRect())); - if (!updates.get_copied().intersect(bogusCopiedCursor).is_empty()) { + if (!update.copied.intersect(bogusCopiedCursor).is_empty()) { updates.add_changed(bogusCopiedCursor); + needNewUpdateInfo = true; } } @@ -587,6 +598,7 @@ void VNCSConnectionST::writeFramebufferUpdate() if (removeRenderedCursor) { updates.add_changed(renderedCursorRect); + needNewUpdateInfo = true; renderedCursorRect.clear(); removeRenderedCursor = false; } @@ -596,6 +608,11 @@ void VNCSConnectionST::writeFramebufferUpdate() if (updates.is_empty() && !writer()->needFakeUpdate() && !drawRenderedCursor) return; + // The `updates' object could change, make sure we have valid update info. + + if (needNewUpdateInfo) + updates.getUpdateInfo(&update, requested); + // If the client needs a server-side rendered cursor, work out the cursor // rectangle. If it's empty then don't bother drawing it, but if it overlaps // with the update region, we need to draw the rendered cursor regardless of @@ -608,7 +625,7 @@ void VNCSConnectionST::writeFramebufferUpdate() if (renderedCursorRect.is_empty()) { drawRenderedCursor = false; - } else if (!updates.get_changed().union_(updates.get_copied()) + } else if (!update.changed.union_(update.copied) .intersect(renderedCursorRect).is_empty()) { drawRenderedCursor = true; } @@ -618,16 +635,15 @@ void VNCSConnectionST::writeFramebufferUpdate() // the same bit of screen twice, but we have the overhead of a more complex // region. - //if (drawRenderedCursor) + //if (drawRenderedCursor) { // updates.subtract(renderedCursorRect); + // updates.getUpdateInfo(&update, requested); + //} } - UpdateInfo update; - updates.enable_copyrect(cp.useCopyRect); - updates.getUpdateInfo(&update, requested); if (!update.is_empty() || writer()->needFakeUpdate() || drawRenderedCursor) { // Compute the number of rectangles. Tight encoder makes the things more - // complicated as compared to the original RealVNC. + // complicated as compared to the original VNC4. writer()->setupCurrentEncoder(); int nRects = update.copied.numRects() + (drawRenderedCursor ? 1 : 0); std::vector<Rect> rects; @@ -635,7 +651,7 @@ void VNCSConnectionST::writeFramebufferUpdate() update.changed.get_rects(&rects); for (i = rects.begin(); i != rects.end(); i++) { if (i->width() && i->height()) - nRects += writer()->getNumRects(*i); + nRects += writer()->getNumRects(*i); } writer()->writeFramebufferUpdateStart(nRects); diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index cc18faa3..c02c2eb0 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -451,12 +451,15 @@ inline bool VNCServerST::needRenderedCursor() void VNCServerST::checkUpdate() { + UpdateInfo ui; + comparer->getUpdateInfo(&ui, pb->getRect()); + bool renderCursor = needRenderedCursor(); - if (comparer->is_empty() && !(renderCursor && renderedCursorInvalid)) + if (ui.is_empty() && !(renderCursor && renderedCursorInvalid)) return; - Region toCheck = comparer->get_changed().union_(comparer->get_copied()); + Region toCheck = ui.changed.union_(ui.copied); if (renderCursor) { Rect clippedCursorRect @@ -490,8 +493,8 @@ void VNCServerST::checkUpdate() std::list<VNCSConnectionST*>::iterator ci, ci_next; for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { ci_next = ci; ci_next++; - (*ci)->add_copied(comparer->get_copied(), comparer->get_delta()); - (*ci)->add_changed(comparer->get_changed()); + (*ci)->add_copied(ui.copied, ui.copy_delta); + (*ci)->add_changed(ui.changed); } comparer->clear(); |