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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.cpp

Issue 2021403002: Update libpng to 1.6.22 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rearrange pnglibconf.h 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | third_party/libpng/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. 2 * Copyright (C) 2006 Apple Computer, Inc.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Portions are Copyright (C) 2001 mozilla.org 5 * Portions are Copyright (C) 2001 mozilla.org
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Stuart Parmenter <stuart@mozilla.com> 8 * Stuart Parmenter <stuart@mozilla.com>
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 20 matching lines...) Expand all
31 * licenses (the MPL or the GPL) and not to allow others to use your 31 * licenses (the MPL or the GPL) and not to allow others to use your
32 * version of this file under the LGPL, indicate your decision by 32 * version of this file under the LGPL, indicate your decision by
33 * deletingthe provisions above and replace them with the notice and 33 * deletingthe provisions above and replace them with the notice and
34 * other provisions required by the MPL or the GPL, as the case may be. 34 * other provisions required by the MPL or the GPL, as the case may be.
35 * If you do not delete the provisions above, a recipient may use your 35 * If you do not delete the provisions above, a recipient may use your
36 * version of this file under any of the LGPL, the MPL or the GPL. 36 * version of this file under any of the LGPL, the MPL or the GPL.
37 */ 37 */
38 38
39 #include "platform/image-decoders/png/PNGImageDecoder.h" 39 #include "platform/image-decoders/png/PNGImageDecoder.h"
40 40
41 #include "platform/Histogram.h"
42 #include "png.h" 41 #include "png.h"
43 #include "wtf/Threading.h"
44 42
45 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR) 43 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR)
46 #error version error: compile against a versioned libpng. 44 #error version error: compile against a versioned libpng.
47 #endif 45 #endif
48 #if USE(QCMSLIB) 46 #if USE(QCMSLIB)
49 #include "qcms.h" 47 #include "qcms.h"
50 #endif 48 #endif
51 49
52 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4) 50 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4)
53 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr) 51 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 { 172 {
175 } 173 }
176 174
177 void PNGImageDecoder::headerAvailable() 175 void PNGImageDecoder::headerAvailable()
178 { 176 {
179 png_structp png = m_reader->pngPtr(); 177 png_structp png = m_reader->pngPtr();
180 png_infop info = m_reader->infoPtr(); 178 png_infop info = m_reader->infoPtr();
181 png_uint_32 width = png_get_image_width(png, info); 179 png_uint_32 width = png_get_image_width(png, info);
182 png_uint_32 height = png_get_image_height(png, info); 180 png_uint_32 height = png_get_image_height(png, info);
183 181
184 DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram,
185 dimensionsLocationHistogram,
186 new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsL ocation.PNG", 0, 50000, 50));
187 dimensionsLocationHistogram.count(m_reader->getReadOffset() - png->current_b uffer_size - 1);
188
189 // Protect against large PNGs. See http://bugzil.la/251381 for more details. 182 // Protect against large PNGs. See http://bugzil.la/251381 for more details.
190 const unsigned long maxPNGSize = 1000000UL; 183 const unsigned long maxPNGSize = 1000000UL;
191 if (width > maxPNGSize || height > maxPNGSize) { 184 if (width > maxPNGSize || height > maxPNGSize) {
192 longjmp(JMPBUF(png), 1); 185 longjmp(JMPBUF(png), 1);
193 return; 186 return;
194 } 187 }
195 188
196 // Set the image size now that the image header is available. 189 // Set the image size now that the image header is available.
197 if (!setSize(width, height)) { 190 if (!setSize(width, height)) {
198 longjmp(JMPBUF(png), 1); 191 longjmp(JMPBUF(png), 1);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else { 229 } else {
237 char* profileName = nullptr; 230 char* profileName = nullptr;
238 int compressionType = 0; 231 int compressionType = 0;
239 #if (PNG_LIBPNG_VER < 10500) 232 #if (PNG_LIBPNG_VER < 10500)
240 png_charp profile = nullptr; 233 png_charp profile = nullptr;
241 #else 234 #else
242 png_bytep profile = nullptr; 235 png_bytep profile = nullptr;
243 #endif 236 #endif
244 png_uint_32 profileLength = 0; 237 png_uint_32 profileLength = 0;
245 if (png_get_iCCP(png, info, &profileName, &compressionType, &profile , &profileLength)) { 238 if (png_get_iCCP(png, info, &profileName, &compressionType, &profile , &profileLength)) {
246 setColorProfileAndTransform(profile, profileLength, imageHasAlph a, false /* useSRGB */); 239 setColorProfileAndTransform(reinterpret_cast<char*>(profile), pr ofileLength, imageHasAlpha, false /* useSRGB */);
247 } 240 }
248 } 241 }
249 #endif // PNG_iCCP_SUPPORTED 242 #endif // PNG_iCCP_SUPPORTED
250 } 243 }
251 #endif // USE(QCMSLIB) 244 #endif // USE(QCMSLIB)
252 245
253 if (!hasColorProfile()) { 246 if (!hasColorProfile()) {
254 // Deal with gamma and keep it under our control. 247 // Deal with gamma and keep it under our control.
255 const double inverseGamma = 0.45455; 248 const double inverseGamma = 0.45455;
256 const double defaultGamma = 2.2; 249 const double defaultGamma = 2.2;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // has failed. 434 // has failed.
442 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 435 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
443 setFailed(); 436 setFailed();
444 437
445 // If decoding is done or failed, we don't need the PNGImageReader anymore. 438 // If decoding is done or failed, we don't need the PNGImageReader anymore.
446 if (isComplete(this) || failed()) 439 if (isComplete(this) || failed())
447 m_reader.reset(); 440 m_reader.reset();
448 } 441 }
449 442
450 } // namespace blink 443 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | third_party/libpng/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698