Index: third_party/WebKit/Source/web/WebMutatorImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebMutatorImpl.cpp b/third_party/WebKit/Source/web/WebMutatorImpl.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9b7c2ae4073dabfda8f9e52717929712abfbde4f |
--- /dev/null |
+++ b/third_party/WebKit/Source/web/WebMutatorImpl.cpp |
@@ -0,0 +1,82 @@ |
+// 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/WebMutatorImpl.h" |
+ |
+#include "core/dom/CompositorProxy.h" |
+#include "modules/compositorworker/CompositorWorkerThread.h" |
+#include "platform/Task.h" |
+#include "platform/TraceEvent.h" |
+#include "platform/WebThreadSupportingGC.h" |
+#include "public/platform/Platform.h" |
+#include "public/platform/WebCompositorMutableStateProvider.h" |
+#include "public/platform/WebCompositorSupport.h" |
+#include "public/platform/WebMutatorClient.h" |
+#include "public/platform/WebWaitableEvent.h" |
+#include "web/CompositorProxyClientImpl.h" |
+#include "wtf/Functional.h" |
+ |
+namespace blink { |
+ |
+WebMutatorImpl::WebMutatorImpl() |
+ : m_client(adoptPtr(Platform::current()->compositorSupport()->createMutatorClient(this))) |
+{ |
+} |
+ |
+WebMutatorImpl::~WebMutatorImpl() |
+{ |
+ TRACE_EVENT0("compositor-worker", "WebMutatorImpl::~WebMutatorImpl"); |
+ // We must have torn down all compositor workers before destroying this |
+ // instance. |
+ ASSERT(m_clients.isEmpty()); |
+} |
+ |
+PassOwnPtr<WebMutatorImpl> WebMutatorImpl::create() |
+{ |
+ return adoptPtr(new WebMutatorImpl()); |
+} |
+ |
+bool WebMutatorImpl::mutate(double timeNow, WebCompositorMutableStateProvider* stateProvider) |
+{ |
+ TRACE_EVENT0("compositor-worker", "WebMutatorImpl::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 WebMutatorImpl::registerClient(CompositorProxyClientImpl* client) |
+{ |
+ TRACE_EVENT0("compositor-worker", "WebMutatorImpl::registerClient"); |
+ m_clients.add(client); |
+ setNeedsMutate(); |
+} |
+ |
+void WebMutatorImpl::unregisterClient(CompositorProxyClientImpl* client) |
+{ |
+ TRACE_EVENT0("compositor-worker", "WebMutatorImpl::unregisterClient"); |
+ m_clients.remove(client); |
+} |
+ |
+CompositorProxyClient* WebMutatorImpl::createCompositorProxyClient() |
+{ |
+ TRACE_EVENT0("compositor-worker", "WebMutatorImpl::createCompositorProxyClient"); |
+ return new CompositorProxyClientImpl(this); |
+} |
+ |
+void WebMutatorImpl::setNeedsMutate() |
+{ |
+ TRACE_EVENT0("compositor-worker", "WebMutatorImpl::requestMutation"); |
+ m_client->setNeedsMutate(); |
+} |
+ |
+} // namespace blink |