Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* 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 Ossman | 80b4209 | 2015-11-10 17:17:34 +0100 | [diff] [blame] | 18 | |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 19 | #include <rdr/InStream.h> |
Pierre Ossman | 80b4209 | 2015-11-10 17:17:34 +0100 | [diff] [blame] | 20 | #include <rdr/MemInStream.h> |
| 21 | #include <rdr/OutStream.h> |
| 22 | |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 23 | #include <rfb/ConnParams.h> |
Pierre Ossman | 0c9bd4b | 2014-07-09 16:44:11 +0200 | [diff] [blame] | 24 | #include <rfb/PixelBuffer.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 25 | #include <rfb/RREDecoder.h> |
| 26 | |
| 27 | using namespace rfb; |
| 28 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 29 | #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 Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 39 | RREDecoder::RREDecoder() |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 40 | { |
| 41 | } |
| 42 | |
| 43 | RREDecoder::~RREDecoder() |
| 44 | { |
| 45 | } |
| 46 | |
Pierre Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 47 | void RREDecoder::readRect(const Rect& r, rdr::InStream* is, |
Pierre Ossman | 80b4209 | 2015-11-10 17:17:34 +0100 | [diff] [blame] | 48 | const ConnParams& cp, rdr::OutStream* os) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 49 | { |
Pierre Ossman | 80b4209 | 2015-11-10 17:17:34 +0100 | [diff] [blame] | 50 | 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 | |
| 58 | void 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 Ossman | 8635062 | 2015-11-10 13:02:12 +0100 | [diff] [blame] | 63 | const PixelFormat& pf = cp.pf(); |
Pierre Ossman | 0c9bd4b | 2014-07-09 16:44:11 +0200 | [diff] [blame] | 64 | switch (pf.bpp) { |
Pierre Ossman | 80b4209 | 2015-11-10 17:17:34 +0100 | [diff] [blame] | 65 | 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 Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 68 | } |
| 69 | } |