Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 111 |
| 112 void BitmapImage::destroyDecodedData() | 112 void BitmapImage::destroyDecodedData() |
| 113 { | 113 { |
| 114 m_cachedFrame.clear(); | 114 m_cachedFrame.clear(); |
| 115 for (size_t i = 0; i < m_frames.size(); ++i) | 115 for (size_t i = 0; i < m_frames.size(); ++i) |
| 116 m_frames[i].clear(true); | 116 m_frames[i].clear(true); |
| 117 m_source.clearCacheExceptFrame(kNotFound); | 117 m_source.clearCacheExceptFrame(kNotFound); |
| 118 notifyMemoryChanged(); | 118 notifyMemoryChanged(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 PassRefPtr<SharedBuffer> BitmapImage::data() | |
| 122 { | |
| 123 return m_source.data(); | |
| 124 } | |
| 125 | |
| 121 void BitmapImage::notifyMemoryChanged() | 126 void BitmapImage::notifyMemoryChanged() |
| 122 { | 127 { |
| 123 if (getImageObserver()) | 128 if (getImageObserver()) |
| 124 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); | 129 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); |
| 125 } | 130 } |
| 126 | 131 |
| 127 size_t BitmapImage::totalFrameBytes() | 132 size_t BitmapImage::totalFrameBytes() |
| 128 { | 133 { |
| 129 const size_t numFrames = frameCount(); | 134 const size_t numFrames = frameCount(); |
| 130 size_t totalBytes = 0; | 135 size_t totalBytes = 0; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 { | 182 { |
| 178 updateSize(); | 183 updateSize(); |
| 179 return m_sizeRespectingOrientation; | 184 return m_sizeRespectingOrientation; |
| 180 } | 185 } |
| 181 | 186 |
| 182 bool BitmapImage::getHotSpot(IntPoint& hotSpot) const | 187 bool BitmapImage::getHotSpot(IntPoint& hotSpot) const |
| 183 { | 188 { |
| 184 return m_source.getHotSpot(hotSpot); | 189 return m_source.getHotSpot(hotSpot); |
| 185 } | 190 } |
| 186 | 191 |
| 192 bool BitmapImage::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived) | |
| 193 { | |
| 194 m_temporaryEncodedImageData = data; | |
|
f(malita)
2016/07/08 15:34:40
Do we need m_temporaryEncodedImageData at all? Lo
hajimehoshi
2016/07/11 06:15:07
Done.
f(malita)
2016/07/12 17:10:59
Thanks, LGTM!
| |
| 195 if (!m_temporaryEncodedImageData.get()) | |
| 196 return true; | |
| 197 | |
| 198 int length = m_temporaryEncodedImageData->size(); | |
| 199 if (!length) | |
| 200 return true; | |
| 201 | |
| 202 return dataChanged(allDataReceived); | |
| 203 } | |
| 204 | |
| 187 bool BitmapImage::dataChanged(bool allDataReceived) | 205 bool BitmapImage::dataChanged(bool allDataReceived) |
| 188 { | 206 { |
| 189 TRACE_EVENT0("blink", "BitmapImage::dataChanged"); | 207 TRACE_EVENT0("blink", "BitmapImage::dataChanged"); |
| 190 | 208 |
| 191 // Clear all partially-decoded frames. For most image formats, there is only | 209 // Clear all partially-decoded frames. For most image formats, there is only |
| 192 // one frame, but at least GIF and ICO can have more. With GIFs, the frames | 210 // one frame, but at least GIF and ICO can have more. With GIFs, the frames |
| 193 // come in order and we ask to decode them in order, waiting to request a | 211 // come in order and we ask to decode them in order, waiting to request a |
| 194 // subsequent frame until the prior one is complete. Given that we clear | 212 // subsequent frame until the prior one is complete. Given that we clear |
| 195 // incomplete frames here, this means there is at most one incomplete frame | 213 // incomplete frames here, this means there is at most one incomplete frame |
| 196 // (even if we use destroyDecodedData() -- since it doesn't reset the | 214 // (even if we use destroyDecodedData() -- since it doesn't reset the |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 211 // cleared-on-a-previous-pass) frames! | 229 // cleared-on-a-previous-pass) frames! |
| 212 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) { | 230 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) { |
| 213 m_frames[i].clear(true); | 231 m_frames[i].clear(true); |
| 214 if (i == m_cachedFrameIndex) | 232 if (i == m_cachedFrameIndex) |
| 215 m_cachedFrame.clear(); | 233 m_cachedFrame.clear(); |
| 216 } | 234 } |
| 217 } | 235 } |
| 218 | 236 |
| 219 // Feed all the data we've seen so far to the image decoder. | 237 // Feed all the data we've seen so far to the image decoder. |
| 220 m_allDataReceived = allDataReceived; | 238 m_allDataReceived = allDataReceived; |
| 221 ASSERT(data()); | 239 // |m_temporaryEncodedImageData| can be null only when testing. |
| 222 m_source.setData(*data(), allDataReceived); | 240 if (m_temporaryEncodedImageData) { |
| 241 m_source.setData(*m_temporaryEncodedImageData, allDataReceived); | |
| 242 m_temporaryEncodedImageData.clear(); | |
| 243 } | |
| 223 | 244 |
| 224 m_haveFrameCount = false; | 245 m_haveFrameCount = false; |
| 225 return isSizeAvailable(); | 246 return isSizeAvailable(); |
| 226 } | 247 } |
| 227 | 248 |
| 228 bool BitmapImage::hasColorProfile() const | 249 bool BitmapImage::hasColorProfile() const |
| 229 { | 250 { |
| 230 return m_source.hasColorProfile(); | 251 return m_source.hasColorProfile(); |
| 231 } | 252 } |
| 232 | 253 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 | 611 |
| 591 // We need to draw this frame if we advanced to it while not skipping, or if | 612 // We need to draw this frame if we advanced to it while not skipping, or if |
| 592 // while trying to skip frames we hit the last frame and thus had to stop. | 613 // while trying to skip frames we hit the last frame and thus had to stop. |
| 593 if (skippingFrames != advancedAnimation) | 614 if (skippingFrames != advancedAnimation) |
| 594 getImageObserver()->animationAdvanced(this); | 615 getImageObserver()->animationAdvanced(this); |
| 595 | 616 |
| 596 return advancedAnimation; | 617 return advancedAnimation; |
| 597 } | 618 } |
| 598 | 619 |
| 599 } // namespace blink | 620 } // namespace blink |
| OLD | NEW |