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> |
Pierre Ossman | 668468b | 2014-01-31 12:37:32 +0100 | [diff] [blame^] | 22 | #include <rfb/SConnection.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 23 | #include <rfb/HextileEncoder.h> |
| 24 | #include <rfb/Configuration.h> |
| 25 | |
| 26 | using namespace rfb; |
| 27 | |
| 28 | BoolParameter improvedHextile("ImprovedHextile", |
| 29 | "Use improved compression algorithm for Hextile " |
| 30 | "encoding which achieves better compression " |
| 31 | "ratios by the cost of using more CPU time", |
| 32 | true); |
| 33 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 34 | #define BPP 8 |
| 35 | #include <rfb/hextileEncode.h> |
| 36 | #include <rfb/hextileEncodeBetter.h> |
| 37 | #undef BPP |
| 38 | #define BPP 16 |
| 39 | #include <rfb/hextileEncode.h> |
| 40 | #include <rfb/hextileEncodeBetter.h> |
| 41 | #undef BPP |
| 42 | #define BPP 32 |
| 43 | #include <rfb/hextileEncode.h> |
| 44 | #include <rfb/hextileEncodeBetter.h> |
| 45 | #undef BPP |
| 46 | |
Pierre Ossman | 668468b | 2014-01-31 12:37:32 +0100 | [diff] [blame^] | 47 | HextileEncoder::HextileEncoder(SConnection* conn) : Encoder(conn) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 48 | { |
| 49 | } |
| 50 | |
| 51 | HextileEncoder::~HextileEncoder() |
| 52 | { |
| 53 | } |
| 54 | |
Pierre Ossman | 717c07b | 2014-01-21 14:45:10 +0100 | [diff] [blame] | 55 | void HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig) |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 56 | { |
Pierre Ossman | 668468b | 2014-01-31 12:37:32 +0100 | [diff] [blame^] | 57 | conn->writer()->startRect(r, encodingHextile); |
| 58 | rdr::OutStream* os = conn->getOutStream(); |
| 59 | switch (conn->cp.pf().bpp) { |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 60 | case 8: |
| 61 | if (improvedHextile) { |
| 62 | hextileEncodeBetter8(r, os, ig); |
| 63 | } else { |
| 64 | hextileEncode8(r, os, ig); |
| 65 | } |
| 66 | break; |
| 67 | case 16: |
| 68 | if (improvedHextile) { |
| 69 | hextileEncodeBetter16(r, os, ig); |
| 70 | } else { |
| 71 | hextileEncode16(r, os, ig); |
| 72 | } |
| 73 | break; |
| 74 | case 32: |
| 75 | if (improvedHextile) { |
| 76 | hextileEncodeBetter32(r, os, ig); |
| 77 | } else { |
| 78 | hextileEncode32(r, os, ig); |
| 79 | } |
| 80 | break; |
| 81 | } |
Pierre Ossman | 668468b | 2014-01-31 12:37:32 +0100 | [diff] [blame^] | 82 | conn->writer()->endRect(); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 83 | } |