blob: 218c9b0bae0549672d28c4614e905f79838968ef [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
Pierre Ossman80b42092015-11-10 17:17:34 +010018
Pierre Ossman86350622015-11-10 13:02:12 +010019#include <rdr/InStream.h>
Pierre Ossman80b42092015-11-10 17:17:34 +010020#include <rdr/MemInStream.h>
21#include <rdr/OutStream.h>
22
Pierre Ossman86350622015-11-10 13:02:12 +010023#include <rfb/ConnParams.h>
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020024#include <rfb/PixelBuffer.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000025#include <rfb/RREDecoder.h>
26
27using namespace rfb;
28
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000029#define BPP 8
30#include <rfb/rreDecode.h>
31#undef BPP
32#define BPP 16
33#include <rfb/rreDecode.h>
34#undef BPP
35#define BPP 32
36#include <rfb/rreDecode.h>
37#undef BPP
38
Pierre Ossman570cd5c2015-11-12 13:07:42 +010039RREDecoder::RREDecoder() : Decoder(DecoderPlain)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000040{
41}
42
43RREDecoder::~RREDecoder()
44{
45}
46
Pierre Ossman86350622015-11-10 13:02:12 +010047void RREDecoder::readRect(const Rect& r, rdr::InStream* is,
Pierre Ossman80b42092015-11-10 17:17:34 +010048 const ConnParams& cp, rdr::OutStream* os)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000049{
Pierre Ossman80b42092015-11-10 17:17:34 +010050 rdr::U32 numRects;
51
52 numRects = is->readU32();
53 os->writeU32(numRects);
54
55 os->copyBytes(is, cp.pf().bpp/8 + numRects * (cp.pf().bpp/8 + 8));
56}
57
58void RREDecoder::decodeRect(const Rect& r, const void* buffer,
59 size_t buflen, const ConnParams& cp,
60 ModifiablePixelBuffer* pb)
61{
62 rdr::MemInStream is(buffer, buflen);
Pierre Ossman86350622015-11-10 13:02:12 +010063 const PixelFormat& pf = cp.pf();
Pierre Ossman0c9bd4b2014-07-09 16:44:11 +020064 switch (pf.bpp) {
Pierre Ossman80b42092015-11-10 17:17:34 +010065 case 8: rreDecode8 (r, &is, pf, pb); break;
66 case 16: rreDecode16(r, &is, pf, pb); break;
67 case 32: rreDecode32(r, &is, pf, pb); break;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000068 }
69}