Chromium Code Reviews| Index: cc/thread_proxy.cc |
| diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc |
| index ac58216e651e66277fc41e6bac8bc508816f4c4c..17cc89997530663d29b05ee358cb76ae7df5e76a 100644 |
| --- a/cc/thread_proxy.cc |
| +++ b/cc/thread_proxy.cc |
| @@ -38,7 +38,6 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost) |
| : m_animateRequested(false) |
| , m_commitRequested(false) |
| , m_commitRequestSentToImplThread(false) |
| - , m_forcedCommitRequested(false) |
| , m_layerTreeHost(layerTreeHost) |
| , m_rendererInitialized(false) |
| , m_started(false) |
| @@ -53,7 +52,6 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost) |
| , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
| , m_totalCommitCount(0) |
| , m_deferCommits(false) |
| - , m_deferredCommitPending(false) |
| { |
| TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| DCHECK(isMainThread()); |
| @@ -68,7 +66,7 @@ ThreadProxy::~ThreadProxy() |
| bool ThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect) |
| { |
| - TRACE_EVENT0("cc", "ThreadPRoxy::compositeAndReadback"); |
| + TRACE_EVENT0("cc", "ThreadProxy::compositeAndReadback"); |
| DCHECK(isMainThread()); |
| DCHECK(m_layerTreeHost); |
| DCHECK(!m_deferCommits); |
| @@ -87,7 +85,7 @@ bool ThreadProxy::compositeAndReadback(void *pixels, const gfx::Rect& rect) |
| beginFrameCompletion.wait(); |
| } |
| m_inCompositeAndReadback = true; |
| - beginFrame(); |
| + beginFrame(scoped_ptr<BeginFrameAndCommitState>()); |
| m_inCompositeAndReadback = false; |
| // Perform a synchronous readback. |
| @@ -338,7 +336,6 @@ void ThreadProxy::setNeedsForcedCommitOnImplThread() |
| { |
| DCHECK(isImplThread()); |
| TRACE_EVENT0("cc", "ThreadProxy::setNeedsForcedCommitOnImplThread"); |
| - m_schedulerOnImplThread->setNeedsCommit(); |
| m_schedulerOnImplThread->setNeedsForcedCommit(); |
| } |
| @@ -404,10 +401,8 @@ void ThreadProxy::setDeferCommits(bool deferCommits) |
| else |
| TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::setDeferCommits", this); |
| - if (!m_deferCommits && m_deferredCommitPending) { |
| - m_deferredCommitPending = false; |
| - m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this))); |
| - } |
| + if (!m_deferCommits && m_pendingDeferredCommit) |
| + m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this), base::Passed(m_pendingDeferredCommit.Pass()))); |
| } |
| bool ThreadProxy::commitRequested() const |
| @@ -488,28 +483,27 @@ void ThreadProxy::forceBeginFrameOnImplThread(CompletionEvent* completion) |
| TRACE_EVENT0("cc", "ThreadProxy::forceBeginFrameOnImplThread"); |
| DCHECK(!m_beginFrameCompletionEventOnImplThread); |
| + setNeedsForcedCommitOnImplThread(); |
| if (m_schedulerOnImplThread->commitPending()) { |
| completion->signal(); |
| return; |
| } |
| m_beginFrameCompletionEventOnImplThread = completion; |
| - setNeedsForcedCommitOnImplThread(); |
| } |
| void ThreadProxy::scheduledActionBeginFrame() |
| { |
| TRACE_EVENT0("cc", "ThreadProxy::scheduledActionBeginFrame"); |
| - DCHECK(!m_pendingBeginFrameRequest); |
| - m_pendingBeginFrameRequest = make_scoped_ptr(new BeginFrameAndCommitState()); |
| - m_pendingBeginFrameRequest->monotonicFrameBeginTime = base::TimeTicks::Now(); |
| - m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); |
| - m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransform(); |
| - m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes(); |
| + scoped_ptr<BeginFrameAndCommitState> beginFrameState(new BeginFrameAndCommitState); |
| + beginFrameState->monotonicFrameBeginTime = base::TimeTicks::Now(); |
| + beginFrameState->scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); |
| + beginFrameState->implTransform = m_layerTreeHostImpl->implTransform(); |
| + beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes(); |
|
enne (OOO)
2012/11/02 18:02:57
Maybe move the DCHECK(memoryAllocationLimitBytes)
|
| if (m_layerTreeHost->contentsTextureManager()) |
| - m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pendingBeginFrameRequest->evictedContentsTexturesBackings); |
| + m_layerTreeHost->contentsTextureManager()->getEvictedBackings(beginFrameState->evictedContentsTexturesBackings); |
| - m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this))); |
| + m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginFrame, base::Unretained(this), base::Passed(beginFrameState.Pass()))); |
| if (m_beginFrameCompletionEventOnImplThread) { |
| m_beginFrameCompletionEventOnImplThread->signal(); |
| @@ -517,7 +511,7 @@ void ThreadProxy::scheduledActionBeginFrame() |
| } |
| } |
| -void ThreadProxy::beginFrame() |
| +void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameState) |
| { |
| TRACE_EVENT0("cc", "ThreadProxy::beginFrame"); |
| DCHECK(isMainThread()); |
| @@ -525,22 +519,15 @@ void ThreadProxy::beginFrame() |
| return; |
| if (m_deferCommits) { |
| - m_deferredCommitPending = true; |
| + m_pendingDeferredCommit = beginFrameState.Pass(); |
| m_layerTreeHost->didDeferCommit(); |
| TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| return; |
| } |
| - if (!m_pendingBeginFrameRequest) { |
| - TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); |
| - return; |
| - } |
| - |
| if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::haveCompositorThreadContext()) |
| WebSharedGraphicsContext3D::createCompositorThreadContext(); |
| - scoped_ptr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.Pass()); |
| - |
| // Do not notify the impl thread of commit requests that occur during |
| // the apply/animate/layout part of the beginFrameAndCommit process since |
| // those commit requests will get painted immediately. Once we have done |
| @@ -554,15 +541,14 @@ void ThreadProxy::beginFrame() |
| // callbacks will trigger another frame. |
| m_animateRequested = false; |
| - // FIXME: technically, scroll deltas need to be applied for dropped commits as well. |
| - // Re-do the commit flow so that we don't send the scrollInfo on the BFAC message. |
| - m_layerTreeHost->applyScrollAndScale(*request->scrollInfo); |
| - m_layerTreeHost->setImplTransform(request->implTransform); |
| + if (beginFrameState) { |
| + m_layerTreeHost->applyScrollAndScale(*beginFrameState->scrollInfo); |
| + m_layerTreeHost->setImplTransform(beginFrameState->implTransform); |
| + } |
| if (!m_inCompositeAndReadback && !m_layerTreeHost->visible()) { |
| m_commitRequested = false; |
| m_commitRequestSentToImplThread = false; |
| - m_forcedCommitRequested = false; |
| TRACE_EVENT0("cc", "EarlyOut_NotVisible"); |
| Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameAbortedOnImplThread, base::Unretained(this))); |
| @@ -571,7 +557,8 @@ void ThreadProxy::beginFrame() |
| m_layerTreeHost->willBeginFrame(); |
| - m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime); |
| + base::TimeTicks frameBeginTime = beginFrameState ? beginFrameState->monotonicFrameBeginTime : base::TimeTicks::Now(); |
|
enne (OOO)
2012/11/02 18:02:57
This looks a little problematic. When we get the
|
| + m_layerTreeHost->updateAnimations(frameBeginTime); |
| m_layerTreeHost->layout(); |
| // Clear the commit flag after updating animations and layout here --- objects that only |
| @@ -579,17 +566,17 @@ void ThreadProxy::beginFrame() |
| // updateLayers. |
| m_commitRequested = false; |
| m_commitRequestSentToImplThread = false; |
| - m_forcedCommitRequested = false; |
| if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
| TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); |
| return; |
| } |
| - m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(request->evictedContentsTexturesBackings); |
| + if (beginFrameState) |
| + m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(beginFrameState->evictedContentsTexturesBackings); |
| scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQueue); |
| - m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimitBytes); |
| + m_layerTreeHost->updateLayers(*(queue.get()), beginFrameState ? beginFrameState->memoryAllocationLimitBytes : 0); |
| // Once single buffered layers are committed, they cannot be modified until |
| // they are drawn by the impl thread. |
| @@ -980,6 +967,7 @@ void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render |
| } |
| ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
| + : memoryAllocationLimitBytes(0) |
| { |
| } |