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 "cc/thread_proxy.h" | 5 #include "cc/thread_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/delay_based_time_source.h" | 9 #include "cc/delay_based_time_source.h" |
10 #include "cc/draw_quad.h" | 10 #include "cc/draw_quad.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::setAnimation
Events, base::Unretained(this), base::Passed(events.Pass()), wallClockTime)); | 349 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::setAnimation
Events, base::Unretained(this), base::Passed(events.Pass()), wallClockTime)); |
350 } | 350 } |
351 | 351 |
352 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) | 352 bool ThreadProxy::reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) |
353 { | 353 { |
354 DCHECK(isImplThread()); | 354 DCHECK(isImplThread()); |
355 | 355 |
356 if (!m_layerTreeHost->contentsTextureManager()) | 356 if (!m_layerTreeHost->contentsTextureManager()) |
357 return false; | 357 return false; |
358 | 358 |
359 ResourceProvider::debugNotifyEnterZone(0x1000000); | |
360 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())
; |
361 ResourceProvider::debugNotifyLeaveZone(); | |
362 if (!reduceResult) | 360 if (!reduceResult) |
363 return false; | 361 return false; |
364 | 362 |
365 // The texture upload queue may reference textures that were just purged, cl
ear | 363 // The texture upload queue may reference textures that were just purged, cl
ear |
366 // them from the queue. | 364 // them from the queue. |
367 if (m_currentResourceUpdateControllerOnImplThread.get()) | 365 if (m_currentResourceUpdateControllerOnImplThread.get()) |
368 m_currentResourceUpdateControllerOnImplThread->discardUploadsToEvictedRe
sources(); | 366 m_currentResourceUpdateControllerOnImplThread->discardUploadsToEvictedRe
sources(); |
369 return true; | 367 return true; |
370 } | 368 } |
371 | 369 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 // resources | 649 // resources |
652 queue->clearUploadsToEvictedResources(); | 650 queue->clearUploadsToEvictedResources(); |
653 // Some textures in the layer tree are invalid. Kick off another commit | 651 // Some textures in the layer tree are invalid. Kick off another commit |
654 // to fill them again. | 652 // to fill them again. |
655 setNeedsCommitOnImplThread(); | 653 setNeedsCommitOnImplThread(); |
656 } | 654 } |
657 | 655 |
658 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; | 656 m_layerTreeHost->contentsTextureManager()->pushTexturePrioritiesToBackings()
; |
659 | 657 |
660 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::cr
eate(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvi
der(), hasImplThread()); | 658 m_currentResourceUpdateControllerOnImplThread = ResourceUpdateController::cr
eate(this, Proxy::implThread(), queue.Pass(), m_layerTreeHostImpl->resourceProvi
der(), hasImplThread()); |
661 ResourceProvider::debugNotifyEnterZone(0x2000000); | |
662 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates( | 659 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates( |
663 m_schedulerOnImplThread->anticipatedDrawTime()); | 660 m_schedulerOnImplThread->anticipatedDrawTime()); |
664 ResourceProvider::debugNotifyLeaveZone(); | |
665 | 661 |
666 m_commitCompletionEventOnImplThread = completion; | 662 m_commitCompletionEventOnImplThread = completion; |
667 } | 663 } |
668 | 664 |
669 void ThreadProxy::beginFrameAbortedOnImplThread() | 665 void ThreadProxy::beginFrameAbortedOnImplThread() |
670 { | 666 { |
671 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); | 667 TRACE_EVENT0("cc", "ThreadProxy::beginFrameAbortedOnImplThread"); |
672 DCHECK(isImplThread()); | 668 DCHECK(isImplThread()); |
673 DCHECK(m_schedulerOnImplThread); | 669 DCHECK(m_schedulerOnImplThread); |
674 DCHECK(m_schedulerOnImplThread->commitPending()); | 670 DCHECK(m_schedulerOnImplThread->commitPending()); |
675 | 671 |
676 m_schedulerOnImplThread->beginFrameAborted(); | 672 m_schedulerOnImplThread->beginFrameAborted(); |
677 } | 673 } |
678 | 674 |
679 void ThreadProxy::scheduledActionCommit() | 675 void ThreadProxy::scheduledActionCommit() |
680 { | 676 { |
681 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit"); | 677 TRACE_EVENT0("cc", "ThreadProxy::scheduledActionCommit"); |
682 DCHECK(isImplThread()); | 678 DCHECK(isImplThread()); |
683 DCHECK(m_commitCompletionEventOnImplThread); | 679 DCHECK(m_commitCompletionEventOnImplThread); |
684 DCHECK(m_currentResourceUpdateControllerOnImplThread); | 680 DCHECK(m_currentResourceUpdateControllerOnImplThread); |
685 | 681 |
686 // Complete all remaining texture updates. | 682 // Complete all remaining texture updates. |
687 ResourceProvider::debugNotifyEnterZone(0x3000000); | |
688 m_currentResourceUpdateControllerOnImplThread->finalize(); | 683 m_currentResourceUpdateControllerOnImplThread->finalize(); |
689 ResourceProvider::debugNotifyLeaveZone(); | |
690 m_currentResourceUpdateControllerOnImplThread.reset(); | 684 m_currentResourceUpdateControllerOnImplThread.reset(); |
691 | 685 |
692 // If there are linked evicted backings, these backings' resources may be pu
t into the | 686 // If there are linked evicted backings, these backings' resources may be pu
t into the |
693 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. | 687 // impl tree, so we can't draw yet. Determine this before clearing all evict
ed backings. |
694 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); | 688 bool newImplTreeHasNoEvictedResources = !m_layerTreeHost->contentsTextureMan
ager()->linkedEvictedBackingsExist(); |
695 | 689 |
696 m_layerTreeHostImpl->beginCommit(); | 690 m_layerTreeHostImpl->beginCommit(); |
697 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); | 691 m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get()); |
698 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); | 692 m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get()); |
699 | 693 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 // This method is called on a forced draw, regardless of whether we are able
to produce a frame, | 739 // This method is called on a forced draw, regardless of whether we are able
to produce a frame, |
746 // as the calling site on main thread is blocked until its request completes
, and we signal | 740 // as the calling site on main thread is blocked until its request completes
, and we signal |
747 // completion here. If canDraw() is false, we will indicate success=false to
the caller, but we | 741 // completion here. If canDraw() is false, we will indicate success=false to
the caller, but we |
748 // must still signal completion to avoid deadlock. | 742 // must still signal completion to avoid deadlock. |
749 | 743 |
750 // We guard prepareToDraw() with canDraw() because it always returns a valid
frame, so can only | 744 // We guard prepareToDraw() with canDraw() because it always returns a valid
frame, so can only |
751 // be used when such a frame is possible. Since drawLayers() depends on the
result of | 745 // be used when such a frame is possible. Since drawLayers() depends on the
result of |
752 // prepareToDraw(), it is guarded on canDraw() as well. | 746 // prepareToDraw(), it is guarded on canDraw() as well. |
753 | 747 |
754 LayerTreeHostImpl::FrameData frame; | 748 LayerTreeHostImpl::FrameData frame; |
755 ResourceProvider::debugNotifyEnterZone(0x4000000); | |
756 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre
pareToDraw(frame) || forcedDraw); | 749 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre
pareToDraw(frame) || forcedDraw); |
757 ResourceProvider::debugNotifyLeaveZone(); | |
758 if (drawFrame) { | 750 if (drawFrame) { |
759 m_layerTreeHostImpl->drawLayers(frame); | 751 m_layerTreeHostImpl->drawLayers(frame); |
760 result.didDraw = true; | 752 result.didDraw = true; |
761 } | 753 } |
762 m_layerTreeHostImpl->didDrawAllLayers(frame); | 754 m_layerTreeHostImpl->didDrawAllLayers(frame); |
763 | 755 |
764 // Check for a pending compositeAndReadback. | 756 // Check for a pending compositeAndReadback. |
765 if (m_readbackRequestOnImplThread) { | 757 if (m_readbackRequestOnImplThread) { |
766 m_readbackRequestOnImplThread->success = false; | 758 m_readbackRequestOnImplThread->success = false; |
767 if (drawFrame) { | 759 if (drawFrame) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapForced() | 819 ScheduledActionDrawAndSwapResult ThreadProxy::scheduledActionDrawAndSwapForced() |
828 { | 820 { |
829 return scheduledActionDrawAndSwapInternal(true); | 821 return scheduledActionDrawAndSwapInternal(true); |
830 } | 822 } |
831 | 823 |
832 void ThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) | 824 void ThreadProxy::didAnticipatedDrawTimeChange(base::TimeTicks time) |
833 { | 825 { |
834 if (!m_currentResourceUpdateControllerOnImplThread) | 826 if (!m_currentResourceUpdateControllerOnImplThread) |
835 return; | 827 return; |
836 | 828 |
837 ResourceProvider::debugNotifyEnterZone(0x5000000); | |
838 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates(time); | 829 m_currentResourceUpdateControllerOnImplThread->performMoreUpdates(time); |
839 ResourceProvider::debugNotifyLeaveZone(); | |
840 } | 830 } |
841 | 831 |
842 void ThreadProxy::readyToFinalizeTextureUpdates() | 832 void ThreadProxy::readyToFinalizeTextureUpdates() |
843 { | 833 { |
844 DCHECK(isImplThread()); | 834 DCHECK(isImplThread()); |
845 m_schedulerOnImplThread->beginFrameComplete(); | 835 m_schedulerOnImplThread->beginFrameComplete(); |
846 } | 836 } |
847 | 837 |
848 void ThreadProxy::didCommitAndDrawFrame() | 838 void ThreadProxy::didCommitAndDrawFrame() |
849 { | 839 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 capabilities->usingSwapCompleteCallback); | 920 capabilities->usingSwapCompleteCallback); |
931 } | 921 } |
932 | 922 |
933 completion->signal(); | 923 completion->signal(); |
934 } | 924 } |
935 | 925 |
936 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) | 926 void ThreadProxy::layerTreeHostClosedOnImplThread(CompletionEvent* completion) |
937 { | 927 { |
938 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); | 928 TRACE_EVENT0("cc", "ThreadProxy::layerTreeHostClosedOnImplThread"); |
939 DCHECK(isImplThread()); | 929 DCHECK(isImplThread()); |
940 ResourceProvider::debugNotifyEnterZone(0x6000000); | |
941 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 930 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
942 ResourceProvider::debugNotifyLeaveZone(); | |
943 m_inputHandlerOnImplThread.reset(); | 931 m_inputHandlerOnImplThread.reset(); |
944 m_layerTreeHostImpl.reset(); | 932 m_layerTreeHostImpl.reset(); |
945 m_schedulerOnImplThread.reset(); | 933 m_schedulerOnImplThread.reset(); |
946 completion->signal(); | 934 completion->signal(); |
947 } | 935 } |
948 | 936 |
949 void ThreadProxy::setFullRootLayerDamageOnImplThread() | 937 void ThreadProxy::setFullRootLayerDamageOnImplThread() |
950 { | 938 { |
951 DCHECK(isImplThread()); | 939 DCHECK(isImplThread()); |
952 m_layerTreeHostImpl->setFullRootLayerDamage(); | 940 m_layerTreeHostImpl->setFullRootLayerDamage(); |
953 } | 941 } |
954 | 942 |
955 size_t ThreadProxy::maxPartialTextureUpdates() const | 943 size_t ThreadProxy::maxPartialTextureUpdates() const |
956 { | 944 { |
957 return ResourceUpdateController::maxPartialTextureUpdates(); | 945 return ResourceUpdateController::maxPartialTextureUpdates(); |
958 } | 946 } |
959 | 947 |
960 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, scope
d_ptr<GraphicsContext> context, bool* recreateSucceeded, RendererCapabilities* c
apabilities) | 948 void ThreadProxy::recreateContextOnImplThread(CompletionEvent* completion, scope
d_ptr<GraphicsContext> context, bool* recreateSucceeded, RendererCapabilities* c
apabilities) |
961 { | 949 { |
962 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); | 950 TRACE_EVENT0("cc", "ThreadProxy::recreateContextOnImplThread"); |
963 DCHECK(isImplThread()); | 951 DCHECK(isImplThread()); |
964 ResourceProvider::debugNotifyEnterZone(0x7000000); | |
965 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); | 952 m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->res
ourceProvider()); |
966 ResourceProvider::debugNotifyLeaveZone(); | |
967 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(context.Pass())
; | 953 *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(context.Pass())
; |
968 if (*recreateSucceeded) { | 954 if (*recreateSucceeded) { |
969 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); | 955 *capabilities = m_layerTreeHostImpl->rendererCapabilities(); |
970 m_schedulerOnImplThread->didRecreateContext(); | 956 m_schedulerOnImplThread->didRecreateContext(); |
971 } | 957 } |
972 completion->signal(); | 958 completion->signal(); |
973 } | 959 } |
974 | 960 |
975 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) | 961 void ThreadProxy::renderingStatsOnImplThread(CompletionEvent* completion, Render
ingStats* stats) |
976 { | 962 { |
977 DCHECK(isImplThread()); | 963 DCHECK(isImplThread()); |
978 m_layerTreeHostImpl->renderingStats(stats); | 964 m_layerTreeHostImpl->renderingStats(stats); |
979 completion->signal(); | 965 completion->signal(); |
980 } | 966 } |
981 | 967 |
982 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() | 968 ThreadProxy::BeginFrameAndCommitState::BeginFrameAndCommitState() |
983 { | 969 { |
984 } | 970 } |
985 | 971 |
986 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() | 972 ThreadProxy::BeginFrameAndCommitState::~BeginFrameAndCommitState() |
987 { | 973 { |
988 } | 974 } |
989 | 975 |
990 } // namespace cc | 976 } // namespace cc |
OLD | NEW |