Index: third_party/WebKit/Source/platform/graphics/BitmapImage.h |
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.h b/third_party/WebKit/Source/platform/graphics/BitmapImage.h |
index 5275168eded9118afa9fd4963aab2e7e5878f221..eae3c45a0df4410aa2e2ab1b61a48fbd459dea4e 100644 |
--- a/third_party/WebKit/Source/platform/graphics/BitmapImage.h |
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.h |
@@ -73,7 +73,7 @@ public: |
// This because we start and stop animating lazily. Animation starts when |
// the image is rendered, and automatically pauses once all observers no |
// longer want to render the image. |
- void stopAnimation() override; |
+ void stopAnimation(); |
void resetAnimation() override; |
bool maybeAnimated() override; |
@@ -88,6 +88,11 @@ public: |
bool currentFrameIsComplete() override; |
bool currentFrameIsLazyDecoded() override; |
+ // Called to wipe out the entire frame buffer cache and tell the image |
+ // source to destroy everything; this is used when e.g. we want to free |
+ // some room in the image cache. |
+ void destroyDecodedData() override; |
+ |
ImageOrientation currentFrameOrientation(); |
// Construct a BitmapImage with the given orientation. |
@@ -99,6 +104,7 @@ private: |
friend class BitmapImageTest; |
void updateSize() const; |
+ static void setAnimationCacheSizeForTesting(size_t maxCacheSize, size_t maxAnimationSizeInCache); |
private: |
Peter Kasting
2016/04/28 23:07:54
Nit: While here: It's weird to have two private: s
aleksandar.stojiljkovic
2016/04/29 17:17:43
Done.
|
enum RepetitionCountStatus { |
@@ -123,10 +129,10 @@ private: |
ImageOrientation frameOrientationAtIndex(size_t); |
// Decodes and caches a frame. Never accessed except internally. |
- void cacheFrame(size_t index); |
+ PassRefPtr<SkImage> cacheFrame(size_t index); |
- // Called before accessing m_frames[index]. Returns false on index out of bounds. |
- bool ensureFrameIsCached(size_t index); |
+ // Helper method that is limiting cache size when animation frame gets cached. |
+ void onAnimationFrameCached(size_t index); |
// Returns the total number of bytes allocated for all framebuffers, i.e. |
// the sum of m_source.frameBytesAtIndex(...) for all frames. This is |
@@ -134,18 +140,6 @@ private: |
// the values from successive calls as signed expressions. |
int totalFrameBytes(); |
- // Called to invalidate cached data. When |destroyAll| is true, we wipe out |
- // the entire frame buffer cache and tell the image source to destroy |
- // everything; this is used when e.g. we want to free some room in the image |
- // cache. If |destroyAll| is false, we delete frames except the current |
- // frame; this is used while animating large images to keep memory footprint |
- // low; the decoder should preserve the current frame and may preserve some |
- // other frames to avoid redecoding the whole image on every frame. |
- void destroyDecodedData(bool destroyAll) override; |
- |
- // If the image is large enough, calls destroyDecodedData(). |
- void destroyDecodedDataIfNecessary(); |
- |
// Notifies observers that the memory footprint has changed. |
void notifyMemoryChanged(int delta); |
@@ -157,6 +151,7 @@ private: |
bool shouldAnimate(); |
void startAnimation(CatchUpAnimation = CatchUp) override; |
void advanceAnimation(Timer<BitmapImage>*); |
+ bool shouldCacheFrame(size_t index); |
// Function that does the real work of advancing the animation. When |
// skippingFrames is true, we're in the middle of a loop trying to skip over |
@@ -170,6 +165,7 @@ private: |
mutable IntSize m_sizeRespectingOrientation; |
size_t m_currentFrame; // The index of the current frame of animation. |
+ size_t m_disposeLaterFrame; // The index of the cached frame that should be disposed before accessing another one. |
Vector<FrameData, 1> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache. |
OwnPtr<Timer<BitmapImage>> m_frameTimer; |