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 "platform/graphics/CompositorMutableStateProvider.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 proxy->takeCompositorMutableState(nullptr); | 33 proxy->takeCompositorMutableState(nullptr); |
| 34 } | 34 } |
| 35 private: | 35 private: |
| 36 HeapHashSet<WeakMember<CompositorProxy>>& m_proxies; | 36 HeapHashSet<WeakMember<CompositorProxy>>& m_proxies; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta tor) | 39 CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* muta tor) |
| 40 : m_mutator(mutator) | 40 : m_mutator(mutator) |
| 41 , m_globalScope(nullptr) | 41 , m_globalScope(nullptr) |
| 42 { | 42 { |
| 43 DCHECK(isMainThread()); | |
| 43 } | 44 } |
| 44 | 45 |
| 45 DEFINE_TRACE(CompositorProxyClientImpl) | 46 DEFINE_TRACE(CompositorProxyClientImpl) |
| 46 { | 47 { |
| 47 CompositorProxyClient::trace(visitor); | 48 CompositorProxyClient::trace(visitor); |
| 48 visitor->trace(m_mutator); | |
| 49 visitor->trace(m_globalScope); | |
| 50 visitor->trace(m_proxies); | 49 visitor->trace(m_proxies); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) | 52 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) |
| 54 { | 53 { |
| 55 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope "); | 54 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope "); |
| 56 DCHECK(!m_globalScope); | 55 DCHECK(!m_globalScope); |
| 57 DCHECK(scope); | 56 DCHECK(scope); |
| 58 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); | 57 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); |
| 59 m_mutator->registerProxyClient(this); | 58 m_mutator->registerProxyClient(this); |
| 60 } | 59 } |
| 61 | 60 |
| 61 void CompositorProxyClientImpl::dispose() | |
|
haraken
2016/09/12 11:45:09
Add a comment about the lifetime of relevant objec
keishi
2016/09/13 03:12:43
Done.
| |
| 62 { | |
| 63 m_mutator->unregisterProxyClient(this); | |
| 64 m_globalScope = nullptr; | |
| 65 } | |
| 66 | |
| 62 void CompositorProxyClientImpl::requestAnimationFrame() | 67 void CompositorProxyClientImpl::requestAnimationFrame() |
| 63 { | 68 { |
| 64 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestAnimati onFrame"); | 69 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestAnimati onFrame"); |
| 65 m_requestedAnimationFrameCallbacks = true; | 70 m_requestedAnimationFrameCallbacks = true; |
| 66 m_mutator->setNeedsMutate(); | 71 m_mutator->setNeedsMutate(); |
| 67 } | 72 } |
| 68 | 73 |
| 69 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow, CompositorMutabl eStateProvider* stateProvider) | 74 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow, CompositorMutabl eStateProvider* stateProvider) |
| 70 { | 75 { |
| 71 if (!m_globalScope) | 76 if (!m_globalScope) |
| 72 return false; | 77 return false; |
| 73 | 78 |
| 74 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); | 79 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); |
| 75 if (!m_requestedAnimationFrameCallbacks) | 80 if (!m_requestedAnimationFrameCallbacks) |
| 76 return false; | 81 return false; |
| 77 | 82 |
| 78 { | 83 { |
| 79 ScopedCompositorMutableState mutableState(m_proxies, stateProvider); | 84 ScopedCompositorMutableState mutableState(m_proxies, stateProvider); |
| 80 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(mono tonicTimeNow); | 85 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(mono tonicTimeNow); |
| 81 } | 86 } |
| 82 | 87 |
| 83 return m_requestedAnimationFrameCallbacks; | 88 return m_requestedAnimationFrameCallbacks; |
| 84 } | 89 } |
| 85 | 90 |
| 86 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) | 91 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT imeNow) |
| 87 { | 92 { |
| 88 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); | 93 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati onFrameCallbacks"); |
| 89 | 94 |
| 95 DCHECK(m_globalScope); | |
| 90 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. | 96 // Convert to zero based document time in milliseconds consistent with reque stAnimationFrame. |
| 91 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); | 97 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi n()); |
| 92 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs); | 98 return m_globalScope->executeAnimationFrameCallbacks(highResTimeMs); |
| 93 } | 99 } |
| 94 | 100 |
| 95 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) | 101 void CompositorProxyClientImpl::registerCompositorProxy(CompositorProxy* proxy) |
| 96 { | 102 { |
| 97 m_proxies.add(proxy); | 103 m_proxies.add(proxy); |
| 98 } | 104 } |
| 99 | 105 |
| 100 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) | 106 void CompositorProxyClientImpl::unregisterCompositorProxy(CompositorProxy* proxy ) |
| 101 { | 107 { |
| 102 m_proxies.remove(proxy); | 108 m_proxies.remove(proxy); |
| 103 } | 109 } |
| 104 | 110 |
| 105 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |