Index: third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp |
diff --git a/third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp b/third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp |
index cfaae3f159f23f773b9a2b2a62cf7b69dbd47bc1..3553da1552c57dc8a4356ab00f1b12e1394a279f 100644 |
--- a/third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp |
+++ b/third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp |
@@ -33,6 +33,8 @@ |
#include "platform/graphics/ImageBuffer.h" |
#include "wtf/OwnPtr.h" |
+#include "zlib.h" |
+ |
namespace blink { |
PNGImageEncoderState::~PNGImageEncoderState() |
@@ -59,14 +61,19 @@ PassOwnPtr<PNGImageEncoderState> PNGImageEncoderState::create(const IntSize& ima |
// Optimize compression for speed. |
// The parameters are the same as what libpng uses by default for RGB and RGBA images, except: |
- // - the zlib compression level is 3 instead of 6, to avoid the lazy Ziv-Lempel match searching; |
- // - the delta filter is 1 ("sub") instead of 5 ("all"), to reduce the filter computations. |
- // The zlib memory level (8) and strategy (Z_FILTERED) will be set inside libpng. |
- // |
+ // The zlib compression level is set to 3 instead of 6, to avoid the lazy Ziv-Lempel match searching. |
+ png_set_compression_level(png, 3); |
+ |
+ // The zlib memory level is set to 8. This actually matches the default, we are just future-proofing. |
+ png_set_compression_mem_level(png, 8); |
+ |
+ // The zlib strategy is set to Z_FILTERED, which does not match the default. |
// Avoid the zlib strategies Z_HUFFMAN_ONLY or Z_RLE. |
// Although they are the fastest for poorly-compressible images (e.g. photographs), |
// they are very slow for highly-compressible images (e.g. text, drawings or business graphics) |
- png_set_compression_level(png, 3); |
+ png_set_compression_strategy(png, Z_FILTERED); |
+ |
+ // The delta filter is PNG_FILTER_SUB instead of PNG_ALL_FILTERS, to reduce the filter computations. |
png_set_filter(png, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB); |
png_set_write_fn(png, output, writeOutput, 0); |