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

Unified Diff: cc/thread_proxy.cc

Issue 11710004: cc: Block the main thread for texture layers during impl-side painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « cc/thread_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/thread_proxy.cc
diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
index b7e0e7c405e9c5518d600b6b875f37ab72fbabca..dd6f38fa99418b63a46c1f603b2d92caa8217b85 100644
--- a/cc/thread_proxy.cc
+++ b/cc/thread_proxy.cc
@@ -50,6 +50,7 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh
, m_readbackRequestOnImplThread(0)
, m_commitCompletionEventOnImplThread(0)
, m_textureAcquisitionCompletionEventOnImplThread(0)
+ , m_pendingTreeActivationEventOnImplThread(0)
, m_nextFrameIsNewlyCommittedFrameOnImplThread(false)
, m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled)
, m_totalCommitCount(0)
@@ -643,6 +644,9 @@ void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameStat
m_layerTreeHost->commitComplete();
m_layerTreeHost->didBeginFrame();
+
+ if (m_layerTreeHost->settings().implSidePainting)
+ blockUntilPendingActivationIfNeeded();
}
void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, ResourceUpdateQueue* rawQueue)
@@ -770,6 +774,14 @@ ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapInternal
}
m_layerTreeHostImpl->didDrawAllLayers(frame);
+ // Check for tree activation
+ if (m_pendingTreeActivationEventOnImplThread && !m_layerTreeHostImpl->pendingTree())
+ {
+ DCHECK(m_layerTreeHostImpl->settings().implSidePainting);
+ m_pendingTreeActivationEventOnImplThread->signal();
+ m_pendingTreeActivationEventOnImplThread = 0;
+ }
+
// Check for a pending compositeAndReadback.
if (m_readbackRequestOnImplThread) {
m_readbackRequestOnImplThread->success = false;
@@ -1012,4 +1024,34 @@ void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ
request->completion.signal();
}
+void ThreadProxy::blockUntilPendingActivationIfNeeded()
+{
+ DCHECK(isMainThread());
+ DCHECK(m_layerTreeHost->settings().implSidePainting);
+
+ if (!m_layerTreeHost->blocksPendingCommit())
+ return;
+
+ TRACE_EVENT0("cc", "ThreadProxy::blockUntilPendingActivationIfNeeded");
+ DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
+ CompletionEvent completion;
+ Proxy::implThread()->postTask(base::Bind(&ThreadProxy::blockUntilPendingActivationOnImplThread, m_implThreadWeakPtr, &completion));
+ completion.wait();
+}
+
+void ThreadProxy::blockUntilPendingActivationOnImplThread(CompletionEvent* completion)
+{
+ DCHECK(isImplThread());
+ DCHECK(isMainThreadBlocked());
+ DCHECK(m_layerTreeHostImpl->settings().implSidePainting);
+ CHECK(!m_pendingTreeActivationEventOnImplThread);
+
+ if (!m_layerTreeHostImpl->pendingTree()) {
+ completion->signal();
+ return;
+ }
+
+ m_pendingTreeActivationEventOnImplThread = completion;
+}
+
} // namespace cc
« no previous file with comments | « cc/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698