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 "web/CompositorProxyClientImpl.h" | 5 #include "web/CompositorProxyClientImpl.h" |
6 | 6 |
7 #include "core/dom/CompositorProxy.h" | 7 #include "core/dom/CompositorProxy.h" |
8 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" | 8 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" |
9 #include "platform/TraceEvent.h" | 9 #include "platform/TraceEvent.h" |
10 #include "web/CompositorMutatorImpl.h" | 10 #include "web/CompositorMutatorImpl.h" |
11 #include "wtf/CurrentTime.h" | 11 #include "wtf/CurrentTime.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta tor) | 15 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta tor) |
16 : m_mutator(mutator) | 16 : m_mutator(mutator) |
17 , m_globalScope(nullptr) | 17 , m_globalScope(nullptr) |
18 { | 18 { |
19 } | 19 } |
20 | 20 |
21 DEFINE_TRACE(CompositorProxyClientImpl) | 21 DEFINE_TRACE(CompositorProxyClientImpl) |
22 { | 22 { |
23 CompositorProxyClient::trace(visitor); | 23 CompositorProxyClient::trace(visitor); |
24 visitor->trace(m_mutator); | 24 visitor->trace(m_mutator); |
25 visitor->trace(m_globalScope); | 25 visitor->trace(m_globalScope); |
26 visitor->trace(m_proxyMap); | |
26 } | 27 } |
27 | 28 |
28 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) | 29 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) |
29 { | 30 { |
30 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope "); | 31 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope "); |
31 DCHECK(!m_globalScope); | 32 DCHECK(!m_globalScope); |
32 DCHECK(scope); | 33 DCHECK(scope); |
33 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); | 34 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); |
34 m_mutator->registerProxyClient(this); | 35 m_mutator->registerProxyClient(this); |
35 } | 36 } |
(...skipping 21 matching lines...) Expand all Loading... | |
57 | 58 |
58 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) | 59 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) |
59 { | 60 { |
60 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); | 61 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); |
61 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. | 62 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. |
62 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); | 63 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); |
63 const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(hi ghResTimeMs); | 64 const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(hi ghResTimeMs); |
64 return shouldReinvoke; | 65 return shouldReinvoke; |
65 } | 66 } |
66 | 67 |
68 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) | |
69 { | |
70 uint64_t elementId = proxy->elementId(); | |
71 | |
72 TRACE_EVENT2("compositor-worker,compositor-proxy", | |
haraken
2016/06/08 00:10:36
registerCompositorProxy should be cheap, so it won
majidvp
2016/06/09 20:34:21
Removed. We were using them as a way to trace the
| |
73 "CompositorProxyClientImpl::registerCompositorProxy", | |
74 "elementId", static_cast<int>(elementId), | |
75 "proxy", proxy); | |
76 | |
77 ProxyMap::AddResult entry = m_proxyMap.add(elementId, new ProxyVector); | |
78 ProxyVector* proxies = entry.storedValue->value; | |
79 if (!proxies->contains(proxy)) | |
80 proxies->append(proxy); | |
81 } | |
82 | |
83 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) | |
84 { | |
85 uint64_t elementId = proxy->elementId(); | |
86 if (ProxyVector* proxies = m_proxyMap.get(elementId)) { | |
87 TRACE_EVENT2("compositor-worker,compositor-proxy", | |
haraken
2016/06/08 00:10:36
Ditto.
| |
88 "CompositorProxyClientImpl::unregisterCompositorProxy", | |
89 "elementId", static_cast<int>(elementId), | |
90 "proxy", proxy); | |
91 | |
92 size_t position = proxies->find(proxy); | |
93 if (position == kNotFound) | |
94 return; | |
95 | |
96 proxies->remove(position); | |
97 if (proxies->isEmpty()) | |
98 m_proxyMap.remove(elementId); | |
99 } | |
100 } | |
101 | |
67 } // namespace blink | 102 } // namespace blink |
OLD | NEW |