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