summaryrefslogtreecommitdiffstats
path: root/common/rfb/PixelFormat.cxx
diff options
context:
space:
mode:
authorDRC <dcommander@users.sourceforge.net>2011-08-17 02:27:59 +0000
committerDRC <dcommander@users.sourceforge.net>2011-08-17 02:27:59 +0000
commitffe09d68f578f6765ed73f3b2bf9d4ea37a0b66b (patch)
tree35a2d8caf9c4393a894b39a3f1e3a6a3748f02a2 /common/rfb/PixelFormat.cxx
parent4c44600b9b8c0ca5b5bf078470cdc4c1b4fc2c48 (diff)
downloadtigervnc-ffe09d68f578f6765ed73f3b2bf9d4ea37a0b66b.tar.gz
tigervnc-ffe09d68f578f6765ed73f3b2bf9d4ea37a0b66b.zip
Further optimizations to the Tight encoder to eliminate getImage() overhead. The encoder now directly accesses the framebuffer for solid rectangle computation, JPEG encoding, and color counting (if pixel translation is not required.) Also moved everything in tightEncode.h into the TightEncoder class to eliminate all of the static mess (this will be important later on if we decide to multi-thread the encoder.)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4631 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/PixelFormat.cxx')
-rw-r--r--common/rfb/PixelFormat.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/common/rfb/PixelFormat.cxx b/common/rfb/PixelFormat.cxx
index 11c2d7ab..013cceb2 100644
--- a/common/rfb/PixelFormat.cxx
+++ b/common/rfb/PixelFormat.cxx
@@ -1,5 +1,6 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
* Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -295,6 +296,51 @@ void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src, int pixels, Co
}
+void PixelFormat::rgbFromBuffer(rdr::U8* dst, const rdr::U8* src,
+ int w, int pitch, int h, ColourMap* cm) const
+{
+ rdr::U8 *rowptr, *colptr;
+
+ if (is888()) {
+ // Optimised common case
+ int rindex, gindex, bindex;
+
+ if (bigEndian) {
+ rindex = (24 - redShift)/8;
+ gindex = (24 - greenShift)/8;
+ bindex = (24 - blueShift)/8;
+ } else {
+ rindex = redShift/8;
+ gindex = greenShift/8;
+ bindex = blueShift/8;
+ }
+
+ for(rowptr = (rdr::U8 *)src; rowptr < &src[pitch * h]; rowptr += pitch) {
+ for(colptr = rowptr; colptr < &rowptr[w * 4]; colptr += 4) {
+ *(dst++) = colptr[rindex];
+ *(dst++) = colptr[gindex];
+ *(dst++) = colptr[bindex];
+ }
+ }
+ } else {
+ // Generic code
+ Pixel p;
+ rdr::U8 r, g, b;
+
+ for(rowptr = (rdr::U8 *)src; rowptr < &src[pitch * h]; rowptr += pitch) {
+ for(colptr = rowptr; colptr < &rowptr[w * bpp/8]; colptr += bpp/8) {
+ p = pixelFromBuffer(colptr);
+
+ rgbFromPixel(p, cm, &r, &g, &b);
+ *(dst++) = r;
+ *(dst++) = g;
+ *(dst++) = b;
+ }
+ }
+ }
+}
+
+
void PixelFormat::print(char* str, int len) const
{
// Unfortunately snprintf is not widely available so we build the string up