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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 1922393002: CC Animation: Unify ElementId in Blink Compositor Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@player
Patch Set: Remove NextElementId. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptValueSerializer.h" 5 #include "bindings/core/v8/ScriptValueSerializer.h"
6 6
7 #include "bindings/core/v8/Transferables.h" 7 #include "bindings/core/v8/Transferables.h"
8 #include "bindings/core/v8/V8ArrayBuffer.h" 8 #include "bindings/core/v8/V8ArrayBuffer.h"
9 #include "bindings/core/v8/V8ArrayBufferView.h" 9 #include "bindings/core/v8/V8ArrayBufferView.h"
10 #include "bindings/core/v8/V8Blob.h" 10 #include "bindings/core/v8/V8Blob.h"
11 #include "bindings/core/v8/V8CompositorProxy.h" 11 #include "bindings/core/v8/V8CompositorProxy.h"
12 #include "bindings/core/v8/V8File.h" 12 #include "bindings/core/v8/V8File.h"
13 #include "bindings/core/v8/V8FileList.h" 13 #include "bindings/core/v8/V8FileList.h"
14 #include "bindings/core/v8/V8ImageBitmap.h" 14 #include "bindings/core/v8/V8ImageBitmap.h"
15 #include "bindings/core/v8/V8ImageData.h" 15 #include "bindings/core/v8/V8ImageData.h"
16 #include "bindings/core/v8/V8MessagePort.h" 16 #include "bindings/core/v8/V8MessagePort.h"
17 #include "bindings/core/v8/V8OffscreenCanvas.h" 17 #include "bindings/core/v8/V8OffscreenCanvas.h"
18 #include "bindings/core/v8/V8SharedArrayBuffer.h" 18 #include "bindings/core/v8/V8SharedArrayBuffer.h"
19 #include "core/dom/CompositorProxy.h" 19 #include "core/dom/CompositorProxy.h"
20 #include "core/dom/DOMDataView.h" 20 #include "core/dom/DOMDataView.h"
21 #include "core/dom/DOMSharedArrayBuffer.h" 21 #include "core/dom/DOMSharedArrayBuffer.h"
22 #include "core/dom/DOMTypedArray.h" 22 #include "core/dom/DOMTypedArray.h"
23 #include "core/fileapi/Blob.h" 23 #include "core/fileapi/Blob.h"
24 #include "core/fileapi/File.h" 24 #include "core/fileapi/File.h"
25 #include "core/fileapi/FileList.h" 25 #include "core/fileapi/FileList.h"
26 #include "platform/RuntimeEnabledFeatures.h" 26 #include "platform/RuntimeEnabledFeatures.h"
27 #include "platform/graphics/CompositorElementId.h"
27 #include "public/platform/Platform.h" 28 #include "public/platform/Platform.h"
28 #include "public/platform/WebBlobInfo.h" 29 #include "public/platform/WebBlobInfo.h"
29 #include "wtf/DateMath.h" 30 #include "wtf/DateMath.h"
30 #include "wtf/text/StringHash.h" 31 #include "wtf/text/StringHash.h"
31 #include "wtf/text/StringUTF8Adaptor.h" 32 #include "wtf/text/StringUTF8Adaptor.h"
32 33
33 // FIXME: consider crashing in debug mode on deserialization errors 34 // FIXME: consider crashing in debug mode on deserialization errors
34 // NOTE: be sure to change wireFormatVersion as necessary! 35 // NOTE: be sure to change wireFormatVersion as necessary!
35 36
36 namespace blink { 37 namespace blink {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void SerializedScriptValueWriter::writeBlobIndex(int blobIndex) 203 void SerializedScriptValueWriter::writeBlobIndex(int blobIndex)
203 { 204 {
204 ASSERT(blobIndex >= 0); 205 ASSERT(blobIndex >= 0);
205 append(BlobIndexTag); 206 append(BlobIndexTag);
206 doWriteUint32(blobIndex); 207 doWriteUint32(blobIndex);
207 } 208 }
208 209
209 void SerializedScriptValueWriter::writeCompositorProxy(const CompositorProxy& co mpositorProxy) 210 void SerializedScriptValueWriter::writeCompositorProxy(const CompositorProxy& co mpositorProxy)
210 { 211 {
211 append(CompositorProxyTag); 212 append(CompositorProxyTag);
212 doWriteUint64(compositorProxy.elementId()); 213 CompositorElementId elementId = compositorProxy.elementId();
214 doWriteInt32(elementId);
213 doWriteUint32(compositorProxy.compositorMutableProperties()); 215 doWriteUint32(compositorProxy.compositorMutableProperties());
214 } 216 }
215 217
216 void SerializedScriptValueWriter::writeFile(const File& file) 218 void SerializedScriptValueWriter::writeFile(const File& file)
217 { 219 {
218 append(FileTag); 220 append(FileTag);
219 doWriteFile(file); 221 doWriteFile(file);
220 } 222 }
221 223
222 void SerializedScriptValueWriter::writeFileIndex(int blobIndex) 224 void SerializedScriptValueWriter::writeFileIndex(int blobIndex)
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 while (true) { 489 while (true) {
488 value >>= SerializedScriptValue::varIntShift; 490 value >>= SerializedScriptValue::varIntShift;
489 if (!value) 491 if (!value)
490 break; 492 break;
491 ++bytes; 493 ++bytes;
492 } 494 }
493 495
494 return bytes; 496 return bytes;
495 } 497 }
496 498
499 void SerializedScriptValueWriter::doWriteInt32(int32_t value)
500 {
501 doWriteUintHelper(value);
502 }
503
497 void SerializedScriptValueWriter::doWriteUint32(uint32_t value) 504 void SerializedScriptValueWriter::doWriteUint32(uint32_t value)
498 { 505 {
499 doWriteUintHelper(value); 506 doWriteUintHelper(value);
500 } 507 }
501 508
502 void SerializedScriptValueWriter::doWriteUint64(uint64_t value) 509 void SerializedScriptValueWriter::doWriteUint64(uint64_t value)
503 { 510 {
504 doWriteUintHelper(value); 511 doWriteUintHelper(value);
505 } 512 }
506 513
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 ImageBitmap* imageBitmap = ImageBitmap::create(imageData, IntRect(0, 0, imag eData->width(), imageData->height()), options, true); 1717 ImageBitmap* imageBitmap = ImageBitmap::create(imageData, IntRect(0, 0, imag eData->width(), imageData->height()), options, true);
1711 if (!imageBitmap) 1718 if (!imageBitmap)
1712 return false; 1719 return false;
1713 *value = toV8(imageBitmap, m_scriptState->context()->Global(), isolate()); 1720 *value = toV8(imageBitmap, m_scriptState->context()->Global(), isolate());
1714 return !value->IsEmpty(); 1721 return !value->IsEmpty();
1715 } 1722 }
1716 1723
1717 bool SerializedScriptValueReader::readCompositorProxy(v8::Local<v8::Value>* valu e) 1724 bool SerializedScriptValueReader::readCompositorProxy(v8::Local<v8::Value>* valu e)
1718 { 1725 {
1719 uint32_t attributes; 1726 uint32_t attributes;
1720 uint64_t element; 1727 CompositorElementId elementId;
1721 if (!doReadUint64(&element)) 1728 if (!doReadInt32(&elementId))
1722 return false; 1729 return false;
1723 if (!doReadUint32(&attributes)) 1730 if (!doReadUint32(&attributes))
1724 return false; 1731 return false;
1725 1732
1726 CompositorProxy* compositorProxy = CompositorProxy::create(element, attribut es); 1733 CompositorProxy* compositorProxy = CompositorProxy::create(elementId, attrib utes);
1727 *value = toV8(compositorProxy, m_scriptState->context()->Global(), isolate() ); 1734 *value = toV8(compositorProxy, m_scriptState->context()->Global(), isolate() );
1728 return !value->IsEmpty(); 1735 return !value->IsEmpty();
1729 } 1736 }
1730 1737
1731 DOMArrayBuffer* SerializedScriptValueReader::doReadArrayBuffer() 1738 DOMArrayBuffer* SerializedScriptValueReader::doReadArrayBuffer()
1732 { 1739 {
1733 uint32_t byteLength; 1740 uint32_t byteLength;
1734 if (!doReadUint32(&byteLength)) 1741 if (!doReadUint32(&byteLength))
1735 return nullptr; 1742 return nullptr;
1736 if (m_position + byteLength > m_length) 1743 if (m_position + byteLength > m_length)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 ASSERT(m_blobInfo); 1997 ASSERT(m_blobInfo);
1991 uint32_t index; 1998 uint32_t index;
1992 if (!doReadUint32(&index) || index >= m_blobInfo->size()) 1999 if (!doReadUint32(&index) || index >= m_blobInfo->size())
1993 return nullptr; 2000 return nullptr;
1994 const WebBlobInfo& info = (*m_blobInfo)[index]; 2001 const WebBlobInfo& info = (*m_blobInfo)[index];
1995 // FIXME: transition WebBlobInfo.lastModified to be milliseconds-based also. 2002 // FIXME: transition WebBlobInfo.lastModified to be milliseconds-based also.
1996 double lastModifiedMS = info.lastModified() * msPerSecond; 2003 double lastModifiedMS = info.lastModified() * msPerSecond;
1997 return File::createFromIndexedSerialization(info.filePath(), info.fileName() , info.size(), lastModifiedMS, getOrCreateBlobDataHandle(info.uuid(), info.type( ), info.size())); 2004 return File::createFromIndexedSerialization(info.filePath(), info.fileName() , info.size(), lastModifiedMS, getOrCreateBlobDataHandle(info.uuid(), info.type( ), info.size()));
1998 } 2005 }
1999 2006
2007 bool SerializedScriptValueReader::doReadInt32(int32_t* value)
2008 {
2009 return doReadUintHelper(value);
2010 }
2011
2000 bool SerializedScriptValueReader::doReadUint32(uint32_t* value) 2012 bool SerializedScriptValueReader::doReadUint32(uint32_t* value)
2001 { 2013 {
2002 return doReadUintHelper(value); 2014 return doReadUintHelper(value);
2003 } 2015 }
2004 2016
2005 bool SerializedScriptValueReader::doReadUint64(uint64_t* value) 2017 bool SerializedScriptValueReader::doReadUint64(uint64_t* value)
2006 { 2018 {
2007 return doReadUintHelper(value); 2019 return doReadUintHelper(value);
2008 } 2020 }
2009 2021
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 return false; 2371 return false;
2360 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1]; 2372 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1];
2361 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1); 2373 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1);
2362 if (objectReference >= m_objectPool.size()) 2374 if (objectReference >= m_objectPool.size())
2363 return false; 2375 return false;
2364 *object = m_objectPool[objectReference]; 2376 *object = m_objectPool[objectReference];
2365 return true; 2377 return true;
2366 } 2378 }
2367 2379
2368 } // namespace blink 2380 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698