OLD | NEW |
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/DOMNodeIds.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 { | 40 { |
41 return !isMainThread(); | 41 return !isMainThread(); |
42 } | 42 } |
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(uint64_t elementId, u
int32_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 Node* node = DOMNodeIds::nodeForId(elementId); |
54 if (!node) | 54 if (!node) |
55 return; | 55 return; |
56 Element* element = toElement(node); | 56 Element* element = toElement(node); |
57 element->decrementCompositorProxiedProperties(compositorMutableProperties); | 57 element->decrementCompositorProxiedProperties(compositorMutableProperties); |
58 } | 58 } |
59 | 59 |
60 static void incrementCompositorProxiedPropertiesForElement(uint64_t elementId, u
int32_t compositorMutableProperties) | 60 static void incrementCompositorProxiedPropertiesForElement(CompositorElementId e
lementId, uint32_t compositorMutableProperties) |
61 { | 61 { |
62 DCHECK(isMainThread()); | 62 DCHECK(isMainThread()); |
63 Node* node = DOMNodeIds::nodeForId(elementId); | 63 Node* node = DOMNodeIds::nodeForId(elementId); |
64 if (!node) | 64 if (!node) |
65 return; | 65 return; |
66 Element* element = toElement(node); | 66 Element* element = toElement(node); |
67 element->incrementCompositorProxiedProperties(compositorMutableProperties); | 67 element->incrementCompositorProxiedProperties(compositorMutableProperties); |
68 } | 68 } |
69 | 69 |
70 static bool raiseExceptionIfMutationNotAllowed(ExceptionState& exceptionState) | 70 static bool raiseExceptionIfMutationNotAllowed(ExceptionState& exceptionState) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 { | 105 { |
106 if (!context->isDocument()) { | 106 if (!context->isDocument()) { |
107 exceptionState.throwTypeError(ExceptionMessages::failedToConstruct("Comp
ositorProxy", "Can only be created from the main context.")); | 107 exceptionState.throwTypeError(ExceptionMessages::failedToConstruct("Comp
ositorProxy", "Can only be created from the main context.")); |
108 exceptionState.throwIfNeeded(); | 108 exceptionState.throwIfNeeded(); |
109 return nullptr; | 109 return nullptr; |
110 } | 110 } |
111 | 111 |
112 return new CompositorProxy(*element, attributeArray); | 112 return new CompositorProxy(*element, attributeArray); |
113 } | 113 } |
114 | 114 |
115 CompositorProxy* CompositorProxy::create(uint64_t elementId, uint32_t compositor
MutableProperties) | 115 CompositorProxy* CompositorProxy::create(CompositorElementId elementId, uint32_t
compositorMutableProperties) |
116 { | 116 { |
117 return new CompositorProxy(elementId, compositorMutableProperties); | 117 return new CompositorProxy(elementId, compositorMutableProperties); |
118 } | 118 } |
119 | 119 |
120 CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attribu
teArray) | 120 CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attribu
teArray) |
121 : m_elementId(DOMNodeIds::idForNode(&element)) | 121 : m_elementId(DOMNodeIds::idForNode(&element)) |
122 , m_compositorMutableProperties(compositorMutablePropertiesFromNames(attribu
teArray)) | 122 , m_compositorMutableProperties(compositorMutablePropertiesFromNames(attribu
teArray)) |
123 { | 123 { |
124 DCHECK(isMainThread()); | 124 DCHECK(isMainThread()); |
125 DCHECK(m_compositorMutableProperties); | 125 DCHECK(m_compositorMutableProperties); |
126 #if DCHECK_IS_ON() | 126 #if DCHECK_IS_ON() |
127 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); | 127 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); |
128 #endif | 128 #endif |
129 | 129 |
130 incrementCompositorProxiedPropertiesForElement(m_elementId, m_compositorMuta
bleProperties); | 130 incrementCompositorProxiedPropertiesForElement(m_elementId, m_compositorMuta
bleProperties); |
131 } | 131 } |
132 | 132 |
133 CompositorProxy::CompositorProxy(uint64_t elementId, uint32_t compositorMutableP
roperties) | 133 CompositorProxy::CompositorProxy(CompositorElementId elementId, uint32_t composi
torMutableProperties) |
134 : m_elementId(elementId) | 134 : m_elementId(elementId) |
135 , m_compositorMutableProperties(compositorMutableProperties) | 135 , m_compositorMutableProperties(compositorMutableProperties) |
136 { | 136 { |
137 DCHECK(isControlThread()); | 137 DCHECK(isControlThread()); |
138 #if DCHECK_IS_ON() | 138 #if DCHECK_IS_ON() |
139 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); | 139 DCHECK(sanityCheckMutableProperties(m_compositorMutableProperties)); |
140 #endif | 140 #endif |
141 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H
ERE, threadSafeBind(&incrementCompositorProxiedPropertiesForElement, m_elementId
, m_compositorMutableProperties)); | 141 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H
ERE, threadSafeBind(&incrementCompositorProxiedPropertiesForElement, m_elementId
, m_compositorMutableProperties)); |
142 } | 142 } |
143 | 143 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void CompositorProxy::disconnect() | 240 void CompositorProxy::disconnect() |
241 { | 241 { |
242 m_connected = false; | 242 m_connected = false; |
243 if (isMainThread()) | 243 if (isMainThread()) |
244 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor
MutableProperties); | 244 decrementCompositorProxiedPropertiesForElement(m_elementId, m_compositor
MutableProperties); |
245 else | 245 else |
246 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme
ntId, m_compositorMutableProperties)); | 246 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&decrementCompositorProxiedPropertiesForElement, m_eleme
ntId, m_compositorMutableProperties)); |
247 } | 247 } |
248 | 248 |
249 } // namespace blink | 249 } // namespace blink |
OLD | NEW |