Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved. |
Peter Åstrand | d69bcc4 | 2011-09-28 12:52:53 +0000 | [diff] [blame] | 2 | * Copyright 2004-2005 Cendio AB. |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 3 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This software is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this software; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 18 | * USA. |
| 19 | */ |
| 20 | #include <rfb/CMsgReader.h> |
| 21 | #include <rfb/CMsgHandler.h> |
| 22 | #include <rfb/TightDecoder.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace rfb; |
| 25 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 26 | #define TIGHT_MAX_WIDTH 2048 |
| 27 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 28 | #define EXTRA_ARGS CMsgHandler* handler |
| 29 | #define FILL_RECT(r, p) handler->fillRect(r, p) |
| 30 | #define IMAGE_RECT(r, p) handler->imageRect(r, p) |
| 31 | #define BPP 8 |
| 32 | #include <rfb/tightDecode.h> |
| 33 | #undef BPP |
| 34 | #define BPP 16 |
| 35 | #include <rfb/tightDecode.h> |
| 36 | #undef BPP |
| 37 | #define BPP 32 |
| 38 | #include <rfb/tightDecode.h> |
| 39 | #undef BPP |
| 40 | |
| 41 | Decoder* TightDecoder::create(CMsgReader* reader) |
| 42 | { |
| 43 | return new TightDecoder(reader); |
| 44 | } |
| 45 | |
| 46 | TightDecoder::TightDecoder(CMsgReader* reader_) : reader(reader_) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | TightDecoder::~TightDecoder() |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | void TightDecoder::readRect(const Rect& r, CMsgHandler* handler) |
| 55 | { |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 56 | is = reader->getInStream(); |
| 57 | this->handler = handler; |
| 58 | clientpf = handler->getPreferredPF(); |
| 59 | serverpf = handler->cp.pf(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 60 | |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 61 | if (clientpf.equal(serverpf)) { |
| 62 | /* Decode directly into the framebuffer (fast path) */ |
| 63 | directDecode = true; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 64 | } else { |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 65 | /* Decode into an intermediate buffer and use pixel translation */ |
| 66 | directDecode = false; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 67 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 68 | |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 69 | switch (serverpf.bpp) { |
| 70 | case 8: |
| 71 | tightDecode8 (r); break; |
| 72 | case 16: |
| 73 | tightDecode16(r); break; |
| 74 | case 32: |
| 75 | tightDecode32(r); break; |
| 76 | } |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 77 | } |