Index: src/pdf/SkDeflate.cpp |
diff --git a/src/pdf/SkDeflate.cpp b/src/pdf/SkDeflate.cpp |
index 0a5b6f964addff736934f481e7c8ebadd51b89b8..3ae0d460684c7db296f4503c5271fcbab4340aa9 100644 |
--- a/src/pdf/SkDeflate.cpp |
+++ b/src/pdf/SkDeflate.cpp |
@@ -65,16 +65,23 @@ struct SkDeflateWStream::Impl { |
z_stream fZStream; |
}; |
-SkDeflateWStream::SkDeflateWStream(SkWStream* out) : fImpl(new SkDeflateWStream::Impl) { |
+SkDeflateWStream::SkDeflateWStream(SkWStream* out, |
+ int compressionLevel, |
+ bool gzip) |
+ : fImpl(new SkDeflateWStream::Impl) { |
fImpl->fOut = out; |
fImpl->fInBufferIndex = 0; |
if (!fImpl->fOut) { |
return; |
} |
+ fImpl->fZStream.next_in = nullptr; |
fImpl->fZStream.zalloc = &skia_alloc_func; |
fImpl->fZStream.zfree = &skia_free_func; |
fImpl->fZStream.opaque = nullptr; |
- SkDEBUGCODE(int r =) deflateInit(&fImpl->fZStream, Z_DEFAULT_COMPRESSION); |
+ SkASSERT(compressionLevel <= 9 && compressionLevel >= -1); |
+ SkDEBUGCODE(int r =) deflateInit2(&fImpl->fZStream, compressionLevel, |
+ Z_DEFLATED, gzip ? 0x1F : 0x0F, |
+ 8, Z_DEFAULT_STRATEGY); |
SkASSERT(Z_OK == r); |
} |