blob: 7bce26422ff799e34934b000798b07d508a668c7 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
DRCcd2c5d42011-08-11 11:18:34 +00002 * Copyright (C) 2011 D. R. Commander
Pierre Ossmanc0397262014-03-14 15:59:46 +01003 * Copyright 2014 Pierre Ossman for Cendio AB
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00004 *
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#ifndef __RFB_TIGHTENCODER_H__
21#define __RFB_TIGHTENCODER_H__
22
23#include <rdr/MemOutStream.h>
24#include <rdr/ZlibOutStream.h>
25#include <rfb/Encoder.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000026
27namespace rfb {
28
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000029 class TightEncoder : public Encoder {
30 public:
Pierre Ossman668468b2014-01-31 12:37:32 +010031 TightEncoder(SConnection* conn);
Pierre Ossman316a3242014-01-15 12:40:20 +010032 virtual ~TightEncoder();
33
Pierre Ossmanc0397262014-03-14 15:59:46 +010034 virtual bool isSupported();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000035
Pierre Ossmanc0397262014-03-14 15:59:46 +010036 virtual void setCompressLevel(int level);
37
38 virtual void writeRect(const PixelBuffer* pb, const Palette& palette);
39 virtual void writeSolidRect(int width, int height,
40 const PixelFormat& pf,
41 const rdr::U8* colour);
42
43 protected:
44 void writeMonoRect(const PixelBuffer* pb, const Palette& palette);
45 void writeIndexedRect(const PixelBuffer* pb, const Palette& palette);
46 void writeFullColourRect(const PixelBuffer* pb, const Palette& palette);
47
48 void writePixels(const rdr::U8* buffer, const PixelFormat& pf,
49 unsigned int count, rdr::OutStream* os);
DRCffe09d62011-08-17 02:27:59 +000050
Pierre Ossman7b5c0692014-03-17 14:35:51 +010051 void writeCompact(rdr::OutStream* os, rdr::U32 value);
52
Pierre Ossmanc0397262014-03-14 15:59:46 +010053 rdr::OutStream* getZlibOutStream(int streamId, int level, size_t length);
54 void flushZlibOutStream(rdr::OutStream* os);
DRCffe09d62011-08-17 02:27:59 +000055
Pierre Ossmanc0397262014-03-14 15:59:46 +010056 protected:
57 // Preprocessor generated, optimised methods
58 void writeMonoRect(int width, int height,
59 const rdr::U8* buffer, int stride,
60 const PixelFormat& pf, const Palette& palette);
61 void writeMonoRect(int width, int height,
62 const rdr::U16* buffer, int stride,
63 const PixelFormat& pf, const Palette& palette);
64 void writeMonoRect(int width, int height,
65 const rdr::U32* buffer, int stride,
66 const PixelFormat& pf, const Palette& palette);
DRCffe09d62011-08-17 02:27:59 +000067
Pierre Ossmanc0397262014-03-14 15:59:46 +010068 void writeIndexedRect(int width, int height,
69 const rdr::U16* buffer, int stride,
70 const PixelFormat& pf, const Palette& palette);
71 void writeIndexedRect(int width, int height,
72 const rdr::U32* buffer, int stride,
73 const PixelFormat& pf, const Palette& palette);
DRCffe09d62011-08-17 02:27:59 +000074
Pierre Ossmanc0397262014-03-14 15:59:46 +010075 rdr::ZlibOutStream zlibStreams[4];
76 rdr::MemOutStream memStream;
DRCffe09d62011-08-17 02:27:59 +000077
Pierre Ossmanc0397262014-03-14 15:59:46 +010078 int idxZlibLevel, monoZlibLevel, rawZlibLevel;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000079 };
80
81}
82
83#endif