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() | |
|
hiroshige
2016/06/29 07:04:06
The name data() here (and ImageSource) looks like
hajimehoshi
2016/07/04 10:46:25
This method is overriding Image::data. Do you mean
| |
| 122 { | |
| 123 if (RefPtr<SharedBuffer> data = cachedData()) | |
| 124 return data; | |
|
f(malita)
2016/06/30 18:21:46
Nit: return data.release();
hajimehoshi
2016/07/04 10:46:25
Done.
| |
| 125 return m_source.data(); | |
|
f(malita)
2016/06/30 18:21:46
IIUC we clear the cached data as soon as we can, a
hajimehoshi
2016/07/04 10:46:25
IIUC the situation where this function is limited:
| |
| 126 } | |
| 127 | |
| 128 PassRefPtr<SharedBuffer> BitmapImage::cachedData() | |
|
scroggo_chromium
2016/06/28 15:33:44
A couple of thoughts on this method:
It is very s
hiroshige
2016/06/29 07:04:06
FYI using "cached" prefix near loading code might
hajimehoshi
2016/07/04 10:46:25
Removed.
| |
| 129 { | |
| 130 return Image::data(); | |
| 131 } | |
| 132 | |
| 121 void BitmapImage::notifyMemoryChanged() | 133 void BitmapImage::notifyMemoryChanged() |
| 122 { | 134 { |
| 123 if (getImageObserver()) | 135 if (getImageObserver()) |
| 124 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); | 136 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); |
| 125 } | 137 } |
| 126 | 138 |
| 127 size_t BitmapImage::totalFrameBytes() | 139 size_t BitmapImage::totalFrameBytes() |
| 128 { | 140 { |
| 129 const size_t numFrames = frameCount(); | 141 const size_t numFrames = frameCount(); |
| 130 size_t totalBytes = 0; | 142 size_t totalBytes = 0; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 // cleared-on-a-previous-pass) frames! | 223 // cleared-on-a-previous-pass) frames! |
| 212 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) { | 224 if (m_frames[i].m_haveMetadata && !m_frames[i].m_isComplete) { |
| 213 m_frames[i].clear(true); | 225 m_frames[i].clear(true); |
| 214 if (i == m_cachedFrameIndex) | 226 if (i == m_cachedFrameIndex) |
| 215 m_cachedFrame.clear(); | 227 m_cachedFrame.clear(); |
| 216 } | 228 } |
| 217 } | 229 } |
| 218 | 230 |
| 219 // Feed all the data we've seen so far to the image decoder. | 231 // Feed all the data we've seen so far to the image decoder. |
| 220 m_allDataReceived = allDataReceived; | 232 m_allDataReceived = allDataReceived; |
| 221 ASSERT(data()); | 233 if (cachedData()) { |
| 222 m_source.setData(*data(), allDataReceived); | 234 m_source.setData(*cachedData(), allDataReceived); |
| 235 if (m_source.hasData()) { | |
| 236 // Remove the cached data (encoded image data) from BitmapImage. Now | |
| 237 // there is an encoded image data in DefferedImageDecoder on a skia | |
|
scroggo_chromium
2016/06/28 15:33:44
nit: "there is encoded image data" (no need for "a
hajimehoshi
2016/07/04 10:46:25
Done.
| |
| 238 // side, we won't need the same data in BitmapImage. | |
| 239 resetCachedData(); | |
|
scroggo_chromium
2016/06/28 15:33:44
Just to make sure I understand - this will drop th
hajimehoshi
2016/07/04 10:46:25
Yes.
| |
| 240 DCHECK(!cachedData()); | |
| 241 } | |
| 242 } | |
| 223 | 243 |
| 224 m_haveFrameCount = false; | 244 m_haveFrameCount = false; |
| 225 return isSizeAvailable(); | 245 return isSizeAvailable(); |
| 226 } | 246 } |
| 227 | 247 |
| 228 bool BitmapImage::hasColorProfile() const | 248 bool BitmapImage::hasColorProfile() const |
| 229 { | 249 { |
| 230 return m_source.hasColorProfile(); | 250 return m_source.hasColorProfile(); |
| 231 } | 251 } |
| 232 | 252 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 | 610 |
| 591 // We need to draw this frame if we advanced to it while not skipping, or if | 611 // 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. | 612 // while trying to skip frames we hit the last frame and thus had to stop. |
| 593 if (skippingFrames != advancedAnimation) | 613 if (skippingFrames != advancedAnimation) |
| 594 getImageObserver()->animationAdvanced(this); | 614 getImageObserver()->animationAdvanced(this); |
| 595 | 615 |
| 596 return advancedAnimation; | 616 return advancedAnimation; |
| 597 } | 617 } |
| 598 | 618 |
| 599 } // namespace blink | 619 } // namespace blink |
| OLD | NEW |