| 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 2a650a893f4364f6de016512b4c67a9031db798d..7bf2ee2afa3e7975f8e0bee048d94ee22eac7425 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/BitmapImage.h
|
| +++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.h
|
| @@ -44,8 +44,9 @@ namespace blink {
|
| template <typename T> class Timer;
|
|
|
| class PLATFORM_EXPORT BitmapImage final : public Image {
|
| - friend class GeneratedImage;
|
| + friend class BitmapImageTest;
|
| friend class CrossfadeGeneratedImage;
|
| + friend class GeneratedImage;
|
| friend class GradientGeneratedImage;
|
| friend class GraphicsContext;
|
| public:
|
| @@ -73,7 +74,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 +89,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.
|
| @@ -96,11 +102,6 @@ public:
|
| void advanceAnimationForTesting() override { internalAdvanceAnimation(false); }
|
|
|
| private:
|
| - friend class BitmapImageTest;
|
| -
|
| - void updateSize() const;
|
| -
|
| -private:
|
| enum RepetitionCountStatus {
|
| Unknown, // We haven't checked the source's repetition count.
|
| Uncertain, // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data has been decoded).
|
| @@ -110,8 +111,11 @@ private:
|
| BitmapImage(const SkBitmap &, ImageObserver* = 0);
|
| BitmapImage(ImageObserver* = 0);
|
|
|
| + static void setAnimationCacheSizeForTesting(size_t maxCacheSize, size_t maxAnimationSizeInCache);
|
| +
|
| void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode) override;
|
|
|
| + void updateSize() const;
|
| size_t currentFrame() const { return m_currentFrame; }
|
| size_t frameCount();
|
|
|
| @@ -123,27 +127,12 @@ private:
|
| ImageOrientation frameOrientationAtIndex(size_t);
|
|
|
| // Decodes and caches a frame. Never accessed except internally.
|
| - void cacheFrame(size_t index);
|
| -
|
| - // Called before accessing m_frames[index]. Returns false on index out of bounds.
|
| - bool ensureFrameIsCached(size_t index);
|
| + PassRefPtr<SkImage> cacheFrame(size_t index);
|
|
|
| // Returns the total number of bytes allocated for all framebuffers, i.e.
|
| // the sum of m_source.frameBytesAtIndex(...) for all frames.
|
| size_t 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();
|
|
|
| @@ -170,6 +159,9 @@ private:
|
| size_t m_currentFrame; // The index of the current frame of animation.
|
| 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.
|
|
|
| + RefPtr<SkImage> m_frame; // One frame is cached (the most recently accessed) also for animations.
|
| + size_t m_frameIndex; // Index of the frame that is cached.
|
| +
|
| OwnPtr<Timer<BitmapImage>> m_frameTimer;
|
| int m_repetitionCount; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation.
|
| RepetitionCountStatus m_repetitionCountStatus;
|
|
|