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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ico/ICOImageDecoder.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. 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) 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/image-decoders/ico/ICOImageDecoder.h" 31 #include "platform/image-decoders/ico/ICOImageDecoder.h"
32 32
33 #include "platform/Histogram.h" 33 #include "platform/Histogram.h"
34 #include "platform/image-decoders/png/PNGImageDecoder.h" 34 #include "platform/image-decoders/png/PNGImageDecoder.h"
35 #include "wtf/PassOwnPtr.h" 35 #include "wtf/PtrUtil.h"
36 #include "wtf/Threading.h" 36 #include "wtf/Threading.h"
37
38 #include <algorithm> 37 #include <algorithm>
39 38
40 namespace blink { 39 namespace blink {
41 40
42 // Number of bits in .ICO/.CUR used to store the directory and its entries, 41 // Number of bits in .ICO/.CUR used to store the directory and its entries,
43 // 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
44 // some fields). 43 // some fields).
45 static const size_t sizeOfDirectory = 6; 44 static const size_t sizeOfDirectory = 6;
46 static const size_t sizeOfDirEntry = 16; 45 static const size_t sizeOfDirEntry = 16;
47 46
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 const IconDirectoryEntry& dirEntry = m_dirEntries[index]; 170 const IconDirectoryEntry& dirEntry = m_dirEntries[index];
172 const ImageType imageType = imageTypeAtIndex(index); 171 const ImageType imageType = imageTypeAtIndex(index);
173 if (imageType == Unknown) 172 if (imageType == Unknown)
174 return false; // Not enough data to determine image type yet. 173 return false; // Not enough data to determine image type yet.
175 174
176 if (imageType == BMP) { 175 if (imageType == BMP) {
177 if (!m_bmpReaders[index]) { 176 if (!m_bmpReaders[index]) {
178 // We need to have already sized m_frameBufferCache before this, and 177 // We need to have already sized m_frameBufferCache before this, and
179 // we must not resize it again later (see caution in frameCount()). 178 // we must not resize it again later (see caution in frameCount()).
180 ASSERT(m_frameBufferCache.size() == m_dirEntries.size()); 179 ASSERT(m_frameBufferCache.size() == m_dirEntries.size());
181 m_bmpReaders[index] = adoptPtr(new BMPImageReader(this, dirEntry.m_i mageOffset, 0, true)); 180 m_bmpReaders[index] = wrapUnique(new BMPImageReader(this, dirEntry.m _imageOffset, 0, true));
182 m_bmpReaders[index]->setData(m_data.get()); 181 m_bmpReaders[index]->setData(m_data.get());
183 m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]); 182 m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]);
184 } 183 }
185 m_frameSize = dirEntry.m_size; 184 m_frameSize = dirEntry.m_size;
186 bool result = m_bmpReaders[index]->decodeBMP(false); 185 bool result = m_bmpReaders[index]->decodeBMP(false);
187 m_frameSize = IntSize(); 186 m_frameSize = IntSize();
188 return result; 187 return result;
189 } 188 }
190 189
191 if (!m_pngDecoders[index]) { 190 if (!m_pngDecoders[index]) {
192 AlphaOption alphaOption = m_premultiplyAlpha ? AlphaPremultiplied : Alph aNotPremultiplied; 191 AlphaOption alphaOption = m_premultiplyAlpha ? AlphaPremultiplied : Alph aNotPremultiplied;
193 GammaAndColorProfileOption colorOptions = m_ignoreGammaAndColorProfile ? GammaAndColorProfileIgnored : GammaAndColorProfileApplied; 192 GammaAndColorProfileOption colorOptions = m_ignoreGammaAndColorProfile ? GammaAndColorProfileIgnored : GammaAndColorProfileApplied;
194 m_pngDecoders[index] = adoptPtr(new PNGImageDecoder(alphaOption, colorOp tions, m_maxDecodedBytes, dirEntry.m_imageOffset)); 193 m_pngDecoders[index] = wrapUnique(new PNGImageDecoder(alphaOption, color Options, m_maxDecodedBytes, dirEntry.m_imageOffset));
195 setDataForPNGDecoderAtIndex(index); 194 setDataForPNGDecoderAtIndex(index);
196 } 195 }
197 // Fail if the size the PNGImageDecoder calculated does not match the size 196 // Fail if the size the PNGImageDecoder calculated does not match the size
198 // in the directory. 197 // in the directory.
199 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size)) 198 if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size))
200 return setFailed(); 199 return setFailed();
201 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0); 200 m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0);
202 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha); 201 m_frameBufferCache[index].setPremultiplyAlpha(m_premultiplyAlpha);
203 return !m_pngDecoders[index]->failed() || setFailed(); 202 return !m_pngDecoders[index]->failed() || setFailed();
204 } 203 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); 304 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size());
306 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; 305 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset;
307 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) 306 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4))
308 return Unknown; 307 return Unknown;
309 char buffer[4]; 308 char buffer[4];
310 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer); 309 const char* data = m_fastReader.getConsecutiveData(imageOffset, 4, buffer);
311 return strncmp(data, "\x89PNG", 4) ? BMP : PNG; 310 return strncmp(data, "\x89PNG", 4) ? BMP : PNG;
312 } 311 }
313 312
314 } // namespace blink 313 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698