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

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: Response to comments 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" 42 #include "wtf/Threading.h"
RyanSturm 2016/06/03 21:55:31 You shouldn't need wtf/threading.h since you remov
msarett 2016/06/06 14:18:16 Thanks! Done.
44 43
45 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR) 44 #if !defined(PNG_LIBPNG_VER_MAJOR) || !defined(PNG_LIBPNG_VER_MINOR)
46 #error version error: compile against a versioned libpng. 45 #error version error: compile against a versioned libpng.
47 #endif 46 #endif
48 #if USE(QCMSLIB) 47 #if USE(QCMSLIB)
49 #include "qcms.h" 48 #include "qcms.h"
50 #endif 49 #endif
51 50
52 #if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MIN OR >= 4) 51 #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) 52 #define JMPBUF(png_ptr) png_jmpbuf(png_ptr)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 { 173 {
175 } 174 }
176 175
177 void PNGImageDecoder::headerAvailable() 176 void PNGImageDecoder::headerAvailable()
178 { 177 {
179 png_structp png = m_reader->pngPtr(); 178 png_structp png = m_reader->pngPtr();
180 png_infop info = m_reader->infoPtr(); 179 png_infop info = m_reader->infoPtr();
181 png_uint_32 width = png_get_image_width(png, info); 180 png_uint_32 width = png_get_image_width(png, info);
182 png_uint_32 height = png_get_image_height(png, info); 181 png_uint_32 height = png_get_image_height(png, info);
183 182
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. 183 // Protect against large PNGs. See http://bugzil.la/251381 for more details.
190 const unsigned long maxPNGSize = 1000000UL; 184 const unsigned long maxPNGSize = 1000000UL;
191 if (width > maxPNGSize || height > maxPNGSize) { 185 if (width > maxPNGSize || height > maxPNGSize) {
192 longjmp(JMPBUF(png), 1); 186 longjmp(JMPBUF(png), 1);
193 return; 187 return;
194 } 188 }
195 189
196 // Set the image size now that the image header is available. 190 // Set the image size now that the image header is available.
197 if (!setSize(width, height)) { 191 if (!setSize(width, height)) {
198 longjmp(JMPBUF(png), 1); 192 longjmp(JMPBUF(png), 1);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else { 230 } else {
237 char* profileName = nullptr; 231 char* profileName = nullptr;
238 int compressionType = 0; 232 int compressionType = 0;
239 #if (PNG_LIBPNG_VER < 10500) 233 #if (PNG_LIBPNG_VER < 10500)
240 png_charp profile = nullptr; 234 png_charp profile = nullptr;
241 #else 235 #else
242 png_bytep profile = nullptr; 236 png_bytep profile = nullptr;
243 #endif 237 #endif
244 png_uint_32 profileLength = 0; 238 png_uint_32 profileLength = 0;
245 if (png_get_iCCP(png, info, &profileName, &compressionType, &profile , &profileLength)) { 239 if (png_get_iCCP(png, info, &profileName, &compressionType, &profile , &profileLength)) {
246 setColorProfileAndTransform(profile, profileLength, imageHasAlph a, false /* useSRGB */); 240 setColorProfileAndTransform((char*) profile, profileLength, imag eHasAlpha, false /* useSRGB */);
247 } 241 }
248 } 242 }
249 #endif // PNG_iCCP_SUPPORTED 243 #endif // PNG_iCCP_SUPPORTED
250 } 244 }
251 #endif // USE(QCMSLIB) 245 #endif // USE(QCMSLIB)
252 246
253 if (!hasColorProfile()) { 247 if (!hasColorProfile()) {
254 // Deal with gamma and keep it under our control. 248 // Deal with gamma and keep it under our control.
255 const double inverseGamma = 0.45455; 249 const double inverseGamma = 0.45455;
256 const double defaultGamma = 2.2; 250 const double defaultGamma = 2.2;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // has failed. 435 // has failed.
442 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 436 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
443 setFailed(); 437 setFailed();
444 438
445 // If decoding is done or failed, we don't need the PNGImageReader anymore. 439 // If decoding is done or failed, we don't need the PNGImageReader anymore.
446 if (isComplete(this) || failed()) 440 if (isComplete(this) || failed())
447 m_reader.reset(); 441 m_reader.reset();
448 } 442 }
449 443
450 } // namespace blink 444 } // 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