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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp

Issue 2362463002: Support ImageBitmap transfer with V8-based structured clone. (Closed)
Patch Set: with one quick unit test 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/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
index 42dd7d2ae0d34b18227d9e1009ddf319f97c880f..fb08af290b9e6f3a860d6b503817ef513b0f14a7 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
@@ -99,6 +99,10 @@ void V8ScriptValueSerializer::finalizeTransfer(ExceptionState& exceptionState)
m_serializedScriptValue->transferArrayBuffers(isolate, m_transferables->arrayBuffers, exceptionState);
if (exceptionState.hadException())
return;
+
+ m_serializedScriptValue->transferImageBitmaps(isolate, m_transferables->imageBitmaps, exceptionState);
+ if (exceptionState.hadException())
+ return;
}
void V8ScriptValueSerializer::writeUTF8String(const String& string)
@@ -121,6 +125,19 @@ bool V8ScriptValueSerializer::writeDOMObject(ScriptWrappable* wrappable, Excepti
"An ImageBitmap is detached and could not be cloned.");
return false;
}
+
+ // If this ImageBitmap was transferred, it can be serialized by index.
+ size_t index = kNotFound;
+ if (m_transferables)
+ index = m_transferables->imageBitmaps.find(imageBitmap);
+ if (index != kNotFound) {
+ DCHECK_LE(index, std::numeric_limits<uint32_t>::max());
+ writeTag(ImageBitmapTransferTag);
+ writeUint32(static_cast<uint32_t>(index));
+ return true;
+ }
+
+ // Otherwise, it must be fully serialized.
// Warning: using N32ColorType here is not portable (across CPU
// architectures, across platforms, etc.).
RefPtr<Uint8Array> pixels = imageBitmap->copyBitmapData(

Powered by Google App Engine
This is Rietveld 408576698