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

Unified Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.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/DeferredImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
index 60d65443bb9078e6621f8440674f7661dacdf33c..0074f07d3d5ee9c963d818f9eb3fd01d6016d214 100644
--- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp
@@ -120,6 +120,19 @@ PassRefPtr<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index)
return fromSkSp(SkImage::MakeFromBitmap(frame->bitmap()));
}
+PassRefPtr<SharedBuffer> DeferredImageDecoder::data()
+{
+ if (!m_rwBuffer)
+ return nullptr;
+ RefPtr<SkROBuffer> roBuffer = adoptRef(m_rwBuffer->newRBufferSnapshot());
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create();
+ SkROBuffer::Iter it(roBuffer.get());
+ do {
+ sharedBuffer->append(static_cast<const char*>(it.data()), it.size());
+ } while (it.next());
+ return sharedBuffer.release();
+}
+
void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
{
if (m_actualDecoder) {
@@ -134,8 +147,9 @@ void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
const char* segment = 0;
for (size_t length = data.getSomeData(segment, m_rwBuffer->size());
- length; length = data.getSomeData(segment, m_rwBuffer->size()))
+ length; length = data.getSomeData(segment, m_rwBuffer->size())) {
m_rwBuffer->append(segment, length);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698