diff options
author | Pierre Ossman <ossman@cendio.se> | 2009-03-06 10:12:55 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2009-03-06 10:12:55 +0000 |
commit | 67b2b2fa7f17a578a7c36561c3dce92fd91c6174 (patch) | |
tree | 97afe96d86e647f82e1d97c60f00ca58595c4a56 /common/rfb/ZRLEDecoder.cxx | |
parent | 02e43d78bf13276ef18fd542167e1ca26830a2f4 (diff) | |
download | tigervnc-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/ZRLEDecoder.cxx')
-rw-r--r-- | common/rfb/ZRLEDecoder.cxx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx index b7c69129..aba7fc9f 100644 --- a/common/rfb/ZRLEDecoder.cxx +++ b/common/rfb/ZRLEDecoder.cxx @@ -63,21 +63,18 @@ void ZRLEDecoder::readRect(const Rect& r, CMsgHandler* handler) case 32: { const rfb::PixelFormat& pf = handler->cp.pf(); - bool fitsInLS3Bytes = ((pf.redMax << pf.redShift) < (1<<24) && - (pf.greenMax << pf.greenShift) < (1<<24) && - (pf.blueMax << pf.blueShift) < (1<<24)); - bool fitsInMS3Bytes = (pf.redShift > 7 && - pf.greenShift > 7 && - pf.blueShift > 7); + Pixel maxPixel = pf.pixelFromRGB((rdr::U16)-1, (rdr::U16)-1, (rdr::U16)-1); + bool fitsInLS3Bytes = maxPixel < (1<<24); + bool fitsInMS3Bytes = (maxPixel & 0xff) == 0; - if ((fitsInLS3Bytes && !pf.bigEndian) || - (fitsInMS3Bytes && pf.bigEndian)) + if ((fitsInLS3Bytes && pf.isLittleEndian()) || + (fitsInMS3Bytes && pf.isBigEndian())) { zrleDecode24A(r, is, &zis, (rdr::U32*)buf, handler); } - else if ((fitsInLS3Bytes && pf.bigEndian) || - (fitsInMS3Bytes && !pf.bigEndian)) + else if ((fitsInLS3Bytes && pf.isBigEndian()) || + (fitsInMS3Bytes && pf.isLittleEndian())) { zrleDecode24B(r, is, &zis, (rdr::U32*)buf, handler); } |