diff options
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); } |