aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/PixelFormat.cxx
diff options
context:
space:
mode:
authorDRC <dcommander@users.sourceforge.net>2011-11-04 06:45:59 +0000
committerDRC <dcommander@users.sourceforge.net>2011-11-04 06:45:59 +0000
commit2b0c21b020fa14d7784aee88e72543804e987684 (patch)
treede74050345037846b90b1dff555bd4651dbf150e /common/rfb/PixelFormat.cxx
parenta5004a3439317c7115d13fa2b37bf6a0b256d329 (diff)
downloadtigervnc-2b0c21b020fa14d7784aee88e72543804e987684.tar.gz
tigervnc-2b0c21b020fa14d7784aee88e72543804e987684.zip
Add fast paths for RGB to 16-bit and 8-bit true color conversion
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4764 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/PixelFormat.cxx')
-rw-r--r--common/rfb/PixelFormat.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
index f7073224..a2e94960 100644
--- a/common/rfb/PixelFormat.cxx
+++ b/common/rfb/PixelFormat.cxx
@@ -224,6 +224,24 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
}
}
+#define trueColorBufferFromRGB(BPP) { \
+ rdr::U8 r, g, b; \
+ int dstPad = pitch - w * BPP / 8; \
+ while (h > 0) { \
+ rdr::U8 *dstEndOfRow = (rdr::U8 *)dst + w * BPP / 8; \
+ while (dst < dstEndOfRow) { \
+ r = *(src++); \
+ g = *(src++); \
+ b = *(src++); \
+ *(rdr::U##BPP *)dst = (((r * redMax + 127) / 255) << redShift) \
+ | (((g * greenMax + 127) / 255) << greenShift) \
+ | (((b * blueMax + 127) / 255) << blueShift); \
+ dst += BPP / 8; \
+ } \
+ dst += dstPad; \
+ h--; \
+ } \
+}
void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
int w, int pitch, int h, ColourMap* cm) const
@@ -254,6 +272,10 @@ void PixelFormat::bufferFromRGB(rdr::U8 *dst, const rdr::U8* src,
dst += dstPad;
h--;
}
+ } else if (!cm && bpp == 16) {
+ trueColorBufferFromRGB(16);
+ } else if (!cm && bpp == 8) {
+ trueColorBufferFromRGB(8);
} else {
// Generic code
Pixel p;