| Index: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
|
| index 60292c6ac26c0d97ad4f97e8b81e716550108352..64395db76a9d3b8b7027981ffebcf5ad7bd0f8db 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
|
| @@ -124,15 +124,18 @@ bool ImageFrameGenerator::decodeAndScale(SegmentReader* data, bool allDataReceiv
|
|
|
| TRACE_EVENT1("blink", "ImageFrameGenerator::decodeAndScale", "frame index", static_cast<int>(index));
|
|
|
| - RefPtr<ExternalMemoryAllocator> externalAllocator = adoptRef(new ExternalMemoryAllocator(info, pixels, rowBytes));
|
| -
|
| // This implementation does not support scaling so check the requested size.
|
| SkISize scaledSize = SkISize::Make(info.width(), info.height());
|
| ASSERT(m_fullSize == scaledSize);
|
|
|
| - // TODO (scroggo): Convert tryToResumeDecode() and decode() to take a
|
| - // sk_sp<SkBitmap::Allocator> instead of a bare pointer.
|
| - SkBitmap bitmap = tryToResumeDecode(data, allDataReceived, index, scaledSize, externalAllocator.get());
|
| + // It is okay to allocate ref-counted ExternalMemoryAllocator on the stack,
|
| + // because 1) it contains references to memory that will be invalid after
|
| + // returning (i.e. a pointer to |pixels|) and therefore 2) should not live
|
| + // longer than the call to the current method.
|
| + ExternalMemoryAllocator externalAllocator(info, pixels, rowBytes);
|
| + SkBitmap bitmap = tryToResumeDecode(data, allDataReceived, index, scaledSize, &externalAllocator);
|
| + DCHECK(externalAllocator.unique()); // Verify we have the only ref-count.
|
| +
|
| if (bitmap.isNull())
|
| return false;
|
|
|
|
|