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

Unified Diff: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp

Issue 1895873006: compositor-worker: Initialize CW machinery plumbing to compositor and fire CW rAF callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary scope Created 4 years, 8 months 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
Index: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp
diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp
index 9389cb2ee960d0cc95ef6bf6ccbfa40146865ad8..c2a1df98ec807faf25e3a54ffd29087b0e98df0e 100644
--- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp
+++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerGlobalScope.cpp
@@ -24,8 +24,17 @@ CompositorWorkerGlobalScope* CompositorWorkerGlobalScope::create(CompositorWorke
CompositorWorkerGlobalScope::CompositorWorkerGlobalScope(const KURL& url, const String& userAgent, CompositorWorkerThread* thread, double timeOrigin, PassOwnPtr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, WorkerClients* workerClients)
: WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivilegeData, workerClients)
+ , m_executingAnimationFrameCallbacks(false)
, m_callbackCollection(this)
+ , m_client(CompositorProxyClient::from(clients()))
{
+ m_client->setGlobalScope(this);
+ ThreadState::current()->registerPreFinalizer(this);
+}
+
+void CompositorWorkerGlobalScope::dispose()
+{
+ m_client->setGlobalScope(nullptr);
}
CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope()
@@ -35,6 +44,7 @@ CompositorWorkerGlobalScope::~CompositorWorkerGlobalScope()
DEFINE_TRACE(CompositorWorkerGlobalScope)
{
visitor->trace(m_callbackCollection);
+ visitor->trace(m_client);
WorkerGlobalScope::trace(visitor);
}
@@ -54,6 +64,9 @@ void CompositorWorkerGlobalScope::postMessage(ExecutionContext* executionContext
int CompositorWorkerGlobalScope::requestAnimationFrame(FrameRequestCallback* callback)
{
+ const bool shouldSignal = !m_executingAnimationFrameCallbacks && m_callbackCollection.isEmpty();
+ if (shouldSignal)
+ m_client->requestMutation();
return m_callbackCollection.registerCallback(callback);
}
@@ -62,9 +75,11 @@ void CompositorWorkerGlobalScope::cancelAnimationFrame(int id)
m_callbackCollection.cancelCallback(id);
}
-void CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResTimeNow)
+bool CompositorWorkerGlobalScope::executeAnimationFrameCallbacks(double highResTimeNow)
{
+ TemporaryChange<bool> temporaryChange(m_executingAnimationFrameCallbacks, true);
m_callbackCollection.executeCallbacks(highResTimeNow, highResTimeNow);
+ return !m_callbackCollection.isEmpty();
}
CompositorWorkerThread* CompositorWorkerGlobalScope::thread() const

Powered by Google App Engine
This is Rietveld 408576698