diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-11-10 17:17:34 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-11-27 11:00:22 +0100 |
commit | 80b4209b547f030dad14b2ce9456b2a4220b9a65 (patch) | |
tree | d2eda58d161281b2d75ff1a1cac2c387fbf1de10 /common/rfb/RawDecoder.cxx | |
parent | ded49076c84048003e4c94da2d53ed93b21740af (diff) | |
download | tigervnc-80b4209b547f030dad14b2ce9456b2a4220b9a65.tar.gz tigervnc-80b4209b547f030dad14b2ce9456b2a4220b9a65.zip |
Split decoders into a read and decode step
We need to split these steps up in preparation for multi-core
support. Reading needs to be done in a serial manner, whilst
decoding can be done in parallel.
This also involved a rather large cleanup of the Tight decoder.
Diffstat (limited to 'common/rfb/RawDecoder.cxx')
-rw-r--r-- | common/rfb/RawDecoder.cxx | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/common/rfb/RawDecoder.cxx b/common/rfb/RawDecoder.cxx index 292c3436..e349bda8 100644 --- a/common/rfb/RawDecoder.cxx +++ b/common/rfb/RawDecoder.cxx @@ -15,7 +15,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ -#include <rdr/InStream.h> + +#include <assert.h> + +#include <rdr/OutStream.h> #include <rfb/ConnParams.h> #include <rfb/PixelBuffer.h> #include <rfb/RawDecoder.h> @@ -31,36 +34,15 @@ RawDecoder::~RawDecoder() } void RawDecoder::readRect(const Rect& r, rdr::InStream* is, - const ConnParams& cp, ModifiablePixelBuffer* pb) + const ConnParams& cp, rdr::OutStream* os) { - const PixelFormat& pf = cp.pf(); - - rdr::U8 imageBuf[16384]; - const int maxPixels = sizeof(imageBuf) / (pf.bpp/8); - - int x = r.tl.x; - int y = r.tl.y; - int w = r.width(); - int h = r.height(); - - while (h > 0) { - int dx; - - dx = 0; - while (dx < w) { - int dw; - - dw = maxPixels; - if (dx + dw > w) - dw = w - dx; - - is->readBytes(imageBuf, dw * pf.bpp/8); - pb->imageRect(pf, Rect(x+dx, y, x+dx+dw, y+1), imageBuf); - - dx += dw; - } + os->copyBytes(is, r.area() * cp.pf().bpp/8); +} - y++; - h--; - } +void RawDecoder::decodeRect(const Rect& r, const void* buffer, + size_t buflen, const ConnParams& cp, + ModifiablePixelBuffer* pb) +{ + assert(buflen >= (size_t)r.area() * cp.pf().bpp/8); + pb->imageRect(cp.pf(), r, buffer); } |