MCPcopy Create free account
hub / github.com/Tencent/tgfx / DeflateWriteStream

Method DeflateWriteStream

src/pdf/DeflateStream.cpp:71–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71DeflateWriteStream::DeflateWriteStream(WriteStream* outStream, int compressionLevel, bool gzip)
72 : impl(std::make_unique<DeflateWriteStream::Impl>()) {
73
74 // There has existed at some point at least one zlib implementation which thought it was being
75 // clever by randomizing the compression level. This is actually not entirely incorrect, except
76 // for the no-compression level which should always be deterministically pass-through.
77 // Users should instead consider the zero compression level broken and handle it themselves.
78 DEBUG_ASSERT(compressionLevel != 0);
79
80 impl->outStream = outStream;
81 impl->inBufferIndex = 0;
82 if (!impl->outStream) {
83 return;
84 }
85 impl->ZStream.next_in = nullptr;
86 impl->ZStream.zalloc = &AllocFunction;
87 impl->ZStream.zfree = &FreeFunction;
88 impl->ZStream.opaque = nullptr;
89 DEBUG_ASSERT((compressionLevel <= 9 && compressionLevel >= -1));
90 deflateInit2(&impl->ZStream, compressionLevel, Z_DEFLATED, gzip ? 0x1F : 0x0F, 8,
91 Z_DEFAULT_STRATEGY);
92}
93
94DeflateWriteStream::~DeflateWriteStream() {
95 this->finalize();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected