blob: aa1b218a89e0321f797383c399435d06b94aec43 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* 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 Ossman456b2c22014-01-15 13:22:03 +010019#include <rfb/TransImageGetter.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000020#include <rfb/encodings.h>
21#include <rfb/SMsgWriter.h>
Pierre Ossman668468b2014-01-31 12:37:32 +010022#include <rfb/SConnection.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000023#include <rfb/HextileEncoder.h>
24#include <rfb/Configuration.h>
25
26using namespace rfb;
27
28BoolParameter 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 Kaplinskya2adc8d2006-05-25 05:01:55 +000034#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 Ossman668468b2014-01-31 12:37:32 +010047HextileEncoder::HextileEncoder(SConnection* conn) : Encoder(conn)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000048{
49}
50
51HextileEncoder::~HextileEncoder()
52{
53}
54
Pierre Ossman717c07b2014-01-21 14:45:10 +010055void HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000056{
Pierre Ossman668468b2014-01-31 12:37:32 +010057 conn->writer()->startRect(r, encodingHextile);
58 rdr::OutStream* os = conn->getOutStream();
59 switch (conn->cp.pf().bpp) {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000060 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 Ossman668468b2014-01-31 12:37:32 +010082 conn->writer()->endRect();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000083}