aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/ZRLEEncoder.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2009-03-06 10:12:55 +0000
committerPierre Ossman <ossman@cendio.se>2009-03-06 10:12:55 +0000
commit67b2b2fa7f17a578a7c36561c3dce92fd91c6174 (patch)
tree97afe96d86e647f82e1d97c60f00ca58595c4a56 /common/rfb/ZRLEEncoder.cxx
parent02e43d78bf13276ef18fd542167e1ca26830a2f4 (diff)
downloadtigervnc-67b2b2fa7f17a578a7c36561c3dce92fd91c6174.tar.gz
tigervnc-67b2b2fa7f17a578a7c36561c3dce92fd91c6174.zip
Consolidate pixel conversion into the PixelFormat class and optimise the
common cases. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3636 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/ZRLEEncoder.cxx')
-rw-r--r--common/rfb/ZRLEEncoder.cxx18
1 files changed, 7 insertions, 11 deletions
diff --git a/common/rfb/ZRLEEncoder.cxx b/common/rfb/ZRLEEncoder.cxx
index d84c4cfb..ef0dd9f5 100644
--- a/common/rfb/ZRLEEncoder.cxx
+++ b/common/rfb/ZRLEEncoder.cxx
@@ -87,21 +87,17 @@ bool ZRLEEncoder::writeRect(const Rect& r, ImageGetter* ig, Rect* actual)
{
const PixelFormat& pf = writer->getConnParams()->pf();
- bool fitsInLS3Bytes = ((pf.redMax << pf.redShift) < (1<<24) &&
- (pf.greenMax << pf.greenShift) < (1<<24) &&
- (pf.blueMax << pf.blueShift) < (1<<24));
+ Pixel maxPixel = pf.pixelFromRGB((rdr::U16)-1, (rdr::U16)-1, (rdr::U16)-1);
+ bool fitsInLS3Bytes = maxPixel < (1<<24);
+ bool fitsInMS3Bytes = (maxPixel & 0xff) == 0;
- bool fitsInMS3Bytes = (pf.redShift > 7 &&
- pf.greenShift > 7 &&
- pf.blueShift > 7);
-
- if ((fitsInLS3Bytes && !pf.bigEndian) ||
- (fitsInMS3Bytes && pf.bigEndian))
+ if ((fitsInLS3Bytes && pf.isLittleEndian()) ||
+ (fitsInMS3Bytes && pf.isBigEndian()))
{
wroteAll = zrleEncode24A(r, mos, &zos, imageBuf, maxLen, actual, ig);
}
- else if ((fitsInLS3Bytes && pf.bigEndian) ||
- (fitsInMS3Bytes && !pf.bigEndian))
+ else if ((fitsInLS3Bytes && pf.isBigEndian()) ||
+ (fitsInMS3Bytes && pf.isLittleEndian()))
{
wroteAll = zrleEncode24B(r, mos, &zos, imageBuf, maxLen, actual, ig);
}