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

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 1964183004: Revert of Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/core/html/HTMLCanvasElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
index f2a50965cb56c90e9053189173815547399d28ba..03aed594ebe1ccbb56e744bf9fdb46ce227b05d7 100644
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
@@ -646,12 +646,16 @@
ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob);
// imageData unref its data, which we still keep alive for the async toBlob thread
ScopedDisposal<ImageData> disposer(imageData);
- CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageData->data(), encodingMimeType, imageData->size(), callback);
-
- if (encodingMimeType == DefaultMimeType)
- asyncCreator->scheduleAsyncBlobCreation(true);
- else
- asyncCreator->scheduleAsyncBlobCreation(false, quality);
+ // Add a ref to keep image data alive until completion of encoding
+ RefPtr<DOMUint8ClampedArray> imageDataRef(imageData->data());
+
+ RefPtr<CanvasAsyncBlobCreator> asyncCreatorRef = CanvasAsyncBlobCreator::create(imageDataRef.release(), encodingMimeType, imageData->size(), callback);
+
+ if (encodingMimeType == DefaultMimeType) {
+ asyncCreatorRef->scheduleAsyncBlobCreation(true);
+ } else {
+ asyncCreatorRef->scheduleAsyncBlobCreation(false, quality);
+ }
}
void HTMLCanvasElement::addListener(CanvasDrawListener* listener)
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReaderSync.cpp ('k') | third_party/WebKit/Source/core/html/ImageData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698