OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | 8 |
10 #ifndef SkFlate_DEFINED | 9 #ifndef SkFlate_DEFINED |
11 #define SkFlate_DEFINED | 10 #define SkFlate_DEFINED |
12 | 11 |
13 #include "SkTypes.h" | 12 #include "SkTypes.h" |
14 | 13 |
15 #include "SkStream.h" | 14 #include "SkStream.h" |
16 | 15 |
17 /** | 16 /** |
18 * Wrap a stream in this class to compress the information written to | 17 * Wrap a stream in this class to compress the information written to |
19 * this stream using the Deflate algorithm. Uses Zlib's | 18 * this stream using the Deflate algorithm. |
20 * Z_DEFAULT_COMPRESSION level. | |
21 * | 19 * |
22 * See http://en.wikipedia.org/wiki/DEFLATE | 20 * See http://en.wikipedia.org/wiki/DEFLATE |
23 */ | 21 */ |
24 class SkDeflateWStream final : public SkWStream { | 22 class SkDeflateWStream final : public SkWStream { |
25 public: | 23 public: |
26 /** Does not take ownership of the stream. */ | 24 /** Does not take ownership of the stream. |
27 SkDeflateWStream(SkWStream*); | 25 |
| 26 @param compressionLevel - 0 is no compression; 1 is best |
| 27 speed; 9 is best compression. The default, -1, is to use |
| 28 zlib's Z_DEFAULT_COMPRESSION level. |
| 29 |
| 30 @param gzip iff true, output a gzip file. "The gzip format is |
| 31 a wrapper, documented in RFC 1952, around a deflate stream." |
| 32 gzip adds a header with a magic number to the beginning of the |
| 33 stream, alowing a client to identify a gzip file. |
| 34 */ |
| 35 SkDeflateWStream(SkWStream*, |
| 36 int compressionLevel = -1, |
| 37 bool gzip = false); |
28 | 38 |
29 /** The destructor calls finalize(). */ | 39 /** The destructor calls finalize(). */ |
30 ~SkDeflateWStream(); | 40 ~SkDeflateWStream(); |
31 | 41 |
32 /** Write the end of the compressed stream. All subsequent calls to | 42 /** Write the end of the compressed stream. All subsequent calls to |
33 write() will fail. Subsequent calls to finalize() do nothing. */ | 43 write() will fail. Subsequent calls to finalize() do nothing. */ |
34 void finalize(); | 44 void finalize(); |
35 | 45 |
36 // The SkWStream interface: | 46 // The SkWStream interface: |
37 bool write(const void*, size_t) override; | 47 bool write(const void*, size_t) override; |
38 size_t bytesWritten() const override; | 48 size_t bytesWritten() const override; |
39 | 49 |
40 private: | 50 private: |
41 struct Impl; | 51 struct Impl; |
42 SkAutoTDelete<Impl> fImpl; | 52 SkAutoTDelete<Impl> fImpl; |
43 }; | 53 }; |
44 | 54 |
45 #endif // SkFlate_DEFINED | 55 #endif // SkFlate_DEFINED |
OLD | NEW |