Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * Copyright (C) 2005 Constantin Kaplinsky. All Rights Reserved. |
| 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
Pierre Ossman | 456b2c2 | 2014-01-15 13:22:03 +0100 | [diff] [blame] | 19 | #include <rfb/TransImageGetter.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 20 | #include <rfb/encodings.h> |
| 21 | #include <rfb/SMsgWriter.h> |
| 22 | #include <rfb/HextileEncoder.h> |
| 23 | #include <rfb/Configuration.h> |
| 24 | |
| 25 | using namespace rfb; |
| 26 | |
| 27 | BoolParameter improvedHextile("ImprovedHextile", |
| 28 | "Use improved compression algorithm for Hextile " |
| 29 | "encoding which achieves better compression " |
| 30 | "ratios by the cost of using more CPU time", |
| 31 | true); |
| 32 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 33 | #define BPP 8 |
| 34 | #include <rfb/hextileEncode.h> |
| 35 | #include <rfb/hextileEncodeBetter.h> |
| 36 | #undef BPP |
| 37 | #define BPP 16 |
| 38 | #include <rfb/hextileEncode.h> |
| 39 | #include <rfb/hextileEncodeBetter.h> |
| 40 | #undef BPP |
| 41 | #define BPP 32 |
| 42 | #include <rfb/hextileEncode.h> |
| 43 | #include <rfb/hextileEncodeBetter.h> |
| 44 | #undef BPP |
| 45 | |
Pierre Ossman | 4aba19e | 2014-01-29 16:42:48 +0100 | [diff] [blame] | 46 | HextileEncoder::HextileEncoder(SMsgWriter* writer_) : Encoder(writer_) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 47 | { |
| 48 | } |
| 49 | |
| 50 | HextileEncoder::~HextileEncoder() |
| 51 | { |
| 52 | } |
| 53 | |
Pierre Ossman | 717c07b | 2014-01-21 14:45:10 +0100 | [diff] [blame] | 54 | void HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 55 | { |
| 56 | writer->startRect(r, encodingHextile); |
| 57 | rdr::OutStream* os = writer->getOutStream(); |
| 58 | switch (writer->bpp()) { |
| 59 | case 8: |
| 60 | if (improvedHextile) { |
| 61 | hextileEncodeBetter8(r, os, ig); |
| 62 | } else { |
| 63 | hextileEncode8(r, os, ig); |
| 64 | } |
| 65 | break; |
| 66 | case 16: |
| 67 | if (improvedHextile) { |
| 68 | hextileEncodeBetter16(r, os, ig); |
| 69 | } else { |
| 70 | hextileEncode16(r, os, ig); |
| 71 | } |
| 72 | break; |
| 73 | case 32: |
| 74 | if (improvedHextile) { |
| 75 | hextileEncodeBetter32(r, os, ig); |
| 76 | } else { |
| 77 | hextileEncode32(r, os, ig); |
| 78 | } |
| 79 | break; |
| 80 | } |
| 81 | writer->endRect(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 82 | } |