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 "cc/thread_proxy.h" | 7 #include "cc/thread_proxy.h" |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/delay_based_time_source.h" | 10 #include "cc/delay_based_time_source.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 return false; | 356 return false; |
357 | 357 |
358 ResourceProvider::debugNotifyEnterZone(0x1000000); | 358 ResourceProvider::debugNotifyEnterZone(0x1000000); |
359 bool reduceResult = m_layerTreeHost->contentsTextureManager()->reduceMemoryO
nImplThread(limitBytes, priorityCutoff, m_layerTreeHostImpl->resourceProvider())
; | 359 bool reduceResult = m_layerTreeHost->contentsTextureManager()->reduceMemoryO
nImplThread(limitBytes, priorityCutoff, m_layerTreeHostImpl->resourceProvider())
; |
360 ResourceProvider::debugNotifyLeaveZone(); | 360 ResourceProvider::debugNotifyLeaveZone(); |
361 if (!reduceResult) | 361 if (!reduceResult) |
362 return false; | 362 return false; |
363 | 363 |
364 // The texture upload queue may reference textures that were just purged, cl
ear | 364 // The texture upload queue may reference textures that were just purged, cl
ear |
365 // them from the queue. | 365 // them from the queue. |
366 if (m_currentTextureUpdateControllerOnImplThread.get()) | 366 if (m_currentResourceUpdateControllerOnImplThread.get()) |
367 m_currentTextureUpdateControllerOnImplThread->discardUploadsToEvictedRes
ources(); | 367 m_currentResourceUpdateControllerOnImplThread->discardUploadsToEvictedRe
sources(); |
368 return true; | 368 return true; |
369 } | 369 } |
370 | 370 |
371 void ThreadProxy::setNeedsRedraw() | 371 void ThreadProxy::setNeedsRedraw() |
372 { | 372 { |
373 DCHECK(isMainThread()); | 373 DCHECK(isMainThread()); |
374 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); | 374 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedraw"); |
375 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); | 375 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setFullRo
otLayerDamageOnImplThread)); |
376 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); | 376 Proxy::implThread()->postTask(createThreadTask(this, &ThreadProxy::setNeedsR
edrawOnImplThread)); |
377 } | 377 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 m_commitRequestSentToImplThread = false; | 540 m_commitRequestSentToImplThread = false; |
541 m_forcedCommitRequested = false; | 541 m_forcedCommitRequested = false; |
542 | 542 |
543 if (!m_layerTreeHost->initializeRendererIfNeeded()) { | 543 if (!m_layerTreeHost->initializeRendererIfNeeded()) { |
544 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); | 544 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); |
545 return; | 545 return; |
546 } | 546 } |
547 | 547 |
548 m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(request->ev
ictedContentsTexturesBackings); | 548 m_layerTreeHost->contentsTextureManager()->unlinkEvictedBackings(request->ev
ictedContentsTexturesBackings); |
549 | 549 |
550 scoped_ptr<TextureUpdateQueue> queue = make_scoped_ptr(new TextureUpdateQueu
e); | 550 scoped_ptr<ResourceUpdateQueue> queue = make_scoped_ptr(new ResourceUpdateQu
eue); |
551 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); | 551 m_layerTreeHost->updateLayers(*(queue.get()), request->memoryAllocationLimit
Bytes); |
552 | 552 |
553 // Once single buffered layers are committed, they cannot be modified until | 553 // Once single buffered layers are committed, they cannot be modified until |
554 // they are drawn by the impl thread. | 554 // they are drawn by the impl thread. |
555 m_texturesAcquired = false; | 555 m_texturesAcquired = false; |
556 | 556 |
557 m_layerTreeHost->willCommit(); | 557 m_layerTreeHost->willCommit(); |
558 // Before applying scrolls and calling animate, we set m_animateRequested to | 558 // Before applying scrolls and calling animate, we set m_animateRequested to |
559 // false. If it is true now, it means setNeedAnimate was called again, but | 559 // false. If it is true now, it means setNeedAnimate was called again, but |
560 // during a state when m_commitRequestSentToImplThread = true. We need to | 560 // during a state when m_commitRequestSentToImplThread = true. We need to |
(...skipping 21 matching lines...) Expand all Loading... |
582 base::TimeTicks endTime = base::TimeTicks::HighResNow(); | 582 base::TimeTicks endTime = base::TimeTicks::HighResNow(); |
583 | 583 |
584 m_totalCommitTime += endTime - startTime; | 584 m_totalCommitTime += endTime - startTime; |
585 m_totalCommitCount++; | 585 m_totalCommitCount++; |
586 } | 586 } |
587 | 587 |
588 m_layerTreeHost->commitComplete(); | 588 m_layerTreeHost->commitComplete(); |
589 m_layerTreeHost->didBeginFrame(); | 589 m_layerTreeHost->didBeginFrame(); |
590 } | 590 } |
591 | 591 |
592 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Te
xtureUpdateQueue* rawQueue) | 592 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re
sourceUpdateQueue* rawQueue) |
593 { | 593 { |
594 scoped_ptr<TextureUpdateQueue> queue(rawQueue); | 594 scoped_ptr<ResourceUpdateQueue> queue(rawQueue); |
595 | 595 |
596 TRACE_EVENT0("cc", "ThreadProxy::beginFrameCompleteOnImplThread"); | 596 TRACE_EVENT0("cc", "ThreadProxy::beginFrameCompleteOnImplThread"); |
597 DCHECK(!m_commitCompletionEventOnImplThread); | 597 DCHECK(!m_commitCompletionEventOnImplThread); |
598 DCHECK(isImplThread() && isMainThreadBlocked()); | 598 DCHECK(isImplThread() && isMainThreadBlocked()); |
599 DCHECK(m_schedulerOnImplThread); | 599 DCHECK(m_schedulerOnImplThread); |
600 DCHECK(m_schedulerOnImplThread->commitPending()); | 600 DCHECK(m_schedulerOnImplThread->commitPending()); |
601 | 601 |
602 if (!m_layerTreeHostImpl.get()) { | 602 if (!m_layerTreeHostImpl.get()) { |
603 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); | 603 TRACE_EVENT0("cc", "EarlyOut_NoLayerTree"); |
604 completion->signal(); | 604 completion->signal(); |
605 return; | 605 return; |
606 } | 606 } |
607 | 607 |
608 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ | 608 if (m_layerTreeHost->contentsTextureManager()->linkedEvictedBackingsExist())
{ |
609 // Clear any uploads we were making to textures linked to evicted | 609 // Clear any uploads we were making to textures linked to evicted |
610 // resources | 610 // resources |
611 queue->clearUploadsToEvictedResources(); | 611 queue->clearUploadsToEvictedResources(); |
612 // Some textures in the layer tree are invalid. Kick off another commit | 612 // Some textures in the layer tree are invalid. Kick off another commit |
613 // to fill them again. | 613 // to fill them again. |
614 setNeedsCommitOnImplThread(); | 614 setNeedsCommitOnImplThread(); |
615 } | 615 } |
616 | 616 |
617 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; | 617 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; |
618 | 618 |
619 m_currentTextureUpdateControllerOnImplThread = TextureUpdateController::crea
te(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvide
r()); | 619 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::cr
eate(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvi
der()); |
620 ResourceProvider::debugNotifyEnterZone(0x2000000); | 620 ResourceProvider::debugNotifyEnterZone(0x2000000); |
621 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates( | 621 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates( |
622 m_schedulerOnImplThread->anticipatedDrawTime()); | 622 m_schedulerOnImplThread->anticipatedDrawTime()); |
623 ResourceProvider::debugNotifyLeaveZone(); | 623 ResourceProvider::debugNotifyLeaveZone(); |
624 | 624 |
625 m_commitCompletionEventOnImplThread = completion; | 625 m_commitCompletionEventOnImplThread = completion; |
626 } | 626 } |
627 | 627 |
628 void ThreadProxy::beginFrameAbortedOnImplThread() | 628 void ThreadProxy::beginFrameAbortedOnImplThread() |
629 { | 629 { |
630 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); | 630 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); |
631 DCHECK(isImplThread()); | 631 DCHECK(isImplThread()); |
632 DCHECK(m_schedulerOnImplThread); | 632 DCHECK(m_schedulerOnImplThread); |
633 DCHECK(m_schedulerOnImplThread->commitPending()); | 633 DCHECK(m_schedulerOnImplThread->commitPending()); |
634 | 634 |
635 m_schedulerOnImplThread->beginFrameAborted(); | 635 m_schedulerOnImplThread->beginFrameAborted(); |
636 } | 636 } |
637 | 637 |
638 void ThreadProxy::scheduledActionCommit() | 638 void ThreadProxy::scheduledActionCommit() |
639 { | 639 { |
640 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit"); | 640 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit"); |
641 DCHECK(isImplThread()); | 641 DCHECK(isImplThread()); |
642 DCHECK(m_commitCompletionEventOnImplThread); | 642 DCHECK(m_commitCompletionEventOnImplThread); |
643 DCHECK(m_currentTextureUpdateControllerOnImplThread); | 643 DCHECK(m_currentResourceUpdateControllerOnImplThread); |
644 | 644 |
645 // Complete all remaining texture updates. | 645 // Complete all remaining texture updates. |
646 ResourceProvider::debugNotifyEnterZone(0x3000000); | 646 ResourceProvider::debugNotifyEnterZone(0x3000000); |
647 m_currentTextureUpdateControllerOnImplThread->finalize(); | 647 m_currentResourceUpdateControllerOnImplThread->finalize(); |
648 ResourceProvider::debugNotifyLeaveZone(); | 648 ResourceProvider::debugNotifyLeaveZone(); |
649 m_currentTextureUpdateControllerOnImplThread.reset(); | 649 m_currentResourceUpdateControllerOnImplThread.reset(); |
650 | 650 |
651 // If there are linked evicted backings, these backings' resources may be pu
t into the | 651 // If there are linked evicted backings, these backings' resources may be pu
t into the |
652 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. | 652 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. |
653 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); | 653 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); |
654 | 654 |
655 m_layerTreeHostImpl->beginCommit(); | 655 m_layerTreeHostImpl->beginCommit(); |
656 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); | 656 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); |
657 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); | 657 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); |
658 | 658 |
659 if (newImplTreeHasNoEvictedResources) { | 659 if (newImplTreeHasNoEvictedResources) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 return scheduledActionDrawAndSwapInternal(false); | 783 return scheduledActionDrawAndSwapInternal(false); |
784 } | 784 } |
785 | 785 |
786 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapForced() | 786 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapForced() |
787 { | 787 { |
788 return scheduledActionDrawAndSwapInternal(true); | 788 return scheduledActionDrawAndSwapInternal(true); |
789 } | 789 } |
790 | 790 |
791 void ThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) | 791 void ThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) |
792 { | 792 { |
793 if (!m_currentTextureUpdateControllerOnImplThread) | 793 if (!m_currentResourceUpdateControllerOnImplThread) |
794 return; | 794 return; |
795 | 795 |
796 ResourceProvider::debugNotifyEnterZone(0x5000000); | 796 ResourceProvider::debugNotifyEnterZone(0x5000000); |
797 m_currentTextureUpdateControllerOnImplThread->performMoreUpdates(time); | 797 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates(time); |
798 ResourceProvider::debugNotifyLeaveZone(); | 798 ResourceProvider::debugNotifyLeaveZone(); |
799 } | 799 } |
800 | 800 |
801 void ThreadProxy::readyToFinalizeTextureUpdates() | 801 void ThreadProxy::readyToFinalizeTextureUpdates() |
802 { | 802 { |
803 DCHECK(isImplThread()); | 803 DCHECK(isImplThread()); |
804 m_schedulerOnImplThread->beginFrameComplete(); | 804 m_schedulerOnImplThread->beginFrameComplete(); |
805 } | 805 } |
806 | 806 |
807 void ThreadProxy::didCommitAndDrawFrame() | 807 void ThreadProxy::didCommitAndDrawFrame() |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 } | 928 } |
929 | 929 |
930 void ThreadProxy::setFullRootLayerDamageOnImplThread() | 930 void ThreadProxy::setFullRootLayerDamageOnImplThread() |
931 { | 931 { |
932 DCHECK(isImplThread()); | 932 DCHECK(isImplThread()); |
933 m_layerTreeHostImpl->setFullRootLayerDamage(); | 933 m_layerTreeHostImpl->setFullRootLayerDamage(); |
934 } | 934 } |
935 | 935 |
936 size_t ThreadProxy::maxPartialTextureUpdates() const | 936 size_t ThreadProxy::maxPartialTextureUpdates() const |
937 { | 937 { |
938 return TextureUpdateController::maxPartialTextureUpdates(); | 938 return ResourceUpdateController::maxPartialTextureUpdates(); |
939 } | 939 } |
940 | 940 |
941 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, Graph
icsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* capabilit
ies) | 941 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, Graph
icsContext* contextPtr, bool* recreateSucceeded, RendererCapabilities* capabilit
ies) |
942 { | 942 { |
943 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); | 943 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); |
944 DCHECK(isImplThread()); | 944 DCHECK(isImplThread()); |
945 ResourceProvider::debugNotifyEnterZone(0x7000000); | 945 ResourceProvider::debugNotifyEnterZone(0x7000000); |
946 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 946 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
947 ResourceProvider::debugNotifyLeaveZone(); | 947 ResourceProvider::debugNotifyLeaveZone(); |
948 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<Grap
hicsContext>(contextPtr).Pass()); | 948 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(scoped_ptr<Grap
hicsContext>(contextPtr).Pass()); |
(...skipping 14 matching lines...) Expand all Loading... |
963 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 963 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
964 : monotonicFrameBeginTime(0) | 964 : monotonicFrameBeginTime(0) |
965 { | 965 { |
966 } | 966 } |
967 | 967 |
968 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 968 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
969 { | 969 { |
970 } | 970 } |
971 | 971 |
972 } // namespace cc | 972 } // namespace cc |
OLD | NEW |