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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp

Issue 2326473005: Use sk_sp<SkBitmap::Allocator> instead of raw pointers or WTF::RefPtr<T>. (Closed)
Patch Set: Created 4 years, 3 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/ImageFrameGenerator.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
index 60292c6ac26c0d97ad4f97e8b81e716550108352..803a73cc49f516b8cf972c3eff9ff696e0974a1d 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageFrameGenerator.cpp
@@ -124,15 +124,13 @@ 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));
+ sk_sp<ExternalMemoryAllocator> externalAllocator(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());
+ SkBitmap bitmap = tryToResumeDecode(data, allDataReceived, index, scaledSize, std::move(externalAllocator));
if (bitmap.isNull())
return false;
@@ -180,7 +178,7 @@ bool ImageFrameGenerator::decodeToYUV(SegmentReader* data, size_t index, const S
return false;
}
-SkBitmap ImageFrameGenerator::tryToResumeDecode(SegmentReader* data, bool allDataReceived, size_t index, const SkISize& scaledSize, SkBitmap::Allocator* allocator)
+SkBitmap ImageFrameGenerator::tryToResumeDecode(SegmentReader* data, bool allDataReceived, size_t index, const SkISize& scaledSize, sk_sp<SkBitmap::Allocator> allocator)
{
TRACE_EVENT1("blink", "ImageFrameGenerator::tryToResumeDecode", "frame index", static_cast<int>(index));
@@ -192,7 +190,7 @@ SkBitmap ImageFrameGenerator::tryToResumeDecode(SegmentReader* data, bool allDat
ASSERT(!resumeDecoding || decoder);
SkBitmap fullSizeImage;
- bool complete = decode(data, allDataReceived, index, &decoder, &fullSizeImage, allocator);
+ bool complete = decode(data, allDataReceived, index, &decoder, &fullSizeImage, std::move(allocator));
if (!decoder)
return SkBitmap();
@@ -252,7 +250,7 @@ void ImageFrameGenerator::setHasAlpha(size_t index, bool hasAlpha)
m_hasAlpha[index] = hasAlpha;
}
-bool ImageFrameGenerator::decode(SegmentReader* data, bool allDataReceived, size_t index, ImageDecoder** decoder, SkBitmap* bitmap, SkBitmap::Allocator* allocator)
+bool ImageFrameGenerator::decode(SegmentReader* data, bool allDataReceived, size_t index, ImageDecoder** decoder, SkBitmap* bitmap, sk_sp<SkBitmap::Allocator> allocator)
{
ASSERT(m_decodeMutex.locked());
TRACE_EVENT2("blink", "ImageFrameGenerator::decode", "width", m_fullSize.width(), "height", m_fullSize.height());
@@ -280,7 +278,7 @@ bool ImageFrameGenerator::decode(SegmentReader* data, bool allDataReceived, size
// If we're using an external memory allocator that means we're decoding
// directly into the output memory and we can save one memcpy.
ASSERT(allocator);
- (*decoder)->setMemoryAllocator(allocator);
+ (*decoder)->setMemoryAllocator(std::move(allocator));
Łukasz Anforowicz 2016/09/09 20:10:04 |allocator| comes from |decodeAndScale|, which wil
scroggo_chromium 2016/09/09 20:51:04 It's safe (but arguably not safe from future chang
Łukasz Anforowicz 2016/09/12 20:50:09 My first priority is to eradicate RefPtr<SkFoo> (b
scroggo_chromium 2016/09/13 14:54:42 Another note: it would *not* be safe if we did not
Łukasz Anforowicz 2016/09/13 18:17:31 Thanks for pointing this out - I agree that using
}
if (shouldCallSetData)

Powered by Google App Engine
This is Rietveld 408576698