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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 void BitmapImage::destroyDecodedData() | 111 void BitmapImage::destroyDecodedData() |
112 { | 112 { |
113 m_cachedFrame.clear(); | 113 m_cachedFrame.clear(); |
114 for (size_t i = 0; i < m_frames.size(); ++i) | 114 for (size_t i = 0; i < m_frames.size(); ++i) |
115 m_frames[i].clear(true); | 115 m_frames[i].clear(true); |
116 m_source.clearCacheExceptFrame(kNotFound); | 116 m_source.clearCacheExceptFrame(kNotFound); |
117 notifyMemoryChanged(); | 117 notifyMemoryChanged(); |
118 } | 118 } |
119 | 119 |
| 120 PassRefPtr<SharedBuffer> BitmapImage::data() |
| 121 { |
| 122 if (SharedBuffer* data = cachedData()) |
| 123 return data; |
| 124 return m_source.data(); |
| 125 } |
| 126 |
| 127 SharedBuffer* BitmapImage::cachedData() |
| 128 { |
| 129 return Image::data().get(); |
| 130 } |
| 131 |
120 void BitmapImage::notifyMemoryChanged() | 132 void BitmapImage::notifyMemoryChanged() |
121 { | 133 { |
122 if (getImageObserver()) | 134 if (getImageObserver()) |
123 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); | 135 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); |
124 } | 136 } |
125 | 137 |
126 size_t BitmapImage::totalFrameBytes() | 138 size_t BitmapImage::totalFrameBytes() |
127 { | 139 { |
128 const size_t numFrames = frameCount(); | 140 const size_t numFrames = frameCount(); |
129 size_t totalBytes = 0; | 141 size_t totalBytes = 0; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // cleared-on-a-previous-pass) frames! | 222 // cleared-on-a-previous-pass) frames! |
211 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) { | 223 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) { |
212 m_frames[i].clear(true); | 224 m_frames[i].clear(true); |
213 if (i == m_cachedFrameIndex) | 225 if (i == m_cachedFrameIndex) |
214 m_cachedFrame.clear(); | 226 m_cachedFrame.clear(); |
215 } | 227 } |
216 } | 228 } |
217 | 229 |
218 // Feed all the data we've seen so far to the image decoder. | 230 // Feed all the data we've seen so far to the image decoder. |
219 m_allDataReceived = allDataReceived; | 231 m_allDataReceived = allDataReceived; |
220 ASSERT(data()); | 232 if (cachedData()) { |
221 m_source.setData(*data(), allDataReceived); | 233 m_source.setData(*cachedData(), allDataReceived); |
| 234 if (m_source.hasData()) { |
| 235 resetEncodedImageData(); |
| 236 DCHECK(!cachedData()); |
| 237 } |
| 238 } |
222 | 239 |
223 m_haveFrameCount = false; | 240 m_haveFrameCount = false; |
224 return isSizeAvailable(); | 241 return isSizeAvailable(); |
225 } | 242 } |
226 | 243 |
227 bool BitmapImage::hasColorProfile() const | 244 bool BitmapImage::hasColorProfile() const |
228 { | 245 { |
229 return m_source.hasColorProfile(); | 246 return m_source.hasColorProfile(); |
230 } | 247 } |
231 | 248 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 | 606 |
590 // We need to draw this frame if we advanced to it while not skipping, or if | 607 // We need to draw this frame if we advanced to it while not skipping, or if |
591 // while trying to skip frames we hit the last frame and thus had to stop. | 608 // while trying to skip frames we hit the last frame and thus had to stop. |
592 if (skippingFrames != advancedAnimation) | 609 if (skippingFrames != advancedAnimation) |
593 getImageObserver()->animationAdvanced(this); | 610 getImageObserver()->animationAdvanced(this); |
594 | 611 |
595 return advancedAnimation; | 612 return advancedAnimation; |
596 } | 613 } |
597 | 614 |
598 } // namespace blink | 615 } // namespace blink |
OLD | NEW |