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

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

Issue 15350006: Decode GIF image frames on demand. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 7 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // The size calculated inside the BMPImageReader had better match the one in 95 // The size calculated inside the BMPImageReader had better match the one in
96 // the icon directory. 96 // the icon directory.
97 return m_frameSize.isEmpty() ? ImageDecoder::setSize(width, height) : ((IntS ize(width, height) == m_frameSize) || setFailed()); 97 return m_frameSize.isEmpty() ? ImageDecoder::setSize(width, height) : ((IntS ize(width, height) == m_frameSize) || setFailed());
98 } 98 }
99 99
100 size_t ICOImageDecoder::frameCount() 100 size_t ICOImageDecoder::frameCount()
101 { 101 {
102 decode(0, true); 102 decode(0, true);
103 if (m_frameBufferCache.isEmpty()) { 103 if (m_frameBufferCache.isEmpty()) {
104 m_frameBufferCache.resize(m_dirEntries.size()); 104 m_frameBufferCache.resize(m_dirEntries.size());
105 for (size_t i = 0; i < m_dirEntries.size(); ++i) 105 for (size_t i = 0; i < m_dirEntries.size(); ++i) {
106 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha); 106 m_frameBufferCache[i].setPremultiplyAlpha(m_premultiplyAlpha);
107 m_frameBufferCache[i].setRequiredPreviousFrameIndex(notFound);
108 }
107 } 109 }
108 // CAUTION: We must not resize m_frameBufferCache again after this, as 110 // CAUTION: We must not resize m_frameBufferCache again after this, as
109 // decodeAtIndex() may give a BMPImageReader a pointer to one of the 111 // decodeAtIndex() may give a BMPImageReader a pointer to one of the
110 // entries. 112 // entries.
111 return m_frameBufferCache.size(); 113 return m_frameBufferCache.size();
112 } 114 }
113 115
114 ImageFrame* ICOImageDecoder::frameBufferAtIndex(size_t index) 116 ImageFrame* ICOImageDecoder::frameBufferAtIndex(size_t index)
115 { 117 {
116 // Ensure |index| is valid. 118 // Ensure |index| is valid.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Check if this entry is a BMP or a PNG; we need 4 bytes to check the magic 335 // Check if this entry is a BMP or a PNG; we need 4 bytes to check the magic
334 // number. 336 // number.
335 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size()); 337 ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size());
336 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset; 338 const uint32_t imageOffset = m_dirEntries[index].m_imageOffset;
337 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4)) 339 if ((imageOffset > m_data->size()) || ((m_data->size() - imageOffset) < 4))
338 return Unknown; 340 return Unknown;
339 return strncmp(&m_data->data()[imageOffset], "\x89PNG", 4) ? BMP : PNG; 341 return strncmp(&m_data->data()[imageOffset], "\x89PNG", 4) ? BMP : PNG;
340 } 342 }
341 343
342 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698