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

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

Issue 198603003: Save a memory copy on Android for decoding images to discardable memory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/ImageFrameGenerator.cpp
diff --git a/Source/platform/graphics/ImageFrameGenerator.cpp b/Source/platform/graphics/ImageFrameGenerator.cpp
index dcb73e4c54858b8acc485aefe63fec79134e7897..c650de72fe6c38f5c44acc339de0a8dd1849a025 100644
--- a/Source/platform/graphics/ImageFrameGenerator.cpp
+++ b/Source/platform/graphics/ImageFrameGenerator.cpp
@@ -253,17 +253,16 @@ PassOwnPtr<ScaledImageFragment> ImageFrameGenerator::decode(size_t index, ImageD
return nullptr;
}
- // An external memory allocator is used if this variable is true.
- bool useExternalAllocator = false;
+ // This variable is set to true if we can skip a memcpy of the decoded bitmap.
+ bool canSkipBitmapCopy = false;
if (!m_isMultiFrame && newDecoder && allDataReceived) {
- // We are supporting two decoding paths in this code. Use the
- // external memory allocator in the Skia discardable path to
- // save one memory copy.
- if (m_externalAllocator) {
+ // If we're using an external memory allocator that means we're decoding
+ // directly into the output memory and we can save one memcpy.
+ canSkipBitmapCopy = true;
+ if (m_externalAllocator)
(*decoder)->setMemoryAllocator(m_externalAllocator.get());
- useExternalAllocator = true;
- } else
+ else
(*decoder)->setMemoryAllocator(m_discardableAllocator.get());
}
(*decoder)->setData(data, allDataReceived);
@@ -302,7 +301,7 @@ PassOwnPtr<ScaledImageFragment> ImageFrameGenerator::decode(size_t index, ImageD
// We early out and do not copy the memory if decoder writes directly to
// the memory provided by Skia and the decode was complete.
- if (useExternalAllocator && isCacheComplete)
+ if (canSkipBitmapCopy && isCacheComplete)
return ScaledImageFragment::createComplete(m_fullSize, index, fullSizeBitmap);
// If the image is progressively decoded we need to return a copy.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698