Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame^] | 1 | /* Copyright (C) 2002-2005 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 | |
| 25 | namespace 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 (the overhead is about 1/16 of the |
| 38 | // width, in this example about 128 bytes). |
| 39 | static void setMaxLen(int m) { maxLen = m; } |
| 40 | |
| 41 | // setSharedMos() sets a MemOutStream to be shared amongst all |
| 42 | // ZRLEEncoders. Should be called before any ZRLEEncoders are created. |
| 43 | static void setSharedMos(rdr::MemOutStream* mos_) { sharedMos = mos_; } |
| 44 | |
| 45 | private: |
| 46 | ZRLEEncoder(SMsgWriter* writer); |
| 47 | SMsgWriter* writer; |
| 48 | rdr::ZlibOutStream zos; |
| 49 | rdr::MemOutStream* mos; |
| 50 | static rdr::MemOutStream* sharedMos; |
| 51 | static int maxLen; |
| 52 | }; |
| 53 | } |
| 54 | #endif |