Index: third_party/WebKit/Source/web/CompositorMutatorImpl.cpp |
diff --git a/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp b/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4fb9aded5e477861bcd13e6aece0ab665077f22a |
--- /dev/null |
+++ b/third_party/WebKit/Source/web/CompositorMutatorImpl.cpp |
@@ -0,0 +1,82 @@ |
+// Copyright 2016 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/CompositorMutatorImpl.h" |
+ |
+#include "core/dom/CompositorProxy.h" |
+#include "modules/compositorworker/CompositorWorkerThread.h" |
+#include "platform/graphics/CompositorMutableStateProvider.h" |
+#include "platform/graphics/CompositorMutatorClient.h" |
+#include "platform/Task.h" |
+#include "platform/TraceEvent.h" |
+#include "platform/WebThreadSupportingGC.h" |
+#include "public/platform/Platform.h" |
+#include "public/platform/WebCompositorSupport.h" |
+#include "public/platform/WebWaitableEvent.h" |
+#include "web/CompositorProxyClientImpl.h" |
+#include "wtf/Functional.h" |
+ |
+namespace blink { |
+ |
+CompositorMutatorImpl::CompositorMutatorImpl() |
+ : m_client(adoptPtr(new CompositorMutatorClient(this))) |
+{ |
+} |
+ |
+CompositorMutatorImpl::~CompositorMutatorImpl() |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::~CompositorMutatorImpl"); |
+ // We must have torn down all compositor workers before destroying this |
+ // instance. |
+ ASSERT(m_clients.isEmpty()); |
+} |
+ |
+PassOwnPtr<CompositorMutatorImpl> CompositorMutatorImpl::create() |
+{ |
+ return adoptPtr(new CompositorMutatorImpl()); |
+} |
+ |
+bool CompositorMutatorImpl::mutate(double timeNow, CompositorMutableStateProvider* stateProvider) |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::mutate"); |
+ Clients copy = m_clients; |
+ bool needToReinvoke = false; |
+ // TODO(vollick): we should avoid executing the animation frame |
+ // callbacks if none of the proxies in the global scope are affected by |
+ // m_mutations. |
+ for (CompositorProxyClientImpl* client : copy) { |
+ if (client->mutate(timeNow, stateProvider)) |
+ needToReinvoke = true; |
+ } |
+ |
+ return needToReinvoke; |
+ |
+} |
+ |
+void CompositorMutatorImpl::registerClient(CompositorProxyClientImpl* client) |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::registerClient"); |
+ m_clients.add(client); |
+ setNeedsMutate(); |
+} |
+ |
+void CompositorMutatorImpl::unregisterClient(CompositorProxyClientImpl* client) |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::unregisterClient"); |
+ m_clients.remove(client); |
+} |
+ |
+CompositorProxyClient* CompositorMutatorImpl::createCompositorProxyClient() |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::createCompositorProxyClient"); |
+ return new CompositorProxyClientImpl(this); |
+} |
+ |
+void CompositorMutatorImpl::setNeedsMutate() |
+{ |
+ TRACE_EVENT0("compositor-worker", "CompositorMutatorImpl::requestMutation"); |
+ m_client->setNeedsMutate(); |
+} |
+ |
+} // namespace blink |