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

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: Created 6 years, 1 month 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
« cc/trees/single_thread_proxy.cc ('K') | « 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 DCHECK(IsMainThread()); 430 DCHECK(IsMainThread());
431 if (main().defer_commits == defer_commits) 431 if (main().defer_commits == defer_commits)
432 return; 432 return;
433 433
434 main().defer_commits = defer_commits; 434 main().defer_commits = defer_commits;
435 if (main().defer_commits) 435 if (main().defer_commits)
436 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 436 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
437 else 437 else
438 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 438 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
439 439
440 if (!main().defer_commits && main().pending_deferred_commit) { 440 Proxy::ImplThreadTaskRunner()->PostTask(
441 Proxy::MainThreadTaskRunner()->PostTask( 441 FROM_HERE,
442 FROM_HERE, 442 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread,
443 base::Bind(&ThreadProxy::BeginMainFrame, 443 impl_thread_weak_ptr_,
444 main_thread_weak_ptr_, 444 defer_commits));
445 base::Passed(&main().pending_deferred_commit))); 445 }
446 } 446
447 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const {
448 DCHECK(IsImplThread());
449 impl().scheduler->SetDeferCommits(defer_commits);
447 } 450 }
448 451
449 bool ThreadProxy::CommitRequested() const { 452 bool ThreadProxy::CommitRequested() const {
450 DCHECK(IsMainThread()); 453 DCHECK(IsMainThread());
451 return main().commit_requested; 454 return main().commit_requested;
452 } 455 }
453 456
454 bool ThreadProxy::BeginMainFrameRequested() const { 457 bool ThreadProxy::BeginMainFrameRequested() const {
455 DCHECK(IsMainThread()); 458 DCHECK(IsMainThread());
456 return main().commit_request_sent_to_impl_thread; 459 return main().commit_request_sent_to_impl_thread;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 } 698 }
696 699
697 void ThreadProxy::BeginMainFrame( 700 void ThreadProxy::BeginMainFrame(
698 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 701 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
699 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( 702 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task(
700 benchmark_instrumentation::kDoBeginFrame, 703 benchmark_instrumentation::kDoBeginFrame,
701 begin_main_frame_state->begin_frame_id); 704 begin_main_frame_state->begin_frame_id);
702 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); 705 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame");
703 DCHECK(IsMainThread()); 706 DCHECK(IsMainThread());
704 707
705 if (main().defer_commits) {
706 main().pending_deferred_commit = begin_main_frame_state.Pass();
707 layer_tree_host()->DidDeferCommit();
708 TRACE_EVENT_INSTANT0(
709 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD);
710 return;
711 }
712
713 // If the commit finishes, LayerTreeHost will transfer its swap promises to 708 // If the commit finishes, LayerTreeHost will transfer its swap promises to
714 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the 709 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the
715 // remaining swap promises. 710 // remaining swap promises.
716 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); 711 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host());
danakj 2014/11/19 16:31:34 This patch reorders the deferred commit early out
brianderson 2014/11/19 19:55:07 We should keep the original behavior and not fulfi
simonhong 2014/11/26 15:52:53 As brian said, Aborting the BeginMainFrame when de
717 712
718 main().commit_requested = false; 713 main().commit_requested = false;
719 main().commit_request_sent_to_impl_thread = false; 714 main().commit_request_sent_to_impl_thread = false;
720 main().animate_requested = false; 715 main().animate_requested = false;
721 716
722 if (!layer_tree_host()->visible()) { 717 bool need_to_abort_begin_main_frame = true;
718 if (main().defer_commits) {
719 layer_tree_host()->DidDeferCommit();
720 TRACE_EVENT_INSTANT0("cc",
721 "EarlyOut_DeferCommits",
722 TRACE_EVENT_SCOPE_THREAD);
brianderson 2014/11/19 19:55:07 If we abort a commit because we are deferring comm
simonhong 2014/11/26 15:52:53 SetNeedsCommit() is added when SetDeferCommits(fal
723 } else if (!layer_tree_host()->visible()) {
723 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 724 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
725 } else if (layer_tree_host()->output_surface_lost()) {
726 TRACE_EVENT_INSTANT0(
727 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
728 } else {
729 need_to_abort_begin_main_frame = false;
730 }
731
732 if (need_to_abort_begin_main_frame) {
724 bool did_handle = false; 733 bool did_handle = false;
725 Proxy::ImplThreadTaskRunner()->PostTask( 734 Proxy::ImplThreadTaskRunner()->PostTask(
726 FROM_HERE, 735 FROM_HERE,
727 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
728 impl_thread_weak_ptr_,
729 did_handle));
730 return;
731 }
732
733 if (layer_tree_host()->output_surface_lost()) {
734 TRACE_EVENT_INSTANT0(
735 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
736 bool did_handle = false;
737 Proxy::ImplThreadTaskRunner()->PostTask(
738 FROM_HERE,
739 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 736 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
740 impl_thread_weak_ptr_, 737 impl_thread_weak_ptr_,
741 did_handle)); 738 did_handle));
742 return; 739 return;
743 } 740 }
744 741
745 // Do not notify the impl thread of commit requests that occur during 742 // Do not notify the impl thread of commit requests that occur during
746 // the apply/animate/layout part of the BeginMainFrameAndCommit process since 743 // the apply/animate/layout part of the BeginMainFrameAndCommit process since
747 // those commit requests will get painted immediately. Once we have done 744 // those commit requests will get painted immediately. Once we have done
748 // the paint, main().commit_requested will be set to false to allow new commit 745 // the paint, main().commit_requested will be set to false to allow new commit
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1360
1364 impl().timing_history.DidActivateSyncTree(); 1361 impl().timing_history.DidActivateSyncTree();
1365 } 1362 }
1366 1363
1367 void ThreadProxy::DidManageTiles() { 1364 void ThreadProxy::DidManageTiles() {
1368 DCHECK(IsImplThread()); 1365 DCHECK(IsImplThread());
1369 impl().scheduler->DidManageTiles(); 1366 impl().scheduler->DidManageTiles();
1370 } 1367 }
1371 1368
1372 } // namespace cc 1369 } // namespace cc
OLDNEW
« cc/trees/single_thread_proxy.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698