Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(906)

Unified Diff: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp

Issue 1857543002: Don't recreate SkImages for high-res (GIF, WEBP...) animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review #4 fix. Thanks @pkasting. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
index fad71475e10d2082229bafd35d958a839138e19c..6d63d9ad723b36c864a1baf2eb0860997a7f476b 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
@@ -107,7 +107,7 @@ bool BitmapImage::currentFrameHasSingleSecurityOrigin() const
return true;
}
-void BitmapImage::destroyDecodedData(bool destroyAll)
+void BitmapImage::destroyDecodedData()
{
for (size_t i = 0; i < m_frames.size(); ++i) {
// The underlying frame isn't actually changing (we're just trying to
@@ -116,24 +116,10 @@ void BitmapImage::destroyDecodedData(bool destroyAll)
m_frames[i].clear(false);
}
- size_t frameBytesCleared = m_source.clearCacheExceptFrame(destroyAll ? kNotFound : m_currentFrame);
+ size_t frameBytesCleared = m_source.clearCacheExceptFrame(kNotFound);
notifyMemoryChanged(-safeCast<int>(frameBytesCleared));
}
-void BitmapImage::destroyDecodedDataIfNecessary()
-{
- // Animated images >5MB are considered large enough that we'll only hang on
- // to one frame at a time.
- static const size_t cLargeAnimationCutoff = 5242880;
- size_t allFrameBytes = 0;
- for (size_t i = 0; i < m_frames.size(); ++i)
- allFrameBytes += m_frames[i].m_frameBytes;
-
- if (allFrameBytes > cLargeAnimationCutoff) {
- destroyDecodedData(false);
- }
-}
-
void BitmapImage::notifyMemoryChanged(int delta)
{
if (delta && getImageObserver())
@@ -571,9 +557,6 @@ void BitmapImage::resetAnimation()
m_repetitionsComplete = 0;
m_desiredFrameStartTime = 0;
m_animationFinished = false;
-
- // For extremely large animations, when the animation is reset, we just throw everything away.
- destroyDecodedDataIfNecessary();
}
bool BitmapImage::maybeAnimated()
@@ -631,7 +614,6 @@ bool BitmapImage::internalAdvanceAnimation(bool skippingFrames)
} else
m_currentFrame = 0;
}
- destroyDecodedDataIfNecessary();
// We need to draw this frame if we advanced to it while not skipping, or if
// while trying to skip frames we hit the last frame and thus had to stop.

Powered by Google App Engine
This is Rietveld 408576698