aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/PixelFormat.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2009-03-25 12:26:41 +0000
committerPierre Ossman <ossman@cendio.se>2009-03-25 12:26:41 +0000
commit38a6be484babd3a67e07e22c6fdd95e1c99fbe0c (patch)
tree8ae9297049958ecd67610f2380f7c4cf948fee94 /common/rfb/PixelFormat.cxx
parentb2ff160f830d8df465aece76a9b32aa73a982da6 (diff)
downloadtigervnc-38a6be484babd3a67e07e22c6fdd95e1c99fbe0c.tar.gz
tigervnc-38a6be484babd3a67e07e22c6fdd95e1c99fbe0c.zip
A quick optimisation of the common 32-bit to 24-bit pixel conversion.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3719 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/PixelFormat.cxx')
-rw-r--r--common/rfb/PixelFormat.cxx41
1 files changed, 30 insertions, 11 deletions
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
index fa7064fe..4221e448 100644
--- a/common/rfb/PixelFormat.cxx
+++ b/common/rfb/PixelFormat.cxx
@@ -209,17 +209,36 @@ void PixelFormat::rgbFromBuffer(rdr::U16* dst, const rdr::U8* src, int pixels, C
void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels, ColourMap* cm) const
{
- Pixel p;
- rdr::U8 r, g, b;
-
- while (pixels--) {
- p = pixelFromBuffer(src);
- src += bpp/8;
-
- rgbFromPixel(p, cm, &r, &g, &b);
- *(dst++) = r;
- *(dst++) = g;
- *(dst++) = b;
+ if (is888()) {
+ // Optimised common case
+ const rdr::U8 *r, *g, *b;
+
+ r = src + redShift/8;
+ g = src + greenShift/8;
+ b = src + blueShift/8;
+
+ while (pixels--) {
+ *(dst++) = *r;
+ *(dst++) = *g;
+ *(dst++) = *b;
+ r += 4;
+ g += 4;
+ b += 4;
+ }
+ } else {
+ // Generic code
+ Pixel p;
+ rdr::U8 r, g, b;
+
+ while (pixels--) {
+ p = pixelFromBuffer(src);
+ src += bpp/8;
+
+ rgbFromPixel(p, cm, &r, &g, &b);
+ *(dst++) = r;
+ *(dst++) = g;
+ *(dst++) = b;
+ }
}
}