Chromium Code Reviews| 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 // Update proxies mutable state for this frame and reset it after rAF | |
| 56 // callback as no mutation is allowed outside rAF. | |
| 57 updateMutableStateForCompositorProxies(stateProvider); | |
| 54 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotoni cTimeNow); | 58 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotoni cTimeNow); |
| 59 updateMutableStateForCompositorProxies(nullptr); | |
| 55 | 60 |
| 56 return m_requestedAnimationFrameCallbacks; | 61 return m_requestedAnimationFrameCallbacks; |
| 57 } | 62 } |
| 58 | 63 |
| 59 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) | 64 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) |
| 60 { | 65 { |
| 61 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); | 66 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); |
| 67 | |
| 62 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. | 68 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. |
| 63 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); | 69 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); |
| 64 const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(hi ghResTimeMs); | 70 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs); |
| 65 return shouldReinvoke; | 71 } |
| 72 | |
| 73 void CompositorProxyClientImpl::updateMutableStateForCompositorProxies(Composito rMutableStateProvider* stateProvider) | |
| 74 { | |
| 75 for (CompositorProxy* proxy : m_proxies) | |
| 76 proxy->takeCompositorMutableState(stateProvider ? stateProvider->getMuta bleStateFor(proxy->elementId()) : nullptr); | |
|
jbroman
2016/06/15 08:55:50
By the way, what happens if there are multiple Com
majidvp
2016/06/15 15:46:53
Yes this is the current design. It is similar to m
| |
| 66 } | 77 } |
| 67 | 78 |
| 68 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) | 79 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) |
| 69 { | 80 { |
| 70 m_proxies.add(proxy); | 81 m_proxies.add(proxy); |
| 71 } | 82 } |
| 72 | 83 |
| 73 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) | 84 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) |
| 74 { | 85 { |
| 75 m_proxies.remove(proxy); | 86 m_proxies.remove(proxy); |
| 76 } | 87 } |
| 77 | 88 |
| 78 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |