The server now only sends updates for those regions that were encoded with lossy JPEG. --- common/rfb/SMsgWriter.cxx | 10 ++++++++++ common/rfb/SMsgWriter.h | 3 +++ common/rfb/TightEncoder.h | 4 ++++ common/rfb/VNCSConnectionST.cxx | 21 ++++++++++++++++++--- common/rfb/tightEncode.h | 5 +++++ 5 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx index f47f3ee..b53c03b 100644 --- a/common/rfb/SMsgWriter.cxx +++ b/common/rfb/SMsgWriter.cxx @@ -25,6 +25,7 @@ #include <rfb/UpdateTracker.h> #include <rfb/SMsgWriter.h> #include <rfb/LogWriter.h> +#include <rfb/TightEncoder.h> using namespace rfb; @@ -214,3 +215,12 @@ int SMsgWriter::bpp() { return cp->pf().bpp; } + +SimpleUpdateTracker *SMsgWriter::getLossyRegions() +{ + if (cp->currentEncoding() != encodingTight) + return NULL; + + TightEncoder *e = dynamic_cast<TightEncoder *>(encoders[encodingTight]); + return &(e->lossy_tracker); +} diff --git a/common/rfb/SMsgWriter.h b/common/rfb/SMsgWriter.h index 3933b38..4ecc998 100644 --- a/common/rfb/SMsgWriter.h +++ b/common/rfb/SMsgWriter.h @@ -40,6 +40,7 @@ namespace rfb { class ColourMap; class Region; class UpdateInfo; + class SimpleUpdateTracker; class WriteSetCursorCallback { public: @@ -171,6 +172,8 @@ namespace rfb { int getBytesSent(int encoding) { return bytesSent[encoding]; } rdr::U64 getRawBytesEquivalent() { return rawBytesEquivalent; } + SimpleUpdateTracker *getLossyRegions(); + int imageBufIdealSize; protected: diff --git a/common/rfb/TightEncoder.h b/common/rfb/TightEncoder.h index 4fff083..7ed7db3 100644 --- a/common/rfb/TightEncoder.h +++ b/common/rfb/TightEncoder.h @@ -23,6 +23,7 @@ #include <rdr/ZlibOutStream.h> #include <rfb/TransImageGetter.h> #include <rfb/Encoder.h> +#include <rfb/UpdateTracker.h> // FIXME: Check if specifying extern "C" is really necessary. #include <stdio.h> @@ -85,6 +86,8 @@ namespace rfb { virtual bool writeRect(const Rect& r, TransImageGetter* ig, Rect* actual); virtual ~TightEncoder(); + SimpleUpdateTracker lossy_tracker; + private: TightEncoder(SMsgWriter* writer); bool checkSolidTile(Rect& r, rdr::U32* colorPtr, bool needSameColor); @@ -158,6 +161,7 @@ namespace rfb { const TIGHT_CONF* pconf; int jpegQuality; JPEG_SUBSAMP jpegSubsampling; + }; } diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index a5b8013..64f1ac1 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -36,6 +36,7 @@ #include <rfb/fenceTypes.h> #include <rfb/ServerCore.h> #include <rfb/ComparingUpdateTracker.h> +#include <rfb/UpdateTracker.h> #include <rfb/KeyRemapper.h> #define XK_MISCELLANY #define XK_XKB_KEYS @@ -1116,8 +1117,9 @@ void VNCSConnectionST::writeFramebufferUpdate() requested.clear(); - if (rfb::Server::automaticRefreshDelay > 0) + if (rfb::Server::automaticRefreshDelay > 0 && cp.currentEncoding() == encodingTight) { refreshTimer.start(rfb::Server::automaticRefreshDelay); + } } out: @@ -1262,10 +1264,23 @@ void VNCSConnectionST::automaticLosslessRefresh(void) cp.subsampling = SUBSAMP_NONE; } - // Update all the screen (TODO: be smarter) - updates.add_changed(Rect(0, 0, cp.width, cp.height)); + // Update the regions which had been sent with lossy compression + SimpleUpdateTracker *lossy_tracker = writer()->getLossyRegions(); + + UpdateInfo ui; + lossy_tracker->getUpdateInfo(&ui, Region(Rect(0, 0, 10000, 10000))); + if (!ui.is_empty()) { + std::vector<Rect> rects; + std::vector<Rect>::const_iterator i; + ui.changed.get_rects(&rects); + for (i = rects.begin(); i != rects.end(); i++) { + updates.add_changed(*i); + } + } + writeFramebufferUpdate(); refreshTimer.stop(); + lossy_tracker->clear(); // Reset to previous compression settings cp.qualityLevel = q; diff --git a/common/rfb/tightEncode.h b/common/rfb/tightEncode.h index 8f900b5..fc42fed 100644 --- a/common/rfb/tightEncode.h +++ b/common/rfb/tightEncode.h @@ -248,23 +248,28 @@ void TIGHT_ENCODE (const Rect& r, rdr::OutStream *os, bool forceSolid) ENCODE_JPEG_RECT(pixels, stride, r, os); else ENCODE_JPEG_RECT((PIXEL_T *)rawPixels, stride, r, os); + lossy_tracker.add_changed(Region(r)); break; } #endif ENCODE_FULLCOLOR_RECT(pixels, r, os); + lossy_tracker.subtract(Region(r)); break; case 1: // Solid rectangle ENCODE_SOLID_RECT(pixels, os); + lossy_tracker.subtract(Region(r)); break; case 2: // Two-color rectangle ENCODE_MONO_RECT(pixels, r, os); + lossy_tracker.subtract(Region(r)); break; #if (BPP != 8) default: // Up to 256 different colors ENCODE_INDEXED_RECT(pixels, r, os); + lossy_tracker.subtract(Region(r)); #endif } } -- 1.7.9.2 ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Tigervnc-devel mailing list Tigervnc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tigervnc-devel