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

Side by Side Diff: third_party/WebKit/Source/core/dom/CompositorProxy.cpp

Issue 1921503008: Blink CompositorWorker: Use CompositorElementId and CompositorIdToElementMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@elementid
Patch Set: Vend ids via local blink nextCompositorElementId. 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/dom/CompositorProxy.h" 5 #include "core/dom/CompositorProxy.h"
6 6
7 #include "bindings/core/v8/ExceptionMessages.h" 7 #include "bindings/core/v8/ExceptionMessages.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "core/dom/DOMNodeIds.h" 9 #include "core/dom/CompositorIdToElementMap.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
11 #include "core/dom/ExecutionContext.h" 11 #include "core/dom/ExecutionContext.h"
12 #include "platform/ThreadSafeFunctional.h" 12 #include "platform/ThreadSafeFunctional.h"
13 #include "platform/graphics/CompositorMutableProperties.h" 13 #include "platform/graphics/CompositorMutableProperties.h"
14 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
15 #include "public/platform/WebTraceLocation.h" 15 #include "public/platform/WebTraceLocation.h"
16 #include <algorithm> 16 #include <algorithm>
17 17
18 namespace blink { 18 namespace blink {
19 19
(...skipping 23 matching lines...) Expand all
43 43
44 static bool isCallingCompositorFrameCallback() 44 static bool isCallingCompositorFrameCallback()
45 { 45 {
46 // TODO(sad): Check that the requestCompositorFrame callbacks are currently being called. 46 // TODO(sad): Check that the requestCompositorFrame callbacks are currently being called.
47 return true; 47 return true;
48 } 48 }
49 49
50 static void decrementCompositorProxiedPropertiesForElement(CompositorElementId e lementId, uint32_t compositorMutableProperties) 50 static void decrementCompositorProxiedPropertiesForElement(CompositorElementId e lementId, uint32_t compositorMutableProperties)
51 { 51 {
52 DCHECK(isMainThread()); 52 DCHECK(isMainThread());
53 Node* node = DOMNodeIds::nodeForId(elementId); 53 Element* element = CompositorIdToElementMap::getById(elementId);
54 if (!node) 54 if (!element)
55 return; 55 return;
56 Element* element = toElement(node);
57 element->decrementCompositorProxiedProperties(compositorMutableProperties); 56 element->decrementCompositorProxiedProperties(compositorMutableProperties);
58 } 57 }
59 58
60 static void incrementCompositorProxiedPropertiesForElement(CompositorElementId e lementId, uint32_t compositorMutableProperties) 59 static void incrementCompositorProxiedPropertiesForElement(CompositorElementId e lementId, uint32_t compositorMutableProperties)
61 { 60 {
62 DCHECK(isMainThread()); 61 DCHECK(isMainThread());
63 Node* node = DOMNodeIds::nodeForId(elementId); 62 Element* element = CompositorIdToElementMap::getById(elementId);
64 if (!node) 63 if (!element)
65 return; 64 return;
66 Element* element = toElement(node);
67 element->incrementCompositorProxiedProperties(compositorMutableProperties); 65 element->incrementCompositorProxiedProperties(compositorMutableProperties);
68 } 66 }
69 67
70 static bool raiseExceptionIfMutationNotAllowed(ExceptionState& exceptionState) 68 static bool raiseExceptionIfMutationNotAllowed(ExceptionState& exceptionState)
71 { 69 {
72 if (!isControlThread()) { 70 if (!isControlThread()) {
73 exceptionState.throwDOMException(NoModificationAllowedError, "Cannot mut ate a proxy attribute from the main page."); 71 exceptionState.throwDOMException(NoModificationAllowedError, "Cannot mut ate a proxy attribute from the main page.");
74 return true; 72 return true;
75 } 73 }
76 if (!isCallingCompositorFrameCallback()) { 74 if (!isCallingCompositorFrameCallback()) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 109
112 return new CompositorProxy(*element, attributeArray); 110 return new CompositorProxy(*element, attributeArray);
113 } 111 }
114 112
115 CompositorProxy* CompositorProxy::create(CompositorElementId elementId, uint32_t compositorMutableProperties) 113 CompositorProxy* CompositorProxy::create(CompositorElementId elementId, uint32_t compositorMutableProperties)
116 { 114 {
117 return new CompositorProxy(elementId, compositorMutableProperties); 115 return new CompositorProxy(elementId, compositorMutableProperties);
118 } 116 }
119 117
120 CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attribu teArray) 118 CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attribu teArray)
121 : m_elementId(DOMNodeIds::idForNode(&element)) 119 : m_elementId(element.assignCompositorElementId())
122 , m_compositorMutableProperties(compositorMutablePropertiesFromNames(attribu teArray)) 120 , m_compositorMutableProperties(compositorMutablePropertiesFromNames(attribu teArray))
123 { 121 {
124 DCHECK(isMainThread()); 122 DCHECK(isMainThread());
125 DCHECK(m_compositorMutableProperties); 123 DCHECK(m_compositorMutableProperties);
126 #if DCHECK_IS_ON() 124 #if DCHECK_IS_ON()
127 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); 125 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties));
128 #endif 126 #endif
127 CompositorIdToElementMap::registerElement(element);
129 128
130 incrementCompositorProxiedPropertiesForElement(m_elementId, m_compositorMuta bleProperties); 129 incrementCompositorProxiedPropertiesForElement(m_elementId, m_compositorMuta bleProperties);
131 } 130 }
132 131
133 CompositorProxy::CompositorProxy(CompositorElementId elementId, uint32_t composi torMutableProperties) 132 CompositorProxy::CompositorProxy(CompositorElementId elementId, uint32_t composi torMutableProperties)
134 : m_elementId(elementId) 133 : m_elementId(elementId)
135 , m_compositorMutableProperties(compositorMutableProperties) 134 , m_compositorMutableProperties(compositorMutableProperties)
136 { 135 {
137 DCHECK(isControlThread()); 136 DCHECK(isControlThread());
138 #if DCHECK_IS_ON() 137 #if DCHECK_IS_ON()
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void CompositorProxy::disconnect() 239 void CompositorProxy::disconnect()
241 { 240 {
242 m_connected = false; 241 m_connected = false;
243 if (isMainThread()) 242 if (isMainThread())
244 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor MutableProperties); 243 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor MutableProperties);
245 else 244 else
246 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme ntId, m_compositorMutableProperties)); 245 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme ntId, m_compositorMutableProperties));
247 } 246 }
248 247
249 } // namespace blink 248 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698