From 67505118683a3f91fe0c336e12684c36269ce588 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20=C3=85strand?= Date: Thu, 10 Feb 2005 15:30:47 +0000 Subject: [PATCH] Uncommented getNumRects. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@165 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- rfb/TightEncoder.cxx | 42 +++++++++++++++++++++--------------------- rfb/TightEncoder.h | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/rfb/TightEncoder.cxx b/rfb/TightEncoder.cxx index fe23a971..fb19885a 100644 --- a/rfb/TightEncoder.cxx +++ b/rfb/TightEncoder.cxx @@ -112,27 +112,27 @@ void TightEncoder::setQualityLevel(int level) } } -//int TightEncoder::getNumRects(const Rect &r) -//{ -// const unsigned int w = r.width(); -// const unsigned int h = r.height(); -// -// // Will this rectangle split into subrects? -// bool rectTooBig = w > pconf->maxRectWidth || w * h > pconf->maxRectSize; -// if (!rectTooBig) -// return 1; -// -// // Compute max sub-rectangle size. -// const unsigned int subrectMaxWidth = -// (w > pconf->maxRectWidth) ? pconf->maxRectWidth : w; -// const unsigned int subrectMaxHeight = -// pconf->maxRectSize / subrectMaxWidth; -// -// // Return the number of subrects. -// return (((w - 1) / pconf->maxRectWidth + 1) * -// ((h - 1) / subrectMaxHeight + 1)); -//} -// +int TightEncoder::getNumRects(const Rect &r) +{ + const unsigned int w = r.width(); + const unsigned int h = r.height(); + + // Will this rectangle split into subrects? + bool rectTooBig = w > pconf->maxRectWidth || w * h > pconf->maxRectSize; + if (!rectTooBig) + return 1; + + // Compute max sub-rectangle size. + const unsigned int subrectMaxWidth = + (w > pconf->maxRectWidth) ? pconf->maxRectWidth : w; + const unsigned int subrectMaxHeight = + pconf->maxRectSize / subrectMaxWidth; + + // Return the number of subrects. + return (((w - 1) / pconf->maxRectWidth + 1) * + ((h - 1) / subrectMaxHeight + 1)); +} + bool TightEncoder::writeRect(const Rect& r, ImageGetter* ig, Rect* actual) { // Shortcuts to rectangle coordinates and dimensions. diff --git a/rfb/TightEncoder.h b/rfb/TightEncoder.h index 181db72a..b6e71a19 100644 --- a/rfb/TightEncoder.h +++ b/rfb/TightEncoder.h @@ -55,7 +55,7 @@ namespace rfb { static Encoder* create(SMsgWriter* writer); virtual void setCompressLevel(int level); virtual void setQualityLevel(int level); - // virtual int getNumRects(const Rect &r); + virtual int getNumRects(const Rect &r); virtual bool writeRect(const Rect& r, ImageGetter* ig, Rect* actual); virtual ~TightEncoder(); -- 2.39.5