| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // respectively (doesn't match sizeof values for member structs since we omit | 42 // respectively (doesn't match sizeof values for member structs since we omit |
| 43 // some fields). | 43 // some fields). |
| 44 static const size_t sizeOfDirectory = 6; | 44 static const size_t sizeOfDirectory = 6; |
| 45 static const size_t sizeOfDirEntry = 16; | 45 static const size_t sizeOfDirEntry = 16; |
| 46 | 46 |
| 47 ICOImageDecoder::ICOImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
tion colorOptions, size_t maxDecodedBytes) | 47 ICOImageDecoder::ICOImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOp
tion colorOptions, size_t maxDecodedBytes) |
| 48 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) | 48 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) |
| 49 , m_fastReader(nullptr) | 49 , m_fastReader(nullptr) |
| 50 , m_decodedOffset(0) | 50 , m_decodedOffset(0) |
| 51 , m_dirEntriesCount(0) | 51 , m_dirEntriesCount(0) |
| 52 , m_gammaAndColorProfileOption(colorOptions) |
| 52 { | 53 { |
| 53 } | 54 } |
| 54 | 55 |
| 55 ICOImageDecoder::~ICOImageDecoder() | 56 ICOImageDecoder::~ICOImageDecoder() |
| 56 { | 57 { |
| 57 } | 58 } |
| 58 | 59 |
| 59 void ICOImageDecoder::onSetData(SegmentReader* data) | 60 void ICOImageDecoder::onSetData(SegmentReader* data) |
| 60 { | 61 { |
| 61 m_fastReader.setData(data); | 62 m_fastReader.setData(data); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // m_frameBufferCache.resize(). | 204 // m_frameBufferCache.resize(). |
| 204 m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]); | 205 m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]); |
| 205 m_frameSize = dirEntry.m_size; | 206 m_frameSize = dirEntry.m_size; |
| 206 bool result = m_bmpReaders[index]->decodeBMP(false); | 207 bool result = m_bmpReaders[index]->decodeBMP(false); |
| 207 m_frameSize = IntSize(); | 208 m_frameSize = IntSize(); |
| 208 return result; | 209 return result; |
| 209 } | 210 } |
| 210 | 211 |
| 211 if (!m_pngDecoders[index]) { | 212 if (!m_pngDecoders[index]) { |
| 212 AlphaOption alphaOption = m_premultiplyAlpha ? AlphaPremultiplied : Alph
aNotPremultiplied; | 213 AlphaOption alphaOption = m_premultiplyAlpha ? AlphaPremultiplied : Alph
aNotPremultiplied; |
| 213 GammaAndColorProfileOption colorOptions = m_ignoreGammaAndColorProfile ?
GammaAndColorProfileIgnored : GammaAndColorProfileApplied; | 214 m_pngDecoders[index] = wrapUnique(new PNGImageDecoder(alphaOption, m_gam
maAndColorProfileOption, m_maxDecodedBytes, dirEntry.m_imageOffset)); |
| 214 m_pngDecoders[index] = wrapUnique(new PNGImageDecoder(alphaOption, color
Options, m_maxDecodedBytes, dirEntry.m_imageOffset)); | |
| 215 setDataForPNGDecoderAtIndex(index); | 215 setDataForPNGDecoderAtIndex(index); |
| 216 } | 216 } |
| 217 // Fail if the size the PNGImageDecoder calculated does not match the size | 217 // Fail if the size the PNGImageDecoder calculated does not match the size |
| 218 // in the directory. | 218 // in the directory. |
| 219 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size()
!= dirEntry.m_size)) | 219 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size()
!= dirEntry.m_size)) |
| 220 return setFailed(); | 220 return setFailed(); |
| 221 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); | 221 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); |
| 222 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); | 222 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); |
| 223 return !m_pngDecoders[index]->failed() || setFailed(); | 223 return !m_pngDecoders[index]->failed() || setFailed(); |
| 224 } | 224 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); | 327 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); |
| 328 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; | 328 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; |
| 329 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) | 329 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) |
| 330 return Unknown; | 330 return Unknown; |
| 331 char buffer[4]; | 331 char buffer[4]; |
| 332 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); | 332 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); |
| 333 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; | 333 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |