| Index: Source/platform/image-decoders/ico/ICOImageDecoder.cpp
|
| diff --git a/Source/platform/image-decoders/ico/ICOImageDecoder.cpp b/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
|
| index 55afd1ea532c1692dcf00baaf56ad9b9e56dcc0c..70d05cb389f0bb5c4f34d0b9ae98a7718f733a5e 100644
|
| --- a/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
|
| +++ b/Source/platform/image-decoders/ico/ICOImageDecoder.cpp
|
| @@ -46,7 +46,6 @@
|
|
|
| ICOImageDecoder::ICOImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption colorOptions, size_t maxDecodedBytes)
|
| : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes)
|
| - , m_fastReader(nullptr)
|
| , m_decodedOffset(0)
|
| {
|
| }
|
| @@ -57,8 +56,6 @@
|
|
|
| void ICOImageDecoder::onSetData(SharedBuffer* data)
|
| {
|
| - m_fastReader.setData(data);
|
| -
|
| for (BMPReaders::iterator i(m_bmpReaders.begin()); i != m_bmpReaders.end(); ++i) {
|
| if (*i)
|
| (*i)->setData(data);
|
| @@ -129,7 +126,12 @@
|
| if (!m_pngDecoders[index])
|
| return;
|
|
|
| - m_pngDecoders[index]->setData(m_data.get(), isAllDataReceived());
|
| + const IconDirectoryEntry& dirEntry = m_dirEntries[index];
|
| + // Copy out PNG data to a separate vector and send to the PNG decoder.
|
| + // FIXME: Save this copy by making the PNG decoder able to take an
|
| + // optional offset.
|
| + RefPtr<SharedBuffer> pngData(SharedBuffer::create(&m_data->data()[dirEntry.m_imageOffset], m_data->size() - dirEntry.m_imageOffset));
|
| + m_pngDecoders[index]->setData(pngData.get(), isAllDataReceived());
|
| }
|
|
|
| void ICOImageDecoder::decode(size_t index, bool onlySize)
|
| @@ -184,12 +186,11 @@
|
| }
|
|
|
| if (!m_pngDecoders[index]) {
|
| - AlphaOption alphaOption = m_premultiplyAlpha ? AlphaPremultiplied : AlphaNotPremultiplied;
|
| - GammaAndColorProfileOption colorOptions = m_ignoreGammaAndColorProfile ? GammaAndColorProfileIgnored : GammaAndColorProfileApplied;
|
| - m_pngDecoders[index] = adoptPtr(new PNGImageDecoder(alphaOption, colorOptions, m_maxDecodedBytes, dirEntry.m_imageOffset));
|
| + m_pngDecoders[index] = adoptPtr(
|
| + new PNGImageDecoder(m_premultiplyAlpha ? AlphaPremultiplied : AlphaNotPremultiplied,
|
| + m_ignoreGammaAndColorProfile ? GammaAndColorProfileIgnored : GammaAndColorProfileApplied, m_maxDecodedBytes));
|
| setDataForPNGDecoderAtIndex(index);
|
| }
|
| -
|
| // Fail if the size the PNGImageDecoder calculated does not match the size
|
| // in the directory.
|
| if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size))
|
| @@ -252,14 +253,14 @@
|
| ICOImageDecoder::IconDirectoryEntry ICOImageDecoder::readDirectoryEntry()
|
| {
|
| // Read icon data.
|
| - // The following calls to readUint8() return a uint8_t, which is appropriate
|
| - // because that's the on-disk type of the width and height values. Storing
|
| - // them in ints (instead of matching uint8_ts) is so we can record dimensions
|
| - // of size 256 (which is what a zero byte really means).
|
| - int width = readUint8(0);
|
| + // The casts to uint8_t in the next few lines are because that's the on-disk
|
| + // type of the width and height values. Storing them in ints (instead of
|
| + // matching uint8_ts) is so we can record dimensions of size 256 (which is
|
| + // what a zero byte really means).
|
| + int width = static_cast<uint8_t>(m_data->data()[m_decodedOffset]);
|
| if (!width)
|
| width = 256;
|
| - int height = readUint8(1);
|
| + int height = static_cast<uint8_t>(m_data->data()[m_decodedOffset + 1]);
|
| if (!height)
|
| height = 256;
|
| IconDirectoryEntry entry;
|
| @@ -278,7 +279,7 @@
|
| // this isn't quite what the bitmap info header says later, as we only use
|
| // this value to determine which icon entry is best.
|
| if (!entry.m_bitCount) {
|
| - int colorCount = readUint8(2);
|
| + int colorCount = static_cast<uint8_t>(m_data->data()[m_decodedOffset + 2]);
|
| if (!colorCount)
|
| colorCount = 256; // Vague in the spec, needed by real-world icons.
|
| for (--colorCount; colorCount; colorCount >>= 1)
|
| @@ -297,9 +298,7 @@
|
| const uint32_t imageOffset = m_dirEntries[index].m_imageOffset;
|
| if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4))
|
| return Unknown;
|
| - char buffer[4];
|
| - const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer);
|
| - return strncmp(data, "\x89PNG", 4) ? BMP : PNG;
|
| -}
|
| -
|
| -}
|
| + return strncmp(&m_data->data()[imageOffset], "\x89PNG", 4) ? BMP : PNG;
|
| +}
|
| +
|
| +}
|
|
|