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

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

Issue 2719883004: Adds support for ArrayBufferContents with external buffer. (Closed)
Patch Set: passes unique_ptr Created 3 years, 10 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/ImageBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
index 2e38b192ed37b338fecca618ef940f34a33e00fa..2a396afaea66b5a12aad339cc172ceb42311e8f6 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp
@@ -346,12 +346,13 @@ bool ImageBuffer::getImageData(Multiply multiplied,
if (!isSurfaceValid()) {
size_t allocSizeInBytes = rect.width() * rect.height() * bytesPerPixel;
- void* data;
- WTF::ArrayBufferContents::allocateMemoryOrNull(
- allocSizeInBytes, WTF::ArrayBufferContents::ZeroInitialize, data);
+ WTF::ArrayBufferContents::ScopedData data(
+ WTF::ArrayBufferContents::allocateMemoryOrNull(
+ allocSizeInBytes, WTF::ArrayBufferContents::ZeroInitialize),
+ WTF::ArrayBufferContents::freeMemory);
if (!data)
return false;
- WTF::ArrayBufferContents result(data, allocSizeInBytes,
+ WTF::ArrayBufferContents result(std::move(data), allocSizeInBytes,
WTF::ArrayBufferContents::NotShared);
result.transfer(contents);
return true;
@@ -375,15 +376,16 @@ bool ImageBuffer::getImageData(Multiply multiplied,
rect.maxX() > m_surface->size().width() ||
rect.maxY() > m_surface->size().height();
size_t allocSizeInBytes = rect.width() * rect.height() * bytesPerPixel;
- void* data;
WTF::ArrayBufferContents::InitializationPolicy initializationPolicy =
mayHaveStrayArea ? WTF::ArrayBufferContents::ZeroInitialize
: WTF::ArrayBufferContents::DontInitialize;
- WTF::ArrayBufferContents::allocateMemoryOrNull(allocSizeInBytes,
- initializationPolicy, data);
+ WTF::ArrayBufferContents::ScopedData data(
+ WTF::ArrayBufferContents::allocateMemoryOrNull(allocSizeInBytes,
+ initializationPolicy),
+ WTF::ArrayBufferContents::freeMemory);
if (!data)
return false;
- WTF::ArrayBufferContents result(data, allocSizeInBytes,
+ WTF::ArrayBufferContents result(std::move(data), allocSizeInBytes,
WTF::ArrayBufferContents::NotShared);
// Skia does not support unpremultiplied read with an F16 to 8888 conversion

Powered by Google App Engine
This is Rietveld 408576698