Index: cc/CCThreadProxy.cpp |
diff --git a/cc/CCThreadProxy.cpp b/cc/CCThreadProxy.cpp |
index 0984b3c80a8c9ad2f3e375a2b2ff435ba0623ebd..394b286ca6a007fc5966b76b847fe8df962dfc51 100644 |
--- a/cc/CCThreadProxy.cpp |
+++ b/cc/CCThreadProxy.cpp |
@@ -14,6 +14,7 @@ |
#include "CCLayerTreeHost.h" |
#include "CCScheduler.h" |
#include "CCScopedThreadProxy.h" |
+#include "CCTextureUpdateController.h" |
#include "CCThreadTask.h" |
#include "TraceEvent.h" |
#include <public/WebSharedGraphicsContext3D.h> |
@@ -47,6 +48,7 @@ PassOwnPtr<CCProxy> CCThreadProxy::create(CCLayerTreeHost* layerTreeHost) |
CCThreadProxy::CCThreadProxy(CCLayerTreeHost* layerTreeHost) |
: m_animateRequested(false) |
, m_commitRequested(false) |
+ , m_commitRequestSentToImplThread(false) |
, m_forcedCommitRequested(false) |
, m_layerTreeHost(layerTreeHost) |
, m_compositorIdentifier(-1) |
@@ -275,7 +277,11 @@ void CCThreadProxy::setNeedsAnimate() |
TRACE_EVENT0("cc", "CCThreadProxy::setNeedsAnimate"); |
m_animateRequested = true; |
- setNeedsCommit(); |
+ |
+ if (m_commitRequestSentToImplThread) |
+ return; |
+ m_commitRequestSentToImplThread = true; |
+ CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setNeedsCommitOnImplThread)); |
} |
void CCThreadProxy::setNeedsCommit() |
@@ -283,9 +289,12 @@ void CCThreadProxy::setNeedsCommit() |
ASSERT(isMainThread()); |
if (m_commitRequested) |
return; |
- |
TRACE_EVENT0("cc", "CCThreadProxy::setNeedsCommit"); |
m_commitRequested = true; |
+ |
+ if (m_commitRequestSentToImplThread) |
+ return; |
+ m_commitRequestSentToImplThread = true; |
CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::setNeedsCommitOnImplThread)); |
} |
@@ -293,8 +302,7 @@ void CCThreadProxy::didLoseContextOnImplThread() |
{ |
ASSERT(isImplThread()); |
TRACE_EVENT0("cc", "CCThreadProxy::didLoseContextOnImplThread"); |
- if (m_currentTextureUpdateControllerOnImplThread) |
- m_currentTextureUpdateControllerOnImplThread->discardUploads(); |
+ m_currentTextureUpdateControllerOnImplThread.clear(); |
m_schedulerOnImplThread->didLoseContext(); |
} |
@@ -468,6 +476,7 @@ void CCThreadProxy::beginFrame() |
// the paint, m_commitRequested will be set to false to allow new commit |
// requests to be scheduled. |
m_commitRequested = true; |
+ m_commitRequestSentToImplThread = true; |
// On the other hand, the animationRequested flag needs to be cleared |
// here so that any animation requests generated by the apply or animate |
@@ -480,6 +489,7 @@ void CCThreadProxy::beginFrame() |
if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { |
m_commitRequested = false; |
+ m_commitRequestSentToImplThread = false; |
m_forcedCommitRequested = false; |
TRACE_EVENT0("cc", "EarlyOut_NotVisible"); |
@@ -496,6 +506,7 @@ void CCThreadProxy::beginFrame() |
// layout when painted will trigger another setNeedsCommit inside |
// updateLayers. |
m_commitRequested = false; |
+ m_commitRequestSentToImplThread = false; |
m_forcedCommitRequested = false; |
if (!m_layerTreeHost->initializeRendererIfNeeded()) |
@@ -512,11 +523,16 @@ void CCThreadProxy::beginFrame() |
m_texturesAcquired = false; |
m_layerTreeHost->willCommit(); |
- // Before applying scrolls and calling animate, we set m_animateRequested to false. |
- // If it is true now, it means setNeedAnimate was called again. Call setNeedsCommit |
- // now so that we get begin frame when this one is done. |
- if (m_animateRequested) |
- setNeedsCommit(); |
+ // Before applying scrolls and calling animate, we set m_animateRequested to |
+ // false. If it is true now, it means setNeedAnimate was called again, but |
+ // during a state when m_commitRequestSentToImplThread = true. We need to |
+ // force that call to happen again now so that the commit request is sent to |
+ // the impl thread. |
+ if (m_animateRequested) { |
+ // Forces setNeedsAnimate to consider posting a commit task. |
+ m_animateRequested = false; |
+ setNeedsAnimate(); |
+ } |
// Notify the impl thread that the beginFrame has completed. This will |
// begin the commit process, which is blocking from the main thread's |
@@ -558,12 +574,10 @@ void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion |
} else |
m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; |
- bool hasResourceUpdates = queue->hasMoreUpdates(); |
- if (hasResourceUpdates) |
- m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader()); |
+ m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader()); |
m_commitCompletionEventOnImplThread = completion; |
- m_schedulerOnImplThread->beginFrameComplete(hasResourceUpdates); |
+ m_schedulerOnImplThread->beginFrameComplete(); |
} |
void CCThreadProxy::beginFrameAbortedOnImplThread() |
@@ -576,6 +590,13 @@ void CCThreadProxy::beginFrameAbortedOnImplThread() |
m_schedulerOnImplThread->beginFrameAborted(); |
} |
+bool CCThreadProxy::hasMoreResourceUpdates() const |
+{ |
+ if (!m_currentTextureUpdateControllerOnImplThread) |
+ return false; |
+ return m_currentTextureUpdateControllerOnImplThread->hasMoreUpdates(); |
+} |
+ |
bool CCThreadProxy::canDraw() |
{ |
ASSERT(isImplThread()); |
@@ -595,6 +616,7 @@ void CCThreadProxy::scheduledActionCommit() |
{ |
TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); |
ASSERT(isImplThread()); |
+ ASSERT(!hasMoreResourceUpdates()); |
ASSERT(m_commitCompletionEventOnImplThread); |
m_currentTextureUpdateControllerOnImplThread.clear(); |
@@ -732,12 +754,6 @@ CCScheduledActionDrawAndSwapResult CCThreadProxy::scheduledActionDrawAndSwapForc |
return scheduledActionDrawAndSwapInternal(true); |
} |
-void CCThreadProxy::updateTexturesCompleted() |
-{ |
- ASSERT(isImplThread()); |
- m_schedulerOnImplThread->updateResourcesComplete(); |
-} |
- |
void CCThreadProxy::didCommitAndDrawFrame() |
{ |
ASSERT(isMainThread()); |