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

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

Issue 2054643003: Remove duplication of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on hiroshige's review Created 4 years, 6 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 2f3b925fa0913a5cab7cee801239036ab77c9431..947e48343529fe5407e5313a48e0ef66bd540bd5 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
@@ -117,6 +117,18 @@ void BitmapImage::destroyDecodedData()
notifyMemoryChanged();
}
+PassRefPtr<SharedBuffer> BitmapImage::data()
+{
+ if (SharedBuffer* data = cachedData())
+ return data;
+ return m_source.data();
+}
+
+SharedBuffer* BitmapImage::cachedData()
+{
+ return Image::data().get();
+}
+
void BitmapImage::notifyMemoryChanged()
{
if (getImageObserver())
@@ -217,8 +229,13 @@ bool BitmapImage::dataChanged(bool allDataReceived)
// Feed all the data we've seen so far to the image decoder.
m_allDataReceived = allDataReceived;
- ASSERT(data());
- m_source.setData(*data(), allDataReceived);
+ if (cachedData()) {
+ m_source.setData(*cachedData(), allDataReceived);
+ if (m_source.hasData()) {
+ resetEncodedImageData();
+ DCHECK(!cachedData());
+ }
+ }
m_haveFrameCount = false;
return isSizeAvailable();

Powered by Google App Engine
This is Rietveld 408576698