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

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 337693005: cc: Control defer_commits logic by Scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP Created 6 years, 6 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/trees/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/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 void ThreadProxy::SetDeferCommits(bool defer_commits) { 474 void ThreadProxy::SetDeferCommits(bool defer_commits) {
475 DCHECK(IsMainThread()); 475 DCHECK(IsMainThread());
476 DCHECK_NE(main().defer_commits, defer_commits); 476 DCHECK_NE(main().defer_commits, defer_commits);
477 main().defer_commits = defer_commits; 477 main().defer_commits = defer_commits;
478 478
479 if (main().defer_commits) 479 if (main().defer_commits)
480 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 480 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
481 else 481 else
482 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 482 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
483 483
484 if (!main().defer_commits && main().pending_deferred_commit) 484 Proxy::ImplThreadTaskRunner()->PostTask(
485 Proxy::MainThreadTaskRunner()->PostTask( 485 FROM_HERE,
486 FROM_HERE, 486 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread,
487 base::Bind(&ThreadProxy::BeginMainFrame, 487 impl_thread_weak_ptr_,
488 main_thread_weak_ptr_, 488 defer_commits));
489 base::Passed(&main().pending_deferred_commit))); 489 }
490
491 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const {
492 DCHECK(IsImplThread());
493 impl().scheduler->SetDeferCommits(defer_commits);
490 } 494 }
491 495
492 bool ThreadProxy::CommitRequested() const { 496 bool ThreadProxy::CommitRequested() const {
493 DCHECK(IsMainThread()); 497 DCHECK(IsMainThread());
494 return main().commit_requested; 498 return main().commit_requested;
495 } 499 }
496 500
497 bool ThreadProxy::BeginMainFrameRequested() const { 501 bool ThreadProxy::BeginMainFrameRequested() const {
498 DCHECK(IsMainThread()); 502 DCHECK(IsMainThread());
499 return main().commit_request_sent_to_impl_thread; 503 return main().commit_request_sent_to_impl_thread;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 impl().layer_tree_host_id); 733 impl().layer_tree_host_id);
730 impl().timing_history.DidBeginMainFrame(); 734 impl().timing_history.DidBeginMainFrame();
731 } 735 }
732 736
733 void ThreadProxy::BeginMainFrame( 737 void ThreadProxy::BeginMainFrame(
734 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 738 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
735 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame"); 739 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame");
736 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); 740 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame");
737 DCHECK(IsMainThread()); 741 DCHECK(IsMainThread());
738 742
739 if (main().defer_commits) {
740 main().pending_deferred_commit = begin_main_frame_state.Pass();
741 layer_tree_host()->DidDeferCommit();
742 TRACE_EVENT_INSTANT0(
743 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD);
744 return;
745 }
746
747 // If the commit finishes, LayerTreeHost will transfer its swap promises to 743 // If the commit finishes, LayerTreeHost will transfer its swap promises to
748 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's 744 // LayerTreeImpl. The destructor of SwapPromiseChecker checks LayerTressHost's
749 // swap promises. 745 // swap promises.
750 SwapPromiseChecker swap_promise_checker(layer_tree_host()); 746 SwapPromiseChecker swap_promise_checker(layer_tree_host());
751 747
752 main().commit_requested = false; 748 main().commit_requested = false;
Sami 2014/06/19 18:26:08 Seems like resetting these flags while deferring t
753 main().commit_request_sent_to_impl_thread = false; 749 main().commit_request_sent_to_impl_thread = false;
754 main().animate_requested = false; 750 main().animate_requested = false;
755 751
756 if (!layer_tree_host()->visible()) { 752 bool need_to_abort_begin_main_frame = true;
753 if (main().defer_commits) {
754 layer_tree_host()->DidDeferCommit();
755 TRACE_EVENT_INSTANT0(
756 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD);
757 } else if (!layer_tree_host()->visible()) {
757 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 758 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
759 } else if (layer_tree_host()->output_surface_lost()) {
760 TRACE_EVENT_INSTANT0(
761 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
762 } else {
763 need_to_abort_begin_main_frame = false;
764 }
765
766 if (need_to_abort_begin_main_frame) {
758 bool did_handle = false; 767 bool did_handle = false;
759 Proxy::ImplThreadTaskRunner()->PostTask( 768 Proxy::ImplThreadTaskRunner()->PostTask(
760 FROM_HERE, 769 FROM_HERE,
761 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
762 impl_thread_weak_ptr_,
763 did_handle));
764 return;
765 }
766
767 if (layer_tree_host()->output_surface_lost()) {
768 TRACE_EVENT_INSTANT0(
769 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
770 bool did_handle = false;
771 Proxy::ImplThreadTaskRunner()->PostTask(
772 FROM_HERE,
773 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 770 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
774 impl_thread_weak_ptr_, 771 impl_thread_weak_ptr_,
775 did_handle)); 772 did_handle));
776 return; 773 return;
777 } 774 }
778 775
779 // Do not notify the impl thread of commit requests that occur during 776 // Do not notify the impl thread of commit requests that occur during
780 // the apply/animate/layout part of the BeginMainFrameAndCommit process since 777 // the apply/animate/layout part of the BeginMainFrameAndCommit process since
781 // those commit requests will get painted immediately. Once we have done 778 // those commit requests will get painted immediately. Once we have done
782 // the paint, main().commit_requested will be set to false to allow new commit 779 // the paint, main().commit_requested will be set to false to allow new commit
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 1452
1456 impl().timing_history.DidActivatePendingTree(); 1453 impl().timing_history.DidActivatePendingTree();
1457 } 1454 }
1458 1455
1459 void ThreadProxy::DidManageTiles() { 1456 void ThreadProxy::DidManageTiles() {
1460 DCHECK(IsImplThread()); 1457 DCHECK(IsImplThread());
1461 impl().scheduler->DidManageTiles(); 1458 impl().scheduler->DidManageTiles();
1462 } 1459 }
1463 1460
1464 } // namespace cc 1461 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698