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

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: Mac rebaselines 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
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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void PNGImageDecoder::headerAvailable() 177 void PNGImageDecoder::headerAvailable()
178 { 178 {
179 png_structp png = m_reader->pngPtr(); 179 png_structp png = m_reader->pngPtr();
180 png_infop info = m_reader->infoPtr(); 180 png_infop info = m_reader->infoPtr();
181 png_uint_32 width = png_get_image_width(png, info); 181 png_uint_32 width = png_get_image_width(png, info);
182 png_uint_32 height = png_get_image_height(png, info); 182 png_uint_32 height = png_get_image_height(png, info);
183 183
184 DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram, 184 DEFINE_THREAD_SAFE_STATIC_LOCAL(blink::CustomCountHistogram,
185 dimensionsLocationHistogram, 185 dimensionsLocationHistogram,
186 new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsL ocation.PNG", 0, 50000, 50)); 186 new blink::CustomCountHistogram("Blink.DecodedImage.EffectiveDimensionsL ocation.PNG", 0, 50000, 50));
187 dimensionsLocationHistogram.count(m_reader->getReadOffset() - png->current_b uffer_size - 1); 187 dimensionsLocationHistogram.count(m_reader->getReadOffset() - 1);
msarett 2016/06/03 20:18:51 @ryansturm libpng 1.6 has a stricter API that doe
RyanSturm 2016/06/03 20:31:51 You can remove the Blink.DecodedImage.EffectiveDim
msarett 2016/06/03 21:26:01 Got it thanks! It's been removed.
scroggo_chromium 2016/06/06 14:51:40 I suppose it's safe to remove the rest of them, to
188 188
189 // Protect against large PNGs. See http://bugzil.la/251381 for more details. 189 // Protect against large PNGs. See http://bugzil.la/251381 for more details.
190 const unsigned long maxPNGSize = 1000000UL; 190 const unsigned long maxPNGSize = 1000000UL;
191 if (width > maxPNGSize || height > maxPNGSize) { 191 if (width > maxPNGSize || height > maxPNGSize) {
192 longjmp(JMPBUF(png), 1); 192 longjmp(JMPBUF(png), 1);
193 return; 193 return;
194 } 194 }
195 195
196 // Set the image size now that the image header is available. 196 // Set the image size now that the image header is available.
197 if (!setSize(width, height)) { 197 if (!setSize(width, height)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // do not similarly transform the color profile. We'd either need to tra nsform 229 // do not similarly transform the color profile. We'd either need to tra nsform
230 // the color profile or we'd need to decode into a gray-scale image buff er and 230 // the color profile or we'd need to decode into a gray-scale image buff er and
231 // hand that to CoreGraphics. 231 // hand that to CoreGraphics.
232 bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount; 232 bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
233 #ifdef PNG_iCCP_SUPPORTED 233 #ifdef PNG_iCCP_SUPPORTED
234 if (png_get_valid(png, info, PNG_INFO_sRGB)) { 234 if (png_get_valid(png, info, PNG_INFO_sRGB)) {
235 setColorProfileAndTransform(nullptr, 0, imageHasAlpha, true /* useSR GB */); 235 setColorProfileAndTransform(nullptr, 0, imageHasAlpha, true /* useSR GB */);
236 } else { 236 } else {
237 char* profileName = nullptr; 237 char* profileName = nullptr;
238 int compressionType = 0; 238 int compressionType = 0;
239 #if (PNG_LIBPNG_VER < 10500) 239 #if (PNG_LIBPNG_VER < 10500)
Nico 2016/06/03 20:27:44 looks like you can tweak this instead of casting?
msarett 2016/06/03 21:26:01 png_get_iCCP needs profile to be an unsigned char*
Nico 2016/06/03 21:36:49 Hm, the other caller of setColorProfileAndTransfor
msarett 2016/06/06 14:18:15 Done.
240 png_charp profile = nullptr; 240 png_charp profile = nullptr;
241 #else 241 #else
242 png_bytep profile = nullptr; 242 png_bytep profile = nullptr;
243 #endif 243 #endif
244 png_uint_32 profileLength = 0; 244 png_uint_32 profileLength = 0;
245 if (png_get_iCCP(png, info, &profileName, &compressionType, &profile , &profileLength)) { 245 if (png_get_iCCP(png, info, &profileName, &compressionType, &profile , &profileLength)) {
246 setColorProfileAndTransform(profile, profileLength, imageHasAlph a, false /* useSRGB */); 246 setColorProfileAndTransform((char*) profile, profileLength, imag eHasAlpha, false /* useSRGB */);
247 } 247 }
248 } 248 }
249 #endif // PNG_iCCP_SUPPORTED 249 #endif // PNG_iCCP_SUPPORTED
250 } 250 }
251 #endif // USE(QCMSLIB) 251 #endif // USE(QCMSLIB)
252 252
253 if (!hasColorProfile()) { 253 if (!hasColorProfile()) {
254 // Deal with gamma and keep it under our control. 254 // Deal with gamma and keep it under our control.
255 const double inverseGamma = 0.45455; 255 const double inverseGamma = 0.45455;
256 const double defaultGamma = 2.2; 256 const double defaultGamma = 2.2;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // has failed. 441 // has failed.
442 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 442 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
443 setFailed(); 443 setFailed();
444 444
445 // If decoding is done or failed, we don't need the PNGImageReader anymore. 445 // If decoding is done or failed, we don't need the PNGImageReader anymore.
446 if (isComplete(this) || failed()) 446 if (isComplete(this) || failed())
447 m_reader.reset(); 447 m_reader.reset();
448 } 448 }
449 449
450 } // namespace blink 450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698