| 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.reset(); | 114 m_cachedFrame.reset(); |
| 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 bool BitmapImage::clear() |
| 122 { |
| 123 destroyDecodedData(); |
| 124 return m_source.clear(); |
| 125 } |
| 126 |
| 121 PassRefPtr<SharedBuffer> BitmapImage::data() | 127 PassRefPtr<SharedBuffer> BitmapImage::data() |
| 122 { | 128 { |
| 123 return m_source.data(); | 129 return m_source.data(); |
| 124 } | 130 } |
| 125 | 131 |
| 126 void BitmapImage::notifyMemoryChanged() | 132 void BitmapImage::notifyMemoryChanged() |
| 127 { | 133 { |
| 128 if (getImageObserver()) | 134 if (getImageObserver()) |
| 129 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); | 135 getImageObserver()->decodedSizeChangedTo(this, totalFrameBytes()); |
| 130 } | 136 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 343 } |
| 338 | 344 |
| 339 sk_sp<SkImage> BitmapImage::frameAtIndex(size_t index) | 345 sk_sp<SkImage> BitmapImage::frameAtIndex(size_t index) |
| 340 { | 346 { |
| 341 if (index >= frameCount()) | 347 if (index >= frameCount()) |
| 342 return nullptr; | 348 return nullptr; |
| 343 | 349 |
| 344 if (index == m_cachedFrameIndex && m_cachedFrame) | 350 if (index == m_cachedFrameIndex && m_cachedFrame) |
| 345 return m_cachedFrame; | 351 return m_cachedFrame; |
| 346 | 352 |
| 353 if (m_source.isBufferCleared()) { |
| 354 getImageObserver()->requireReloading(this); |
| 355 return nullptr; |
| 356 } |
| 357 |
| 347 return decodeAndCacheFrame(index); | 358 return decodeAndCacheFrame(index); |
| 348 } | 359 } |
| 349 | 360 |
| 350 bool BitmapImage::frameIsCompleteAtIndex(size_t index) | 361 bool BitmapImage::frameIsCompleteAtIndex(size_t index) |
| 351 { | 362 { |
| 352 if (index < m_frames.size() && m_frames[index].m_haveMetadata && m_frames[in
dex].m_isComplete) | 363 if (index < m_frames.size() && m_frames[index].m_haveMetadata && m_frames[in
dex].m_isComplete) |
| 353 return true; | 364 return true; |
| 354 | 365 |
| 355 return m_source.frameIsCompleteAtIndex(index); | 366 return m_source.frameIsCompleteAtIndex(index); |
| 356 } | 367 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 646 |
| 636 return true; | 647 return true; |
| 637 } | 648 } |
| 638 | 649 |
| 639 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) | 650 void BitmapImage::notifyObserversOfAnimationAdvance(TimerBase*) |
| 640 { | 651 { |
| 641 getImageObserver()->animationAdvanced(this); | 652 getImageObserver()->animationAdvanced(this); |
| 642 } | 653 } |
| 643 | 654 |
| 644 } // namespace blink | 655 } // namespace blink |
| OLD | NEW |