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

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: Bug fix Created 4 years, 5 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 17d815c5049c96f11bf0829b3427eecc716e092f..501c1d522a9f84ba0c94ff7b58e8ab5fb7a36b3e 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
@@ -118,6 +118,11 @@ void BitmapImage::destroyDecodedData()
notifyMemoryChanged();
}
+PassRefPtr<SharedBuffer> BitmapImage::data()
+{
+ return m_source.data();
+}
+
void BitmapImage::notifyMemoryChanged()
{
if (getImageObserver())
@@ -184,6 +189,19 @@ bool BitmapImage::getHotSpot(IntPoint& hotSpot) const
return m_source.getHotSpot(hotSpot);
}
+bool BitmapImage::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
+{
+ m_temporaryEncodedImageData = data;
f(malita) 2016/07/08 15:34:40 Do we need m_temporaryEncodedImageData at all? Lo
hajimehoshi 2016/07/11 06:15:07 Done.
f(malita) 2016/07/12 17:10:59 Thanks, LGTM!
+ if (!m_temporaryEncodedImageData.get())
+ return true;
+
+ int length = m_temporaryEncodedImageData->size();
+ if (!length)
+ return true;
+
+ return dataChanged(allDataReceived);
+}
+
bool BitmapImage::dataChanged(bool allDataReceived)
{
TRACE_EVENT0("blink", "BitmapImage::dataChanged");
@@ -218,8 +236,11 @@ 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);
+ // |m_temporaryEncodedImageData| can be null only when testing.
+ if (m_temporaryEncodedImageData) {
+ m_source.setData(*m_temporaryEncodedImageData, allDataReceived);
+ m_temporaryEncodedImageData.clear();
+ }
m_haveFrameCount = false;
return isSizeAvailable();

Powered by Google App Engine
This is Rietveld 408576698