| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkFlate_DEFINED | 10 #ifndef SkFlate_DEFINED |
| 11 #define SkFlate_DEFINED | 11 #define SkFlate_DEFINED |
| 12 | 12 |
| 13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
| 14 | 14 |
| 15 #ifndef Sk_NO_FLATE | 15 #ifndef Sk_NO_FLATE |
| 16 | 16 |
| 17 #include "SkStream.h" |
| 17 class SkData; | 18 class SkData; |
| 18 class SkWStream; | |
| 19 class SkStream; | |
| 20 | 19 |
| 21 /** \class SkFlate | 20 /** \class SkFlate |
| 22 A class to provide access to the flate compression algorithm. | 21 A class to provide access to the flate compression algorithm. |
| 23 */ | 22 */ |
| 24 class SkFlate { | 23 class SkFlate { |
| 25 public: | 24 public: |
| 26 /** | 25 /** |
| 27 * Use the flate compression algorithm to compress the data in src, | 26 * Use the flate compression algorithm to compress the data in src, |
| 28 * putting the result into dst. Returns false if an error occurs. | 27 * putting the result into dst. Returns false if an error occurs. |
| 29 */ | 28 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 * putting the result into dst. Returns false if an error occurs. | 39 * putting the result into dst. Returns false if an error occurs. |
| 41 */ | 40 */ |
| 42 static bool Deflate(const SkData*, SkWStream* dst); | 41 static bool Deflate(const SkData*, SkWStream* dst); |
| 43 | 42 |
| 44 /** Use the flate compression algorithm to decompress the data in src, | 43 /** Use the flate compression algorithm to decompress the data in src, |
| 45 putting the result into dst. Returns false if an error occurs. | 44 putting the result into dst. Returns false if an error occurs. |
| 46 */ | 45 */ |
| 47 static bool Inflate(SkStream* src, SkWStream* dst); | 46 static bool Inflate(SkStream* src, SkWStream* dst); |
| 48 }; | 47 }; |
| 49 | 48 |
| 49 /** |
| 50 * Wrap a stream in this class to compress the information written to |
| 51 * this stream using the Deflate algorithm. Uses Zlib's |
| 52 * Z_DEFAULT_COMPRESSION level. |
| 53 * |
| 54 * See http://en.wikipedia.org/wiki/DEFLATE |
| 55 */ |
| 56 class SkDeflateWStream : public SkWStream { |
| 57 public: |
| 58 /** Does not take ownership of the stream. */ |
| 59 SkDeflateWStream(SkWStream*); |
| 60 |
| 61 /** The destructor calls finalize(). */ |
| 62 ~SkDeflateWStream(); |
| 63 |
| 64 /** Write the end of the compressed stream. All subsequent calls to |
| 65 write() will fail. Subsequent calls to finalize() do nothing. */ |
| 66 void finalize(); |
| 67 |
| 68 // The SkWStream interface: |
| 69 bool write(const void*, size_t) SK_OVERRIDE; |
| 70 size_t bytesWritten() const SK_OVERRIDE; |
| 71 |
| 72 private: |
| 73 struct Impl; |
| 74 SkAutoTDelete<Impl> fImpl; |
| 75 }; |
| 76 |
| 50 #endif // SK_NO_FLATE | 77 #endif // SK_NO_FLATE |
| 51 #endif // SkFlate_DEFINED | 78 #endif // SkFlate_DEFINED |
| OLD | NEW |