OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 if (!m_pngDecoders[index]) { | 211 if (!m_pngDecoders[index]) { |
212 AlphaOption alphaOption = | 212 AlphaOption alphaOption = |
213 m_premultiplyAlpha ? AlphaPremultiplied : AlphaNotPremultiplied; | 213 m_premultiplyAlpha ? AlphaPremultiplied : AlphaNotPremultiplied; |
214 m_pngDecoders[index] = WTF::wrapUnique( | 214 m_pngDecoders[index] = WTF::wrapUnique( |
215 new PNGImageDecoder(alphaOption, m_colorBehavior, m_maxDecodedBytes, | 215 new PNGImageDecoder(alphaOption, m_colorBehavior, m_maxDecodedBytes, |
216 dirEntry.m_imageOffset)); | 216 dirEntry.m_imageOffset)); |
217 setDataForPNGDecoderAtIndex(index); | 217 setDataForPNGDecoderAtIndex(index); |
218 } | 218 } |
219 // Fail if the size the PNGImageDecoder calculated does not match the size | 219 // Fail if the size the PNGImageDecoder calculated does not match the size |
220 // in the directory. | 220 // in the directory. |
221 if (m_pngDecoders[index]->isSizeAvailable() && | 221 auto* pngDecoder = m_pngDecoders[index].get(); |
222 (m_pngDecoders[index]->size() != dirEntry.m_size)) | 222 if (pngDecoder->isSizeAvailable() && pngDecoder->size() != dirEntry.m_size) |
223 return setFailed(); | 223 return setFailed(); |
224 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); | 224 if (const auto* frame = pngDecoder->frameBufferAtIndex(0)) |
Peter Kasting
2017/03/20 20:42:15
Nit: Conditional-with-side-effect always kinda wor
scroggo_chromium
2017/03/21 16:03:31
I do not have a strong preference here. noel@ has
| |
225 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); | 225 m_frameBufferCache[index] = *frame; |
226 return !m_pngDecoders[index]->failed() || setFailed(); | 226 return !pngDecoder->failed() || setFailed(); |
227 } | 227 } |
228 | 228 |
229 bool ICOImageDecoder::processDirectory() { | 229 bool ICOImageDecoder::processDirectory() { |
230 // Read directory. | 230 // Read directory. |
231 DCHECK(!m_decodedOffset); | 231 DCHECK(!m_decodedOffset); |
232 if (m_data->size() < sizeOfDirectory) | 232 if (m_data->size() < sizeOfDirectory) |
233 return false; | 233 return false; |
234 const uint16_t fileType = readUint16(2); | 234 const uint16_t fileType = readUint16(2); |
235 m_dirEntriesCount = readUint16(4); | 235 m_dirEntriesCount = readUint16(4); |
236 m_decodedOffset = sizeOfDirectory; | 236 m_decodedOffset = sizeOfDirectory; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 SECURITY_DCHECK(index < m_dirEntries.size()); | 325 SECURITY_DCHECK(index < m_dirEntries.size()); |
326 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; | 326 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; |
327 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) | 327 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) |
328 return Unknown; | 328 return Unknown; |
329 char buffer[4]; | 329 char buffer[4]; |
330 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); | 330 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); |
331 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; | 331 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; |
332 } | 332 } |
333 | 333 |
334 } // namespace blink | 334 } // namespace blink |
OLD | NEW |