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 99c59dc89c15204fc7fcc79767af0332b85422c5..df4b86994d13c1d7ef177299c069132d5ffbdb52 100644 |
--- a/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp |
@@ -98,16 +98,26 @@ |
prepareLazyDecodedFrames(); |
- DCHECK(index < m_frameData.size()); |
- DeferredFrameData* frameData = &m_frameData[index]; |
- if (m_actualDecoder) |
- frameData->m_frameBytes = m_actualDecoder->frameBytesAtIndex(index); |
- else |
- frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData); |
- // ImageFrameGenerator has the latest known alpha state. There will be a |
- // performance boost if this frame is opaque. |
- DCHECK(m_frameGenerator); |
- return createFrameImageAtIndex(index, !m_frameGenerator->hasAlpha(index)); |
+ if (index < m_frameData.size()) { |
+ DeferredFrameData* frameData = &m_frameData[index]; |
+ if (m_actualDecoder) |
+ frameData->m_frameBytes = m_actualDecoder->frameBytesAtIndex(index); |
+ else |
+ frameData->m_frameBytes = m_size.area() * sizeof(ImageFrame::PixelData); |
+ // ImageFrameGenerator has the latest known alpha state. There will be a |
+ // performance boost if this frame is opaque. |
+ DCHECK(m_frameGenerator); |
+ return createFrameImageAtIndex(index, !m_frameGenerator->hasAlpha(index)); |
+ } |
+ |
+ if (!m_actualDecoder || m_actualDecoder->failed()) |
+ return nullptr; |
+ |
+ ImageFrame* frame = m_actualDecoder->frameBufferAtIndex(index); |
+ if (!frame || frame->getStatus() == ImageFrame::FrameEmpty) |
+ return nullptr; |
+ |
+ return fromSkSp(SkImage::MakeFromBitmap(frame->bitmap())); |
} |
PassRefPtr<SharedBuffer> DeferredImageDecoder::data() |