Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1301)

Unified Diff: third_party/WebKit/Source/web/WebMutatorImpl.cpp

Issue 1547893003: WIP - compositor worker mega patch. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/WebMutatorImpl.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/web/WebMutatorImpl.h ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698