| Index: cc/thread_proxy.cc
|
| diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc
|
| index 8a50a7780ae314022e49b91f25af4a1dda906045..9490f3c94dfda1c7a6f15341f894f2efb02b148d 100644
|
| --- a/cc/thread_proxy.cc
|
| +++ b/cc/thread_proxy.cc
|
| @@ -38,7 +38,6 @@ ThreadProxy::ThreadProxy(LayerTreeHost* layerTreeHost, scoped_ptr<Thread> implTh
|
| , 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, scoped_ptr<Thread> implTh
|
| , 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();
|
| }
|
|
|
| @@ -402,10 +399,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
|
| @@ -486,28 +481,28 @@ 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();
|
| + DCHECK_GT(m_layerTreeHostImpl->memoryAllocationLimitBytes(), 0u);
|
| + beginFrameState->memoryAllocationLimitBytes = m_layerTreeHostImpl->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();
|
| @@ -515,7 +510,7 @@ void ThreadProxy::scheduledActionBeginFrame()
|
| }
|
| }
|
|
|
| -void ThreadProxy::beginFrame()
|
| +void ThreadProxy::beginFrame(scoped_ptr<BeginFrameAndCommitState> beginFrameState)
|
| {
|
| TRACE_EVENT0("cc", "ThreadProxy::beginFrame");
|
| DCHECK(isMainThread());
|
| @@ -523,22 +518,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
|
| @@ -552,15 +540,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)));
|
| @@ -569,7 +556,8 @@ void ThreadProxy::beginFrame()
|
|
|
| m_layerTreeHost->willBeginFrame();
|
|
|
| - m_layerTreeHost->updateAnimations(request->monotonicFrameBeginTime);
|
| + if (beginFrameState)
|
| + m_layerTreeHost->updateAnimations(beginFrameState->monotonicFrameBeginTime);
|
| m_layerTreeHost->layout();
|
|
|
| // Clear the commit flag after updating animations and layout here --- objects that only
|
| @@ -577,17 +565,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.
|
| @@ -966,6 +954,7 @@ void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
|
| }
|
|
|
| ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState()
|
| + : memoryAllocationLimitBytes(0)
|
| {
|
| }
|
|
|
|
|