blob: 17222a3caf59eca175982f979530fc0b455d6e34 [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18#ifndef __RFB_ZRLEENCODER_H__
19#define __RFB_ZRLEENCODER_H__
20
21#include <rdr/MemOutStream.h>
22#include <rdr/ZlibOutStream.h>
23#include <rfb/Encoder.h>
24
25namespace rfb {
26
27 class ZRLEEncoder : public Encoder {
28 public:
29 static Encoder* create(SMsgWriter* writer);
30 virtual bool writeRect(const Rect& r, ImageGetter* ig, Rect* actual);
31 virtual ~ZRLEEncoder();
32
33 // setMaxLen() sets the maximum size in bytes of any ZRLE rectangle. This
34 // can be used to stop the MemOutStream from growing too large. The value
35 // must be large enough to allow for at least one row of ZRLE tiles. So
36 // for example for a screen width of 2048 32-bit pixels this is 2K*4*64 =
37 // 512Kbytes plus a bit of overhead.
38 static void setMaxLen(int m) { maxLen = m; }
39
40 // setSharedMos() sets a MemOutStream to be shared amongst all
41 // ZRLEEncoders. Should be called before any ZRLEEncoders are created.
42 static void setSharedMos(rdr::MemOutStream* mos_) { sharedMos = mos_; }
43
44 private:
45 ZRLEEncoder(SMsgWriter* writer);
46 SMsgWriter* writer;
47 rdr::ZlibOutStream zos;
48 rdr::MemOutStream* mos;
49 static rdr::MemOutStream* sharedMos;
50 static int maxLen;
51 };
52}
53#endif