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 "platform/graphics/CompositorMutableStateProvider.h" |
10 #include "web/CompositorMutatorImpl.h" | 11 #include "web/CompositorMutatorImpl.h" |
11 #include "wtf/CurrentTime.h" | 12 #include "wtf/CurrentTime.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta
tor) | 16 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta
tor) |
16 : m_mutator(mutator) | 17 : m_mutator(mutator) |
17 , m_globalScope(nullptr) | 18 , m_globalScope(nullptr) |
18 { | 19 { |
19 } | 20 } |
(...skipping 15 matching lines...) Expand all Loading... |
35 m_mutator->registerProxyClient(this); | 36 m_mutator->registerProxyClient(this); |
36 } | 37 } |
37 | 38 |
38 void CompositorProxyClientImpl::requestAnimationFrame() | 39 void CompositorProxyClientImpl::requestAnimationFrame() |
39 { | 40 { |
40 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestAnimati
onFrame"); | 41 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestAnimati
onFrame"); |
41 m_requestedAnimationFrameCallbacks = true; | 42 m_requestedAnimationFrameCallbacks = true; |
42 m_mutator->setNeedsMutate(); | 43 m_mutator->setNeedsMutate(); |
43 } | 44 } |
44 | 45 |
45 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow) | 46 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow, CompositorMutabl
eStateProvider* stateProvider) |
46 { | 47 { |
47 if (!m_globalScope) | 48 if (!m_globalScope) |
48 return false; | 49 return false; |
49 | 50 |
50 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); | 51 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); |
51 if (!m_requestedAnimationFrameCallbacks) | 52 if (!m_requestedAnimationFrameCallbacks) |
52 return false; | 53 return false; |
53 | 54 |
| 55 updateMutableStateForCompositorProxies(stateProvider); |
54 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotoni
cTimeNow); | 56 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotoni
cTimeNow); |
| 57 updateMutableStateForCompositorProxies(nullptr); |
55 | 58 |
56 return m_requestedAnimationFrameCallbacks; | 59 return m_requestedAnimationFrameCallbacks; |
57 } | 60 } |
58 | 61 |
59 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT
imeNow) | 62 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT
imeNow) |
60 { | 63 { |
61 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati
onFrameCallbacks"); | 64 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati
onFrameCallbacks"); |
| 65 |
62 // Convert to zero based document time in milliseconds consistent with reque
stAnimationFrame. | 66 // Convert to zero based document time in milliseconds consistent with reque
stAnimationFrame. |
63 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi
n()); | 67 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi
n()); |
64 const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(hi
ghResTimeMs); | 68 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs); |
65 return shouldReinvoke; | 69 } |
| 70 |
| 71 void CompositorProxyClientImpl::updateMutableStateForCompositorProxies(Composito
rMutableStateProvider* stateProvider) |
| 72 { |
| 73 for (auto iter : m_proxies) { |
| 74 for (CompositorProxy* proxy : *iter.value) |
| 75 proxy->takeCompositorMutableState(stateProvider ? stateProvider->get
MutableStateFor(iter.key) : nullptr); |
| 76 } |
66 } | 77 } |
67 | 78 |
68 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) | 79 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) |
69 { | 80 { |
70 uint64_t elementId = proxy->elementId(); | 81 uint64_t elementId = proxy->elementId(); |
71 | 82 |
72 TRACE_EVENT2("compositor-worker,compositor-proxy", | 83 TRACE_EVENT2("compositor-worker,compositor-proxy", |
73 "CompositorProxyClientImpl::registerCompositorProxy", | 84 "CompositorProxyClientImpl::registerCompositorProxy", |
74 "elementId", static_cast<int>(elementId), | 85 "elementId", static_cast<int>(elementId), |
75 "proxy", proxy); | 86 "proxy", proxy); |
(...skipping 17 matching lines...) Expand all Loading... |
93 if (position == kNotFound) | 104 if (position == kNotFound) |
94 return; | 105 return; |
95 | 106 |
96 proxies->remove(position); | 107 proxies->remove(position); |
97 if (proxies->isEmpty()) | 108 if (proxies->isEmpty()) |
98 m_proxies.remove(elementId); | 109 m_proxies.remove(elementId); |
99 } | 110 } |
100 } | 111 } |
101 | 112 |
102 } // namespace blink | 113 } // namespace blink |
OLD | NEW |