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 ProxyMap::AddResult entry = m_proxyMap.add(elementId, new ProxySet); | |
jbroman
2016/06/10 17:45:42
This will create a spurious "new ProxySet" every t
majidvp
2016/06/10 19:17:51
Great! I like this pattern of using isNewEntry. Th
| |
72 ProxySet* proxies = entry.storedValue->value; | |
73 if (!proxies->contains(proxy)) | |
74 proxies->add(proxy); | |
75 } | |
76 | |
77 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) | |
78 { | |
79 uint64_t elementId = proxy->elementId(); | |
80 if (ProxySet* proxies = m_proxyMap.get(elementId)) { | |
81 proxies->remove(proxy); | |
82 if (proxies->isEmpty()) | |
83 m_proxyMap.remove(elementId); | |
jbroman
2016/06/10 17:45:42
This case is probably less worrisome, but this is
majidvp
2016/06/10 19:17:51
Done.
| |
84 } | |
85 } | |
86 | |
67 } // namespace blink | 87 } // namespace blink |
OLD | NEW |