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); |
+ } |
} |
} |