Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: cc/thread_proxy.cc

Issue 11710004: cc: Block the main thread for texture layers during impl-side painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 , m_started(false) 43 , m_started(false)
44 , m_texturesAcquired(true) 44 , m_texturesAcquired(true)
45 , m_inCompositeAndReadback(false) 45 , m_inCompositeAndReadback(false)
46 , m_manageTilesPending(false) 46 , m_manageTilesPending(false)
47 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this)) 47 , m_weakFactoryOnImplThread(ALLOW_THIS_IN_INITIALIZER_LIST(this))
48 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread())) 48 , m_mainThreadProxy(ScopedThreadProxy::create(Proxy::mainThread()))
49 , m_beginFrameCompletionEventOnImplThread(0) 49 , m_beginFrameCompletionEventOnImplThread(0)
50 , m_readbackRequestOnImplThread(0) 50 , m_readbackRequestOnImplThread(0)
51 , m_commitCompletionEventOnImplThread(0) 51 , m_commitCompletionEventOnImplThread(0)
52 , m_textureAcquisitionCompletionEventOnImplThread(0) 52 , m_textureAcquisitionCompletionEventOnImplThread(0)
53 , m_pendingTreeActivationEventOnImplThread(0)
53 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false) 54 , m_nextFrameIsNewlyCommittedFrameOnImplThread(false)
54 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled) 55 , m_renderVSyncEnabled(layerTreeHost->settings().renderVSyncEnabled)
55 , m_totalCommitCount(0) 56 , m_totalCommitCount(0)
56 , m_deferCommits(false) 57 , m_deferCommits(false)
57 { 58 {
58 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); 59 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
59 DCHECK(isMainThread()); 60 DCHECK(isMainThread());
60 } 61 }
61 62
62 ThreadProxy::~ThreadProxy() 63 ThreadProxy::~ThreadProxy()
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet eOnImplThread, m_implThreadWeakPtr, &completion, queue.release())); 637 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::beginFrameComplet eOnImplThread, m_implThreadWeakPtr, &completion, queue.release()));
637 completion.wait(); 638 completion.wait();
638 base::TimeTicks endTime = base::TimeTicks::HighResNow(); 639 base::TimeTicks endTime = base::TimeTicks::HighResNow();
639 640
640 m_totalCommitTime += endTime - startTime; 641 m_totalCommitTime += endTime - startTime;
641 m_totalCommitCount++; 642 m_totalCommitCount++;
642 } 643 }
643 644
644 m_layerTreeHost->commitComplete(); 645 m_layerTreeHost->commitComplete();
645 m_layerTreeHost->didBeginFrame(); 646 m_layerTreeHost->didBeginFrame();
647
648 if (m_layerTreeHost->settings().implSidePainting)
649 blockUntilPendingActivationIfNeeded();
646 } 650 }
647 651
648 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re sourceUpdateQueue* rawQueue) 652 void ThreadProxy::beginFrameCompleteOnImplThread(CompletionEvent* completion, Re sourceUpdateQueue* rawQueue)
649 { 653 {
650 scoped_ptr<ResourceUpdateQueue> queue(rawQueue); 654 scoped_ptr<ResourceUpdateQueue> queue(rawQueue);
651 655
652 TRACE_EVENT0("cc", "ThreadProxy::beginFrameCompleteOnImplThread"); 656 TRACE_EVENT0("cc", "ThreadProxy::beginFrameCompleteOnImplThread");
653 DCHECK(!m_commitCompletionEventOnImplThread); 657 DCHECK(!m_commitCompletionEventOnImplThread);
654 DCHECK(isImplThread() && isMainThreadBlocked()); 658 DCHECK(isImplThread() && isMainThreadBlocked());
655 DCHECK(m_schedulerOnImplThread); 659 DCHECK(m_schedulerOnImplThread);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 714
711 if (newImplTreeHasNoEvictedResources) { 715 if (newImplTreeHasNoEvictedResources) {
712 if (m_layerTreeHostImpl->contentsTexturesPurged()) 716 if (m_layerTreeHostImpl->contentsTexturesPurged())
713 m_layerTreeHostImpl->resetContentsTexturesPurged(); 717 m_layerTreeHostImpl->resetContentsTexturesPurged();
714 } 718 }
715 719
716 m_layerTreeHostImpl->commitComplete(); 720 m_layerTreeHostImpl->commitComplete();
717 721
718 m_nextFrameIsNewlyCommittedFrameOnImplThread = true; 722 m_nextFrameIsNewlyCommittedFrameOnImplThread = true;
719 723
720 m_commitCompletionEventOnImplThread->signal(); 724 m_commitCompletionEventOnImplThread->signal();
nduca 2013/01/05 04:56:22 how about making not signaling this in impl side p
enne (OOO) 2013/01/05 06:25:45 You mean conditionally not signaling this here bas
721 m_commitCompletionEventOnImplThread = 0; 725 m_commitCompletionEventOnImplThread = 0;
722 726
723 // SetVisible kicks off the next scheduler action, so this must be last. 727 // SetVisible kicks off the next scheduler action, so this must be last.
724 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible()); 728 m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
725 } 729 }
726 730
727 void ThreadProxy::scheduledActionBeginContextRecreation() 731 void ThreadProxy::scheduledActionBeginContextRecreation()
728 { 732 {
729 DCHECK(isImplThread()); 733 DCHECK(isImplThread());
730 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginContext Recreation, base::Unretained(this))); 734 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadProxy::beginContext Recreation, base::Unretained(this)));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // prepareToDraw(), it is guarded on canDraw() as well. 767 // prepareToDraw(), it is guarded on canDraw() as well.
764 768
765 LayerTreeHostImpl::FrameData frame; 769 LayerTreeHostImpl::FrameData frame;
766 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre pareToDraw(frame) || forcedDraw); 770 bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->pre pareToDraw(frame) || forcedDraw);
767 if (drawFrame) { 771 if (drawFrame) {
768 m_layerTreeHostImpl->drawLayers(frame); 772 m_layerTreeHostImpl->drawLayers(frame);
769 result.didDraw = true; 773 result.didDraw = true;
770 } 774 }
771 m_layerTreeHostImpl->didDrawAllLayers(frame); 775 m_layerTreeHostImpl->didDrawAllLayers(frame);
772 776
777 // Check for tree activation
778 if (m_pendingTreeActivationEventOnImplThread && !m_layerTreeHostImpl->pendin gTree())
779 {
780 DCHECK(m_layerTreeHostImpl->settings().implSidePainting);
781 m_pendingTreeActivationEventOnImplThread->signal();
782 m_pendingTreeActivationEventOnImplThread = 0;
783 }
784
773 // Check for a pending compositeAndReadback. 785 // Check for a pending compositeAndReadback.
774 if (m_readbackRequestOnImplThread) { 786 if (m_readbackRequestOnImplThread) {
775 m_readbackRequestOnImplThread->success = false; 787 m_readbackRequestOnImplThread->success = false;
776 if (drawFrame) { 788 if (drawFrame) {
777 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect); 789 m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect);
778 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon textLost(); 790 m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isCon textLost();
779 } 791 }
780 m_readbackRequestOnImplThread->completion.signal(); 792 m_readbackRequestOnImplThread->completion.signal();
781 m_readbackRequestOnImplThread = 0; 793 m_readbackRequestOnImplThread = 0;
782 } else if (drawFrame) 794 } else if (drawFrame)
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 return commitPendingRequest.commitPending; 1017 return commitPendingRequest.commitPending;
1006 } 1018 }
1007 1019
1008 void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ est) 1020 void ThreadProxy::commitPendingOnImplThreadForTesting(CommitPendingRequest* requ est)
1009 { 1021 {
1010 DCHECK(isImplThread()); 1022 DCHECK(isImplThread());
1011 request->commitPending = m_schedulerOnImplThread->commitPending(); 1023 request->commitPending = m_schedulerOnImplThread->commitPending();
1012 request->completion.signal(); 1024 request->completion.signal();
1013 } 1025 }
1014 1026
1027 void ThreadProxy::blockUntilPendingActivationIfNeeded()
1028 {
1029 DCHECK(isMainThread());
1030 DCHECK(m_layerTreeHost->settings().implSidePainting);
1031
1032 if (!m_layerTreeHost->blocksPendingCommit())
1033 return;
1034
1035 TRACE_EVENT0("cc", "ThreadProxy::blockUntilPendingActivationIfNeeded");
1036 DebugScopedSetMainThreadBlocked mainThreadBlocked(this);
1037 CompletionEvent completion;
1038 Proxy::implThread()->postTask(base::Bind(&ThreadProxy::blockUntilPendingActi vationOnImplThread, m_implThreadWeakPtr, &completion));
1039 completion.wait();
1040 }
1041
1042 void ThreadProxy::blockUntilPendingActivationOnImplThread(CompletionEvent* compl etion)
1043 {
1044 DCHECK(isImplThread());
1045 DCHECK(isMainThreadBlocked());
1046 DCHECK(m_layerTreeHostImpl->settings().implSidePainting);
1047 CHECK(!m_pendingTreeActivationEventOnImplThread);
1048
1049 if (!m_layerTreeHostImpl->pendingTree()) {
1050 completion->signal();
1051 return;
1052 }
1053
1054 m_pendingTreeActivationEventOnImplThread = completion;
1055 }
1056
1015 } // namespace cc 1057 } // namespace cc
OLDNEW
« no previous file with comments | « cc/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698