3 * Copyright 2010 The Android Open Source Project
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #ifndef SkFlate_DEFINED
11 #define SkFlate_DEFINED
21 A class to provide access to the flate compression algorithm.
26 * Use the flate compression algorithm to compress the data in src,
27 * putting the result into dst. Returns false if an error occurs.
29 static bool Deflate(SkStream* src, SkWStream* dst);
32 * Use the flate compression algorithm to compress the data in src,
33 * putting the result into dst. Returns false if an error occurs.
35 static bool Deflate(const void* src, size_t len, SkWStream* dst);
38 * Use the flate compression algorithm to compress the data,
39 * putting the result into dst. Returns false if an error occurs.
41 static bool Deflate(const SkData*, SkWStream* dst);
43 /** Use the flate compression algorithm to decompress the data in src,
44 putting the result into dst. Returns false if an error occurs.
46 static bool Inflate(SkStream* src, SkWStream* dst);
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.
54 * See http://en.wikipedia.org/wiki/DEFLATE
56 class SkDeflateWStream : public SkWStream {
58 /** Does not take ownership of the stream. */
59 SkDeflateWStream(SkWStream*);
61 /** The destructor calls finalize(). */
64 /** Write the end of the compressed stream. All subsequent calls to
65 write() will fail. Subsequent calls to finalize() do nothing. */
68 // The SkWStream interface:
69 bool write(const void*, size_t) SK_OVERRIDE;
70 size_t bytesWritten() const SK_OVERRIDE;
74 SkAutoTDelete<Impl> fImpl;
78 #endif // SkFlate_DEFINED