blob: 0907bab8c4fddf4b420545dd3098cfb12fd2436c [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>
22#include <rfb/HextileEncoder.h>
23#include <rfb/Configuration.h>
24
25using namespace rfb;
26
27BoolParameter 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
33#define EXTRA_ARGS ImageGetter* ig
34#define GET_IMAGE_INTO_BUF(r,buf) ig->getImage(buf, r);
35#define BPP 8
36#include <rfb/hextileEncode.h>
37#include <rfb/hextileEncodeBetter.h>
38#undef BPP
39#define BPP 16
40#include <rfb/hextileEncode.h>
41#include <rfb/hextileEncodeBetter.h>
42#undef BPP
43#define BPP 32
44#include <rfb/hextileEncode.h>
45#include <rfb/hextileEncodeBetter.h>
46#undef BPP
47
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000048HextileEncoder::HextileEncoder(SMsgWriter* writer_) : writer(writer_)
49{
50}
51
52HextileEncoder::~HextileEncoder()
53{
54}
55
DRCffe09d62011-08-17 02:27:59 +000056bool HextileEncoder::writeRect(const Rect& r, TransImageGetter* ig,
57 Rect* actual)
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000058{
59 writer->startRect(r, encodingHextile);
60 rdr::OutStream* os = writer->getOutStream();
61 switch (writer->bpp()) {
62 case 8:
63 if (improvedHextile) {
64 hextileEncodeBetter8(r, os, ig);
65 } else {
66 hextileEncode8(r, os, ig);
67 }
68 break;
69 case 16:
70 if (improvedHextile) {
71 hextileEncodeBetter16(r, os, ig);
72 } else {
73 hextileEncode16(r, os, ig);
74 }
75 break;
76 case 32:
77 if (improvedHextile) {
78 hextileEncodeBetter32(r, os, ig);
79 } else {
80 hextileEncode32(r, os, ig);
81 }
82 break;
83 }
84 writer->endRect();
85 return true;
86}