| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 { | 77 { |
| 78 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); | 78 TRACE_EVENT0("cc", "CCThreadPRoxy::compositeAndReadback"); |
| 79 ASSERT(isMainThread()); | 79 ASSERT(isMainThread()); |
| 80 ASSERT(m_layerTreeHost); | 80 ASSERT(m_layerTreeHost); |
| 81 | 81 |
| 82 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 82 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
| 83 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); | 83 TRACE_EVENT0("cc", "compositeAndReadback_EarlyOut_LR_Uninitialized"); |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 | |
| 88 // Perform a synchronous commit. | 87 // Perform a synchronous commit. |
| 89 { | 88 { |
| 90 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 89 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
| 91 CCCompletionEvent beginFrameCompletion; | 90 CCCompletionEvent beginFrameCompletion; |
| 92 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:forceBeginFrameOnImplThread, &beginFrameCompletion)); | 91 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:forceBeginFrameOnImplThread, &beginFrameCompletion)); |
| 93 beginFrameCompletion.wait(); | 92 beginFrameCompletion.wait(); |
| 94 } | 93 } |
| 95 m_inCompositeAndReadback = true; | 94 m_inCompositeAndReadback = true; |
| 96 beginFrame(); | 95 beginFrame(0); |
| 97 m_inCompositeAndReadback = false; | 96 m_inCompositeAndReadback = false; |
| 98 | 97 |
| 99 // Perform a synchronous readback. | 98 // Perform a synchronous readback. |
| 100 ReadbackRequest request; | 99 ReadbackRequest request; |
| 101 request.rect = rect; | 100 request.rect = rect; |
| 102 request.pixels = pixels; | 101 request.pixels = pixels; |
| 103 { | 102 { |
| 104 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 103 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
| 105 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:requestReadbackOnImplThread, &request)); | 104 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:requestReadbackOnImplThread, &request)); |
| 106 request.completion.wait(); | 105 request.completion.wait(); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 void CCThreadProxy::scheduledActionBeginFrame() | 448 void CCThreadProxy::scheduledActionBeginFrame() |
| 450 { | 449 { |
| 451 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); | 450 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); |
| 452 ASSERT(!m_pendingBeginFrameRequest); | 451 ASSERT(!m_pendingBeginFrameRequest); |
| 453 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); | 452 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); |
| 454 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); | 453 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); |
| 455 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); | 454 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); |
| 456 m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImp
l->contentsTexturesPurged(); | 455 m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImp
l->contentsTexturesPurged(); |
| 457 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); | 456 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); |
| 458 | 457 |
| 459 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame)); | 458 size_t maxPartialTextureUpdates = CCTextureUpdateController::maxPartialUpdat
esDefault(); |
| 459 if (m_layerTreeHostImpl && m_layerTreeHostImpl->renderer() && m_layerTreeHos
tImpl->renderer()->textureUploader()) |
| 460 maxPartialTextureUpdates = CCTextureUpdateController::maxPartialUpdates(
m_layerTreeHostImpl->renderer()->textureUploader()); |
| 461 |
| 462 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame, maxPartialTextureUpdates)); |
| 460 | 463 |
| 461 if (m_beginFrameCompletionEventOnImplThread) { | 464 if (m_beginFrameCompletionEventOnImplThread) { |
| 462 m_beginFrameCompletionEventOnImplThread->signal(); | 465 m_beginFrameCompletionEventOnImplThread->signal(); |
| 463 m_beginFrameCompletionEventOnImplThread = 0; | 466 m_beginFrameCompletionEventOnImplThread = 0; |
| 464 } | 467 } |
| 465 } | 468 } |
| 466 | 469 |
| 467 void CCThreadProxy::beginFrame() | 470 void CCThreadProxy::beginFrame(size_t maxPartialTextureUpdates) |
| 468 { | 471 { |
| 469 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); | 472 TRACE_EVENT0("cc", "CCThreadProxy::beginFrame"); |
| 470 ASSERT(isMainThread()); | 473 ASSERT(isMainThread()); |
| 474 |
| 471 if (!m_layerTreeHost) | 475 if (!m_layerTreeHost) |
| 472 return; | 476 return; |
| 473 | 477 |
| 474 if (!m_pendingBeginFrameRequest) { | 478 if (!m_pendingBeginFrameRequest) { |
| 475 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); | 479 TRACE_EVENT0("cc", "EarlyOut_StaleBeginFrameMessage"); |
| 476 return; | 480 return; |
| 477 } | 481 } |
| 478 | 482 |
| 479 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) | 483 if (m_layerTreeHost->needsSharedContext() && !WebSharedGraphicsContext3D::ha
veCompositorThreadContext()) |
| 480 WebSharedGraphicsContext3D::createCompositorThreadContext(); | 484 WebSharedGraphicsContext3D::createCompositorThreadContext(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 526 |
| 523 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 527 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
| 524 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); | 528 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); |
| 525 return; | 529 return; |
| 526 } | 530 } |
| 527 | 531 |
| 528 if (request->contentsTexturesWereDeleted) | 532 if (request->contentsTexturesWereDeleted) |
| 529 m_layerTreeHost->unlinkAllContentTextures(); | 533 m_layerTreeHost->unlinkAllContentTextures(); |
| 530 | 534 |
| 531 OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue); | 535 OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue); |
| 532 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); | 536 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes, maxPartialTextureUpdates); |
| 533 | 537 |
| 534 // Once single buffered layers are committed, they cannot be modified until | 538 // Once single buffered layers are committed, they cannot be modified until |
| 535 // they are drawn by the impl thread. | 539 // they are drawn by the impl thread. |
| 536 m_texturesAcquired = false; | 540 m_texturesAcquired = false; |
| 537 | 541 |
| 538 m_layerTreeHost->willCommit(); | 542 m_layerTreeHost->willCommit(); |
| 539 // Before applying scrolls and calling animate, we set m_animateRequested to | 543 // Before applying scrolls and calling animate, we set m_animateRequested to |
| 540 // false. If it is true now, it means setNeedAnimate was called again, but | 544 // false. If it is true now, it means setNeedAnimate was called again, but |
| 541 // during a state when m_commitRequestSentToImplThread = true. We need to | 545 // during a state when m_commitRequestSentToImplThread = true. We need to |
| 542 // force that call to happen again now so that the commit request is sent to | 546 // force that call to happen again now so that the commit request is sent to |
| 543 // the impl thread. | 547 // the impl thread. |
| 544 if (m_animateRequested) { | 548 if (m_animateRequested) { |
| 545 // Forces setNeedsAnimate to consider posting a commit task. | 549 // Forces setNeedsAnimate to consider posting a commit task. |
| 546 m_animateRequested = false; | 550 m_animateRequested = false; |
| 547 setNeedsAnimate(); | 551 setNeedsAnimate(); |
| 548 } | 552 } |
| 549 | 553 |
| 550 // Notify the impl thread that the beginFrame has completed. This will | 554 // Notify the impl thread that the beginFrame has completed. This will |
| 551 // begin the commit process, which is blocking from the main thread's | 555 // begin the commit process, which is blocking from the main thread's |
| 552 // point of view, but asynchronously performed on the impl thread, | 556 // point of view, but asynchronously performed on the impl thread, |
| 553 // coordinated by the CCScheduler. | 557 // coordinated by the CCScheduler. |
| 554 { | 558 { |
| 555 TRACE_EVENT0("cc", "commit"); | 559 TRACE_EVENT0("cc", "commit"); |
| 556 DebugScopedSetMainThreadBlocked mainThreadBlocked; | 560 DebugScopedSetMainThreadBlocked mainThreadBlocked; |
| 557 | 561 |
| 558 CCCompletionEvent completion; | 562 CCCompletionEvent completion; |
| 559 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:beginFrameCompleteOnImplThread, &completion, queue.release(), request->contents
TexturesWereDeleted)); | 563 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy:
:beginFrameCompleteOnImplThread, &completion, queue.release(), request->contents
TexturesWereDeleted, maxPartialTextureUpdates)); |
| 560 completion.wait(); | 564 completion.wait(); |
| 561 } | 565 } |
| 562 | 566 |
| 563 m_layerTreeHost->commitComplete(); | 567 m_layerTreeHost->commitComplete(); |
| 564 m_layerTreeHost->didBeginFrame(); | 568 m_layerTreeHost->didBeginFrame(); |
| 565 } | 569 } |
| 566 | 570 |
| 567 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, PassOwnPtr<CCTextureUpdateQueue> queue, bool contentsTexturesWereDeleted) | 571 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion
, PassOwnPtr<CCTextureUpdateQueue> queue, bool contentsTexturesWereDeleted, size
_t maxPartialTextureUpdates) |
| 568 { | 572 { |
| 569 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); | 573 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread"); |
| 570 ASSERT(!m_commitCompletionEventOnImplThread); | 574 ASSERT(!m_commitCompletionEventOnImplThread); |
| 571 ASSERT(isImplThread() && isMainThreadBlocked()); | 575 ASSERT(isImplThread() && isMainThreadBlocked()); |
| 572 ASSERT(m_schedulerOnImplThread); | 576 ASSERT(m_schedulerOnImplThread); |
| 573 ASSERT(m_schedulerOnImplThread->commitPending()); | 577 ASSERT(m_schedulerOnImplThread->commitPending()); |
| 574 | 578 |
| 575 if (!m_layerTreeHostImpl) { | 579 if (!m_layerTreeHostImpl) { |
| 576 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 580 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
| 577 completion->signal(); | 581 completion->signal(); |
| 578 return; | 582 return; |
| 579 } | 583 } |
| 580 | 584 |
| 581 if (contentsTexturesWereDeleted) { | 585 if (contentsTexturesWereDeleted) { |
| 582 ASSERT(m_layerTreeHostImpl->contentsTexturesPurged()); | 586 ASSERT(m_layerTreeHostImpl->contentsTexturesPurged()); |
| 583 // We unlinked all textures on the main thread, delete them now. | 587 // We unlinked all textures on the main thread, delete them now. |
| 584 m_layerTreeHost->deleteUnlinkedTextures(); | 588 m_layerTreeHost->deleteUnlinkedTextures(); |
| 585 // Mark that we can start drawing again when this commit is complete. | 589 // Mark that we can start drawing again when this commit is complete. |
| 586 m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; | 590 m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; |
| 587 } else if (m_layerTreeHostImpl->contentsTexturesPurged()) { | 591 } else if (m_layerTreeHostImpl->contentsTexturesPurged()) { |
| 588 // We purged the content textures on the impl thread between the time we | 592 // We purged the content textures on the impl thread between the time we |
| 589 // posted the beginFrame task and now, meaning we have a bunch of | 593 // posted the beginFrame task and now, meaning we have a bunch of |
| 590 // uploads that are now invalid. Clear the uploads (they all go to | 594 // uploads that are now invalid. Clear the uploads (they all go to |
| 591 // content textures), and kick another commit to fill them again. | 595 // content textures), and kick another commit to fill them again. |
| 592 queue->clearUploads(); | 596 queue->clearUploads(); |
| 593 setNeedsCommitOnImplThread(); | 597 setNeedsCommitOnImplThread(); |
| 594 } | 598 } |
| 595 | 599 |
| 596 bool hasResourceUpdates = !!queue->fullUploadSize(); | 600 bool hasResourceUpdates = !!queue->fullUploadSize(); |
| 597 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider()
, m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->rendere
r()->textureUploader()); | 601 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider()
, m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->rendere
r()->textureUploader(), maxPartialTextureUpdates); |
| 598 m_commitCompletionEventOnImplThread = completion; | 602 m_commitCompletionEventOnImplThread = completion; |
| 599 | 603 |
| 600 m_schedulerOnImplThread->beginFrameComplete(hasResourceUpdates); | 604 m_schedulerOnImplThread->beginFrameComplete(hasResourceUpdates); |
| 601 } | 605 } |
| 602 | 606 |
| 603 void CCThreadProxy::beginFrameAbortedOnImplThread() | 607 void CCThreadProxy::beginFrameAbortedOnImplThread() |
| 604 { | 608 { |
| 605 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); | 609 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); |
| 606 ASSERT(isImplThread()); | 610 ASSERT(isImplThread()); |
| 607 ASSERT(m_schedulerOnImplThread); | 611 ASSERT(m_schedulerOnImplThread); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 m_schedulerOnImplThread.clear(); | 893 m_schedulerOnImplThread.clear(); |
| 890 completion->signal(); | 894 completion->signal(); |
| 891 } | 895 } |
| 892 | 896 |
| 893 void CCThreadProxy::setFullRootLayerDamageOnImplThread() | 897 void CCThreadProxy::setFullRootLayerDamageOnImplThread() |
| 894 { | 898 { |
| 895 ASSERT(isImplThread()); | 899 ASSERT(isImplThread()); |
| 896 m_layerTreeHostImpl->setFullRootLayerDamage(); | 900 m_layerTreeHostImpl->setFullRootLayerDamage(); |
| 897 } | 901 } |
| 898 | 902 |
| 899 size_t CCThreadProxy::maxPartialTextureUpdates() const | |
| 900 { | |
| 901 return CCTextureUpdateController::maxPartialTextureUpdates(); | |
| 902 } | |
| 903 | |
| 904 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C
CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap
abilities) | 903 void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C
CGraphicsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* cap
abilities) |
| 905 { | 904 { |
| 906 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); | 905 TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread"); |
| 907 ASSERT(isImplThread()); | 906 ASSERT(isImplThread()); |
| 908 if (!m_layerTreeHostImpl->contentsTexturesPurged()) | 907 if (!m_layerTreeHostImpl->contentsTexturesPurged()) |
| 909 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl-
>resourceProvider()); | 908 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl-
>resourceProvider()); |
| 910 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contex
tPtr), textureUploader); | 909 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contex
tPtr), textureUploader); |
| 911 if (*recreateSucceeded) { | 910 if (*recreateSucceeded) { |
| 912 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 911 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
| 913 m_schedulerOnImplThread->didRecreateContext(); | 912 m_schedulerOnImplThread->didRecreateContext(); |
| 914 } | 913 } |
| 915 completion->signal(); | 914 completion->signal(); |
| 916 } | 915 } |
| 917 | 916 |
| 918 void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* comple
tion, CCRenderingStats* stats) | 917 void CCThreadProxy::implSideRenderingStatsOnImplThread(CCCompletionEvent* comple
tion, CCRenderingStats* stats) |
| 919 { | 918 { |
| 920 ASSERT(isImplThread()); | 919 ASSERT(isImplThread()); |
| 921 m_layerTreeHostImpl->renderingStats(*stats); | 920 m_layerTreeHostImpl->renderingStats(*stats); |
| 922 completion->signal(); | 921 completion->signal(); |
| 923 } | 922 } |
| 924 | 923 |
| 925 } // namespace cc | 924 } // namespace cc |
| OLD | NEW |