Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Unified Diff: third_party/WebKit/Source/platform/image-encoders/PNGImageEncoder.cpp

Issue 2062423002: Fix performance regression in png encoding caused by libpng update (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/libpng/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | third_party/libpng/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698