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