| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCThreadProxy.h" | 7 #include "CCThreadProxy.h" |
| 8 | 8 |
| 9 #include "CCDelayBasedTimeSource.h" | 9 #include "CCDelayBasedTimeSource.h" |
| 10 #include "CCDrawQuad.h" | 10 #include "CCDrawQuad.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 , m_texturesAcquired(true) | 47 , m_texturesAcquired(true) |
| 48 , m_inCompositeAndReadback(false) | 48 , m_inCompositeAndReadback(false) |
| 49 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) | 49 , m_mainThreadProxy(CCScopedThreadProxy::create(CCProxy::mainThread())) |
| 50 , m_beginFrameCompletionEventOnImplThread(0) | 50 , m_beginFrameCompletionEventOnImplThread(0) |
| 51 , m_readbackRequestOnImplThread(0) | 51 , m_readbackRequestOnImplThread(0) |
| 52 , m_commitCompletionEventOnImplThread(0) | 52 , m_commitCompletionEventOnImplThread(0) |
| 53 , m_textureAcquisitionCompletionEventOnImplThread(0) | 53 , m_textureAcquisitionCompletionEventOnImplThread(0) |
| 54 , m_resetContentsTexturesPurgedAfterCommitOnImplThread(false) | 54 , m_resetContentsTexturesPurgedAfterCommitOnImplThread(false) |
| 55 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 55 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
| 56 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 56 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
| 57 , m_totalCommitCount(0) |
| 57 { | 58 { |
| 58 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); | 59 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); |
| 59 ASSERT(isMainThread()); | 60 ASSERT(isMainThread()); |
| 60 } | 61 } |
| 61 | 62 |
| 62 CCThreadProxy::~CCThreadProxy() | 63 CCThreadProxy::~CCThreadProxy() |
| 63 { | 64 { |
| 64 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); | 65 TRACE_EVENT0("cc", "CCThreadProxy::~CCThreadProxy"); |
| 65 ASSERT(isMainThread()); | 66 ASSERT(isMainThread()); |
| 66 ASSERT(!m_started); | 67 ASSERT(!m_started); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 context.leakPtr(), | 235 context.leakPtr(), |
| 235 &recreateSucceeded, | 236 &recreateSucceeded, |
| 236 &capabilities)); | 237 &capabilities)); |
| 237 completion.wait(); | 238 completion.wait(); |
| 238 | 239 |
| 239 if (recreateSucceeded) | 240 if (recreateSucceeded) |
| 240 m_RendererCapabilitiesMainThreadCopy = capabilities; | 241 m_RendererCapabilitiesMainThreadCopy = capabilities; |
| 241 return recreateSucceeded; | 242 return recreateSucceeded; |
| 242 } | 243 } |
| 243 | 244 |
| 244 void CCThreadProxy::implSideRenderingStats(CCRenderingStats& stats) | 245 void CCThreadProxy::renderingStats(CCRenderingStats* stats) |
| 245 { | 246 { |
| 246 ASSERT(isMainThread()); | 247 ASSERT(isMainThread()); |
| 247 | 248 |
| 248 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 249 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
| 249 CCCompletionEvent completion; | 250 CCCompletionEvent completion; |
| 250 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::imp
lSideRenderingStatsOnImplThread, | 251 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::ren
deringStatsOnImplThread, |
| 251 &completion, | 252 &completion, |
| 252 &stats)); | 253 stats)); |
| 254 stats->totalCommitTimeInSeconds = m_totalCommitTime.InSecondsF(); |
| 255 stats->totalCommitCount = m_totalCommitCount; |
| 256 |
| 253 completion.wait(); | 257 completion.wait(); |
| 254 } | 258 } |
| 255 | 259 |
| 256 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const | 260 const RendererCapabilities& CCThreadProxy::rendererCapabilities() const |
| 257 { | 261 { |
| 258 ASSERT(m_rendererInitialized); | 262 ASSERT(m_rendererInitialized); |
| 259 return m_RendererCapabilitiesMainThreadCopy; | 263 return m_RendererCapabilitiesMainThreadCopy; |
| 260 } | 264 } |
| 261 | 265 |
| 262 void CCThreadProxy::loseContext() | 266 void CCThreadProxy::loseContext() |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 m_animateRequested = false; | 556 m_animateRequested = false; |
| 553 setNeedsAnimate(); | 557 setNeedsAnimate(); |
| 554 } | 558 } |
| 555 | 559 |
| 556 // Notify the impl thread that the beginFrame has completed. This will | 560 // Notify the impl thread that the beginFrame has completed. This will |
| 557 // begin the commit process, which is blocking from the main thread's | 561 // begin the commit process, which is blocking from the main thread's |
| 558 // point of view, but asynchronously performed on the impl thread, | 562 // point of view, but asynchronously performed on the impl thread, |
| 559 // coordinated by the CCScheduler. | 563 // coordinated by the CCScheduler. |
| 560 { | 564 { |
| 561 TRACE_EVENT0("cc", "commit"); | 565 TRACE_EVENT0("cc", "commit"); |
| 566 |
| 562 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 567 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
| 563 | 568 |
| 569 base::TimeTicks startTime = base::TimeTicks::HighResNow(); |
| 564 CCCompletionEvent completion; | 570 CCCompletionEvent completion; |
| 565 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:beginFrameCompleteOnImplThread, &completion, queue.release())); | 571 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:beginFrameCompleteOnImplThread, &completion, queue.release())); |
| 566 completion.wait(); | 572 completion.wait(); |
| 573 base::TimeTicks endTime = base::TimeTicks::HighResNow(); |
| 574 |
| 575 m_totalCommitTime += endTime - startTime; |
| 576 m_totalCommitCount++; |
| 567 } | 577 } |
| 568 | 578 |
| 569 m_layerTreeHost->commitComplete(); | 579 m_layerTreeHost->commitComplete(); |
| 570 m_layerTreeHost->didBeginFrame(); | 580 m_layerTreeHost->didBeginFrame(); |
| 571 } | 581 } |
| 572 | 582 |
| 573 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, PassOwnPtr<CCTextureUpdateQueue> queue) | 583 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, PassOwnPtr<CCTextureUpdateQueue> queue) |
| 574 { | 584 { |
| 575 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); | 585 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); |
| 576 ASSERT(!m_commitCompletionEventOnImplThread); | 586 ASSERT(!m_commitCompletionEventOnImplThread); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 ASSERT(isImplThread()); | 925 ASSERT(isImplThread()); |
| 916 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 926 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
| 917 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contex
tPtr)); | 927 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contex
tPtr)); |
| 918 if (*recreateSucceeded) { | 928 if (*recreateSucceeded) { |
| 919 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 929 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
| 920 m_schedulerOnImplThread->didRecreateContext(); | 930 m_schedulerOnImplThread->didRecreateContext(); |
| 921 } | 931 } |
| 922 completion->signal(); | 932 completion->signal(); |
| 923 } | 933 } |
| 924 | 934 |
| 925 void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* comple
tion, CCRenderingStats* stats) | 935 void CCThreadProxy::renderingStatsOnImplThread(CCCompletionEvent* completion, CC
RenderingStats* stats) |
| 926 { | 936 { |
| 927 ASSERT(isImplThread()); | 937 ASSERT(isImplThread()); |
| 928 m_layerTreeHostImpl->renderingStats(*stats); | 938 m_layerTreeHostImpl->renderingStats(stats); |
| 929 completion->signal(); | 939 completion->signal(); |
| 930 } | 940 } |
| 931 | 941 |
| 932 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 942 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
| 933 : monotonicFrameBeginTime(0) | 943 : monotonicFrameBeginTime(0) |
| 934 { | 944 { |
| 935 } | 945 } |
| 936 | 946 |
| 937 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 947 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
| 938 { | 948 { |
| 939 } | 949 } |
| 940 | 950 |
| 941 } // namespace cc | 951 } // namespace cc |
| OLD | NEW |