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

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

Issue 2385993002: Rewrap comments to 80 columns in Source/platform/image-decoders/. (Closed)
Patch Set: Rewrite comment Created 4 years, 2 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
11 * modify it under the terms of the GNU Lesser General Public 11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version. 13 * version 2.1 of the License, or (at your option) any later version.
14 * 14 *
15 * This library is distributed in the hope that it will be useful, 15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details. 18 * Lesser General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU Lesser General Public 20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software 21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US A 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * 23 *
24 * Alternatively, the contents of this file may be used under the terms 24 * Alternatively, the contents of this file may be used under the terms
25 * of either the Mozilla Public License Version 1.1, found at 25 * of either the Mozilla Public License Version 1.1, found at
26 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public 26 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
27 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html 27 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
28 * (the "GPL"), in which case the provisions of the MPL or the GPL are 28 * (the "GPL"), in which case the provisions of the MPL or the GPL are
29 * applicable instead of those above. If you wish to allow use of your 29 * applicable instead of those above. If you wish to allow use of your
30 * version of this file only under the terms of one of those two 30 * version of this file only under the terms of one of those two
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
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 219
220 if (bitDepth == 16) 220 if (bitDepth == 16)
221 png_set_strip_16(png); 221 png_set_strip_16(png);
222 222
223 if (colorType == PNG_COLOR_TYPE_GRAY || 223 if (colorType == PNG_COLOR_TYPE_GRAY ||
224 colorType == PNG_COLOR_TYPE_GRAY_ALPHA) 224 colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
225 png_set_gray_to_rgb(png); 225 png_set_gray_to_rgb(png);
226 226
227 if ((colorType & PNG_COLOR_MASK_COLOR) && !m_ignoreGammaAndColorProfile) { 227 if ((colorType & PNG_COLOR_MASK_COLOR) && !m_ignoreGammaAndColorProfile) {
228 // We only support color profiles for color PALETTE and RGB[A] PNG. Supporti ng 228 // We only support color profiles for color PALETTE and RGB[A] PNG.
229 // color profiles for gray-scale images is slightly tricky, at least using t he 229 // Supporting color profiles for gray-scale images is slightly tricky, at
230 // CoreGraphics ICC library, because we expand gray-scale images to RGB but we 230 // least using the CoreGraphics ICC library, because we expand gray-scale
231 // do not similarly transform the color profile. We'd either need to transfo rm 231 // images to RGB but we do not similarly transform the color profile. We'd
232 // the color profile or we'd need to decode into a gray-scale image buffer a nd 232 // either need to transform the color profile or we'd need to decode into a
233 // hand that to CoreGraphics. 233 // gray-scale image buffer and hand that to CoreGraphics.
234 bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount; 234 bool imageHasAlpha = (colorType & PNG_COLOR_MASK_ALPHA) || trnsCount;
235 #ifdef PNG_iCCP_SUPPORTED 235 #ifdef PNG_iCCP_SUPPORTED
236 if (png_get_valid(png, info, PNG_INFO_sRGB)) { 236 if (png_get_valid(png, info, PNG_INFO_sRGB)) {
237 setColorProfileAndComputeTransform(nullptr, 0, imageHasAlpha, 237 setColorProfileAndComputeTransform(nullptr, 0, imageHasAlpha,
238 true /* useSRGB */); 238 true /* useSRGB */);
239 } else { 239 } else {
240 char* profileName = nullptr; 240 char* profileName = nullptr;
241 int compressionType = 0; 241 int compressionType = 0;
242 #if (PNG_LIBPNG_VER < 10500) 242 #if (PNG_LIBPNG_VER < 10500)
243 png_charp profile = nullptr; 243 png_charp profile = nullptr;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 png_read_update_info(png, info); 280 png_read_update_info(png, info);
281 channels = png_get_channels(png, info); 281 channels = png_get_channels(png, info);
282 ASSERT(channels == 3 || channels == 4); 282 ASSERT(channels == 3 || channels == 4);
283 283
284 m_reader->setHasAlpha(channels == 4); 284 m_reader->setHasAlpha(channels == 4);
285 285
286 if (m_reader->decodingSizeOnly()) { 286 if (m_reader->decodingSizeOnly()) {
287 // If we only needed the size, halt the reader. 287 // If we only needed the size, halt the reader.
288 #if PNG_LIBPNG_VER_MAJOR > 1 || \ 288 #if PNG_LIBPNG_VER_MAJOR > 1 || \
289 (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 5) 289 (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 5)
290 // '0' argument to png_process_data_pause means: Do not cache unprocessed da ta. 290 // Passing '0' tells png_process_data_pause() not to cache unprocessed data.
291 m_reader->setReadOffset(m_reader->currentBufferSize() - 291 m_reader->setReadOffset(m_reader->currentBufferSize() -
292 png_process_data_pause(png, 0)); 292 png_process_data_pause(png, 0));
293 #else 293 #else
294 m_reader->setReadOffset(m_reader->currentBufferSize() - png->buffer_size); 294 m_reader->setReadOffset(m_reader->currentBufferSize() - png->buffer_size);
295 png->buffer_size = 0; 295 png->buffer_size = 0;
296 #endif 296 #endif
297 } 297 }
298 } 298 }
299 299
300 void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, 300 void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // has failed. 450 // has failed.
451 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) 451 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
452 setFailed(); 452 setFailed();
453 453
454 // If decoding is done or failed, we don't need the PNGImageReader anymore. 454 // If decoding is done or failed, we don't need the PNGImageReader anymore.
455 if (isComplete(this) || failed()) 455 if (isComplete(this) || failed())
456 m_reader.reset(); 456 m_reader.reset();
457 } 457 }
458 458
459 } // namespace blink 459 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698