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 62529643b6be1c9b5f514da7ddc461abe057fa29..9b0738885104e6c9d2dba89877b152eda29d443f 100644 |
--- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp |
@@ -87,6 +87,7 @@ DeferredImageDecoder::DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualD |
, m_hasColorProfile(false) |
, m_canYUVDecode(false) |
, m_hasHotSpot(false) |
+ , m_isBufferCleared(false) |
{ |
} |
@@ -128,6 +129,15 @@ sk_sp<SkImage> DeferredImageDecoder::createFrameAtIndex(size_t index) |
return SkImage::MakeFromBitmap(frame->bitmap()); |
} |
+bool DeferredImageDecoder::clear() |
+{ |
+ if (!m_rwBuffer) |
+ return false; |
+ m_rwBuffer.reset(); |
+ m_isBufferCleared = true; |
+ return true; |
+} |
+ |
PassRefPtr<SharedBuffer> DeferredImageDecoder::data() |
{ |
if (!m_rwBuffer) |
@@ -165,6 +175,7 @@ void DeferredImageDecoder::setDataInternal(PassRefPtr<SharedBuffer> passData, bo |
length; length = data->getSomeData(segment, m_rwBuffer->size())) { |
m_rwBuffer->append(segment, length); |
} |
+ m_isBufferCleared = false; |
} |
} |
@@ -324,6 +335,7 @@ sk_sp<SkImage> DeferredImageDecoder::createFrameImageAtIndex(size_t index, bool |
ASSERT(decodedSize.width() > 0); |
ASSERT(decodedSize.height() > 0); |
+ DCHECK(!m_isBufferCleared); |
sk_sp<SkROBuffer> roBuffer(m_rwBuffer->newRBufferSnapshot()); |
RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkROBuffer(std::move(roBuffer)); |
DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenerator, imageInfoFrom(decodedSize, knownToBeOpaque), segmentReader.release(), m_allDataReceived, index, m_frameData[index].m_uniqueID); |