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

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: (rebase) 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..c361c5b307450c79d0bae24ff1cb89d6563ec282 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,20 @@ bool BitmapImage::getHotSpot(IntPoint& hotSpot) const
return m_source.getHotSpot(hotSpot);
}
+bool BitmapImage::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
+{
+ if (!data.get())
+ return true;
+
+ int length = data->size();
+ if (!length)
+ return true;
+
+ m_source.setData(*data, allDataReceived);
+
+ return dataChanged(allDataReceived);
+}
+
bool BitmapImage::dataChanged(bool allDataReceived)
{
TRACE_EVENT0("blink", "BitmapImage::dataChanged");
@@ -218,8 +237,6 @@ 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_haveFrameCount = false;
return isSizeAvailable();

Powered by Google App Engine
This is Rietveld 408576698