OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "web/CompositorProxyClientImpl.h" |
| 6 |
| 7 #include "core/dom/CompositorProxy.h" |
| 8 #include "modules/compositorworker/CompositorWorkerGlobalScope.h" |
| 9 #include "platform/TraceEvent.h" |
| 10 #include "wtf/CurrentTime.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 CompositorProxyClientImpl::CompositorProxyClientImpl() |
| 15 : m_globalScope(nullptr) |
| 16 { |
| 17 } |
| 18 |
| 19 DEFINE_TRACE(CompositorProxyClientImpl) |
| 20 { |
| 21 CompositorProxyClient::trace(visitor); |
| 22 visitor->trace(m_globalScope); |
| 23 } |
| 24 |
| 25 void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) |
| 26 { |
| 27 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope
"); |
| 28 DCHECK(!m_globalScope); |
| 29 DCHECK(scope); |
| 30 m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); |
| 31 } |
| 32 |
| 33 void CompositorProxyClientImpl::runAnimationFrameCallbacks() |
| 34 { |
| 35 m_requestedAnimationFrameCallbacks = true; |
| 36 mutate(monotonicallyIncreasingTime()); |
| 37 } |
| 38 |
| 39 bool CompositorProxyClientImpl::mutate(double monotonicTimeNow) |
| 40 { |
| 41 if (!m_globalScope) |
| 42 return false; |
| 43 |
| 44 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); |
| 45 if (!m_requestedAnimationFrameCallbacks) |
| 46 return false; |
| 47 |
| 48 m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(monotoni
cTimeNow); |
| 49 |
| 50 return m_requestedAnimationFrameCallbacks; |
| 51 } |
| 52 |
| 53 bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double monotonicT
imeNow) |
| 54 { |
| 55 TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimati
onFrameCallbacks"); |
| 56 // Convert to zero based document time in milliseconds consistent with reque
stAnimationFrame. |
| 57 double highResTimeMs = 1000.0 * (monotonicTimeNow - m_globalScope->timeOrigi
n()); |
| 58 const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(hi
ghResTimeMs); |
| 59 return shouldReinvoke; |
| 60 } |
| 61 |
| 62 } // namespace blink |
OLD | NEW |