Index: third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp |
diff --git a/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp b/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..efeac342e3ffb3ffc8ec70f7475551a1d34d3c10 |
--- /dev/null |
+++ b/third_party/WebKit/Source/web/CompositorProxyClientImpl.cpp |
@@ -0,0 +1,73 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "web/CompositorProxyClientImpl.h" |
+ |
+#include "core/dom/CompositorProxy.h" |
+#include "modules/compositorworker/CompositorWorkerGlobalScope.h" |
+#include "platform/TraceEvent.h" |
+#include "web/CompositorMutatorImpl.h" |
+ |
+namespace blink { |
+ |
+CompositorProxyClientImpl::CompositorProxyClientImpl(CompositorMutatorImpl* mutator) |
+ : m_mutator(mutator) |
+ , m_globalScope(nullptr) |
+ , m_executingAnimationFrameCallbacks(false) |
+{ |
+} |
+ |
+CompositorProxyClientImpl::~CompositorProxyClientImpl() |
+{ |
+} |
+ |
+DEFINE_TRACE(CompositorProxyClientImpl) |
+{ |
+ visitor->trace(m_globalScope); |
+ CompositorProxyClient::trace(visitor); |
+} |
+ |
+void CompositorProxyClientImpl::setGlobalScope(WorkerGlobalScope* scope) |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::setGlobalScope"); |
+ m_globalScope = static_cast<CompositorWorkerGlobalScope*>(scope); |
+ if (m_globalScope) |
+ m_mutator->registerClient(this); |
+ else |
+ m_mutator->unregisterClient(this); |
+} |
+ |
+void CompositorProxyClientImpl::requestMutation() |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::requestMutation"); |
+ m_requestedAnimationFrameCallbacks = true; |
+ m_mutator->setNeedsMutate(); |
+} |
+ |
+bool CompositorProxyClientImpl::mutate(double timeNow) |
+{ |
+ if (!m_globalScope) |
+ return false; |
+ |
+ TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::mutate"); |
+ if (!m_requestedAnimationFrameCallbacks) |
+ return false; |
+ |
+ m_requestedAnimationFrameCallbacks = false; |
+ { |
+ TemporaryChange<bool> temporary(m_executingAnimationFrameCallbacks, true); |
jbroman
2016/04/20 21:06:42
What's the point of changing this? It's never read
flackr
2016/04/25 14:06:28
I believe it does care in a subsequent patch but I
|
+ m_requestedAnimationFrameCallbacks = executeAnimationFrameCallbacks(timeNow); |
+ } |
+ |
+ return m_requestedAnimationFrameCallbacks; |
+} |
+ |
+bool CompositorProxyClientImpl::executeAnimationFrameCallbacks(double time) |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorProxyClientImpl::executeAnimationFrameCallbacks"); |
+ const bool shouldReinvoke = m_globalScope->executeAnimationFrameCallbacks(time); |
+ return shouldReinvoke; |
+} |
+ |
+} // namespace blink |