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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 , m_layerTreeHost(layerTreeHost) | 44 , m_layerTreeHost(layerTreeHost) |
45 , m_rendererInitialized(false) | 45 , m_rendererInitialized(false) |
46 , m_started(false) | 46 , m_started(false) |
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) | |
55 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) | 54 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) |
56 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) | 55 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) |
57 , m_totalCommitCount(0) | 56 , m_totalCommitCount(0) |
58 { | 57 { |
59 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); | 58 TRACE_EVENT0("cc", "CCThreadProxy::CCThreadProxy"); |
60 ASSERT(isMainThread()); | 59 ASSERT(isMainThread()); |
61 } | 60 } |
62 | 61 |
63 CCThreadProxy::~CCThreadProxy() | 62 CCThreadProxy::~CCThreadProxy() |
64 { | 63 { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 { | 346 { |
348 ASSERT(isImplThread()); | 347 ASSERT(isImplThread()); |
349 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre
ad"); | 348 TRACE_EVENT0("cc", "CCThreadProxy::postAnimationEventsToMainThreadOnImplThre
ad"); |
350 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim
ationEvents, events.release(), wallClockTime)); | 349 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::setAnim
ationEvents, events.release(), wallClockTime)); |
351 } | 350 } |
352 | 351 |
353 void CCThreadProxy::releaseContentsTexturesOnImplThread() | 352 void CCThreadProxy::releaseContentsTexturesOnImplThread() |
354 { | 353 { |
355 ASSERT(isImplThread()); | 354 ASSERT(isImplThread()); |
356 | 355 |
357 m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHost
Impl->resourceProvider()); | 356 if (m_layerTreeHost->contentsTextureManager()) |
| 357 m_layerTreeHost->contentsTextureManager()->reduceMemoryOnImplThread(0, m
_layerTreeHostImpl->resourceProvider()); |
358 | 358 |
359 // Make sure that we get a new commit before drawing again. | |
360 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false; | |
361 // The texture upload queue may reference textures that were just purged, cl
ear | 359 // The texture upload queue may reference textures that were just purged, cl
ear |
362 // them from the queue. | 360 // them from the queue. |
363 if (m_currentTextureUpdateControllerOnImplThread.get() && m_layerTreeHost->e
victedContentsTexturesBackingsExist()) | 361 if (m_currentTextureUpdateControllerOnImplThread.get()) |
364 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); | 362 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); |
365 } | 363 } |
366 | 364 |
367 void CCThreadProxy::setNeedsRedraw() | 365 void CCThreadProxy::setNeedsRedraw() |
368 { | 366 { |
369 ASSERT(isMainThread()); | 367 ASSERT(isMainThread()); |
370 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); | 368 TRACE_EVENT0("cc", "CCThreadProxy::setNeedsRedraw"); |
371 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
FullRootLayerDamageOnImplThread)); | 369 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
FullRootLayerDamageOnImplThread)); |
372 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsRedrawOnImplThread)); | 370 CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::set
NeedsRedrawOnImplThread)); |
373 } | 371 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 459 |
462 void CCThreadProxy::scheduledActionBeginFrame() | 460 void CCThreadProxy::scheduledActionBeginFrame() |
463 { | 461 { |
464 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); | 462 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionBeginFrame"); |
465 ASSERT(!m_pendingBeginFrameRequest); | 463 ASSERT(!m_pendingBeginFrameRequest); |
466 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); | 464 m_pendingBeginFrameRequest = adoptPtr(new BeginFrameAndCommitState()); |
467 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); | 465 m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasin
gTime(); |
468 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); | 466 m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollD
eltas(); |
469 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); | 467 m_pendingBeginFrameRequest->implTransform = m_layerTreeHostImpl->implTransfo
rm(); |
470 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); | 468 m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl
->memoryAllocationLimitBytes(); |
471 m_layerTreeHost->getEvictedContentTexturesBackings(m_pendingBeginFrameReques
t->evictedContentsTexturesBackings); | 469 if (m_layerTreeHost->contentsTextureManager()) |
| 470 m_layerTreeHost->contentsTextureManager()->getEvictedBackings(m_pending
BeginFrameRequest->evictedContentsTexturesBackings); |
472 | 471 |
473 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame)); | 472 m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFr
ame)); |
474 | 473 |
475 if (m_beginFrameCompletionEventOnImplThread) { | 474 if (m_beginFrameCompletionEventOnImplThread) { |
476 m_beginFrameCompletionEventOnImplThread->signal(); | 475 m_beginFrameCompletionEventOnImplThread->signal(); |
477 m_beginFrameCompletionEventOnImplThread = 0; | 476 m_beginFrameCompletionEventOnImplThread = 0; |
478 } | 477 } |
479 } | 478 } |
480 | 479 |
481 void CCThreadProxy::beginFrame() | 480 void CCThreadProxy::beginFrame() |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // updateLayers. | 532 // updateLayers. |
534 m_commitRequested = false; | 533 m_commitRequested = false; |
535 m_commitRequestSentToImplThread = false; | 534 m_commitRequestSentToImplThread = false; |
536 m_forcedCommitRequested = false; | 535 m_forcedCommitRequested = false; |
537 | 536 |
538 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 537 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
539 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); | 538 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); |
540 return; | 539 return; |
541 } | 540 } |
542 | 541 |
543 m_layerTreeHost->unlinkEvictedContentTexturesBackings(request->evictedConten
tsTexturesBackings); | 542 m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(request->ev
ictedContentsTexturesBackings); |
544 | 543 |
545 OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue); | 544 OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue); |
546 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); | 545 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); |
547 | 546 |
548 // Once single buffered layers are committed, they cannot be modified until | 547 // Once single buffered layers are committed, they cannot be modified until |
549 // they are drawn by the impl thread. | 548 // they are drawn by the impl thread. |
550 m_texturesAcquired = false; | 549 m_texturesAcquired = false; |
551 | 550 |
552 m_layerTreeHost->willCommit(); | 551 m_layerTreeHost->willCommit(); |
553 // Before applying scrolls and calling animate, we set m_animateRequested to | 552 // Before applying scrolls and calling animate, we set m_animateRequested to |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 ASSERT(isImplThread() && isMainThreadBlocked()); | 590 ASSERT(isImplThread() && isMainThreadBlocked()); |
592 ASSERT(m_schedulerOnImplThread); | 591 ASSERT(m_schedulerOnImplThread); |
593 ASSERT(m_schedulerOnImplThread->commitPending()); | 592 ASSERT(m_schedulerOnImplThread->commitPending()); |
594 | 593 |
595 if (!m_layerTreeHostImpl.get()) { | 594 if (!m_layerTreeHostImpl.get()) { |
596 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 595 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
597 completion->signal(); | 596 completion->signal(); |
598 return; | 597 return; |
599 } | 598 } |
600 | 599 |
601 // Clear any uploads we were making to textures linked to evicted | 600 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ |
602 // resources | 601 // Clear any uploads we were making to textures linked to evicted |
603 if (m_layerTreeHost->evictedContentsTexturesBackingsExist()) | 602 // resources |
604 queue->clearUploadsToEvictedResources(); | 603 queue->clearUploadsToEvictedResources(); |
| 604 // Some textures in the layer tree are invalid. Kick off another commit |
| 605 // to fill them again. |
| 606 setNeedsCommitOnImplThread(); |
| 607 } |
605 | 608 |
606 // If we unlinked evicted textures on the main thread, delete them now. | 609 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; |
607 if (m_layerTreeHost->deleteEvictedContentTexturesBackings()) { | |
608 // Deleting the evicted textures' backings resulted in some textures in
the | |
609 // layer tree being invalidated (unliked from their backings). Kick off | |
610 // another commit to fill them again. | |
611 setNeedsCommitOnImplThread(); | |
612 } else { | |
613 // The layer tree does not reference evicted textures, so mark that we | |
614 // can draw this tree once this commit is complete. | |
615 if (m_layerTreeHostImpl->contentsTexturesPurged()) | |
616 m_resetContentsTexturesPurgedAfterCommitOnImplThread = true; | |
617 } | |
618 | 610 |
619 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider()
, m_layerTreeHostImpl->resourceProvider()->textureUploader()); | 611 m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::cr
eate(this, CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider()
, m_layerTreeHostImpl->resourceProvider()->textureUploader()); |
620 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( | 612 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( |
621 m_schedulerOnImplThread->anticipatedDrawTime()); | 613 m_schedulerOnImplThread->anticipatedDrawTime()); |
622 | 614 |
623 m_commitCompletionEventOnImplThread = completion; | 615 m_commitCompletionEventOnImplThread = completion; |
624 } | 616 } |
625 | 617 |
626 void CCThreadProxy::beginFrameAbortedOnImplThread() | 618 void CCThreadProxy::beginFrameAbortedOnImplThread() |
627 { | 619 { |
628 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); | 620 TRACE_EVENT0("cc", "CCThreadProxy::beginFrameAbortedOnImplThread"); |
629 ASSERT(isImplThread()); | 621 ASSERT(isImplThread()); |
630 ASSERT(m_schedulerOnImplThread); | 622 ASSERT(m_schedulerOnImplThread); |
631 ASSERT(m_schedulerOnImplThread->commitPending()); | 623 ASSERT(m_schedulerOnImplThread->commitPending()); |
632 | 624 |
633 m_schedulerOnImplThread->beginFrameAborted(); | 625 m_schedulerOnImplThread->beginFrameAborted(); |
634 } | 626 } |
635 | 627 |
636 void CCThreadProxy::scheduledActionCommit() | 628 void CCThreadProxy::scheduledActionCommit() |
637 { | 629 { |
638 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); | 630 TRACE_EVENT0("cc", "CCThreadProxy::scheduledActionCommit"); |
639 ASSERT(isImplThread()); | 631 ASSERT(isImplThread()); |
640 ASSERT(m_commitCompletionEventOnImplThread); | 632 ASSERT(m_commitCompletionEventOnImplThread); |
641 ASSERT(m_currentTextureUpdateControllerOnImplThread); | 633 ASSERT(m_currentTextureUpdateControllerOnImplThread); |
642 | 634 |
643 // Complete all remaining texture updates. | 635 // Complete all remaining texture updates. |
644 m_currentTextureUpdateControllerOnImplThread->finalize(); | 636 m_currentTextureUpdateControllerOnImplThread->finalize(); |
645 m_currentTextureUpdateControllerOnImplThread.clear(); | 637 m_currentTextureUpdateControllerOnImplThread.clear(); |
646 | 638 |
| 639 // If there are linked evicted backings, these backings' resources may be pu
t into the |
| 640 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. |
| 641 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); |
| 642 |
647 m_layerTreeHostImpl->beginCommit(); | 643 m_layerTreeHostImpl->beginCommit(); |
648 | |
649 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); | 644 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); |
650 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); | 645 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); |
651 | 646 |
652 if (m_resetContentsTexturesPurgedAfterCommitOnImplThread) { | 647 if (newImplTreeHasNoEvictedResources) { |
653 m_resetContentsTexturesPurgedAfterCommitOnImplThread = false; | 648 if (m_layerTreeHostImpl->contentsTexturesPurged()) |
654 m_layerTreeHostImpl->resetContentsTexturesPurged(); | 649 m_layerTreeHostImpl->resetContentsTexturesPurged(); |
655 } | 650 } |
656 | 651 |
657 m_layerTreeHostImpl->commitComplete(); | 652 m_layerTreeHostImpl->commitComplete(); |
658 | 653 |
659 m_nextFrameIsNewlyCommittedFrameOnImplThread = true; | 654 m_nextFrameIsNewlyCommittedFrameOnImplThread = true; |
660 | 655 |
661 m_commitCompletionEventOnImplThread->signal(); | 656 m_commitCompletionEventOnImplThread->signal(); |
662 m_commitCompletionEventOnImplThread = 0; | 657 m_commitCompletionEventOnImplThread = 0; |
663 | 658 |
664 // SetVisible kicks off the next scheduler action, so this must be last. | 659 // SetVisible kicks off the next scheduler action, so this must be last. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 943 CCThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
949 : monotonicFrameBeginTime(0) | 944 : monotonicFrameBeginTime(0) |
950 { | 945 { |
951 } | 946 } |
952 | 947 |
953 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 948 CCThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
954 { | 949 { |
955 } | 950 } |
956 | 951 |
957 } // namespace cc | 952 } // namespace cc |
OLD | NEW |