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/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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 DCHECK(IsMainThread()); | 445 DCHECK(IsMainThread()); |
446 if (main().defer_commits == defer_commits) | 446 if (main().defer_commits == defer_commits) |
447 return; | 447 return; |
448 | 448 |
449 main().defer_commits = defer_commits; | 449 main().defer_commits = defer_commits; |
450 if (main().defer_commits) | 450 if (main().defer_commits) |
451 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); | 451 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); |
452 else | 452 else |
453 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); | 453 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); |
454 | 454 |
455 Proxy::ImplThreadTaskRunner()->PostTask( | 455 if (!main().defer_commits && main().pending_deferred_commit) { |
456 FROM_HERE, | 456 Proxy::MainThreadTaskRunner()->PostTask( |
457 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread, | 457 FROM_HERE, |
458 impl_thread_weak_ptr_, | 458 base::Bind(&ThreadProxy::BeginMainFrame, |
459 defer_commits)); | 459 main_thread_weak_ptr_, |
460 } | 460 base::Passed(&main().pending_deferred_commit))); |
461 | 461 } |
462 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { | |
463 DCHECK(IsImplThread()); | |
464 impl().scheduler->SetDeferCommits(defer_commits); | |
465 } | 462 } |
466 | 463 |
467 bool ThreadProxy::CommitRequested() const { | 464 bool ThreadProxy::CommitRequested() const { |
468 DCHECK(IsMainThread()); | 465 DCHECK(IsMainThread()); |
469 return main().commit_requested; | 466 return main().commit_requested; |
470 } | 467 } |
471 | 468 |
472 bool ThreadProxy::BeginMainFrameRequested() const { | 469 bool ThreadProxy::BeginMainFrameRequested() const { |
473 DCHECK(IsMainThread()); | 470 DCHECK(IsMainThread()); |
474 return main().commit_request_sent_to_impl_thread; | 471 return main().commit_request_sent_to_impl_thread; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 694 |
698 void ThreadProxy::BeginMainFrame( | 695 void ThreadProxy::BeginMainFrame( |
699 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { | 696 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { |
700 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( | 697 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( |
701 benchmark_instrumentation::kDoBeginFrame, | 698 benchmark_instrumentation::kDoBeginFrame, |
702 begin_main_frame_state->begin_frame_id); | 699 begin_main_frame_state->begin_frame_id); |
703 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); | 700 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); |
704 DCHECK(IsMainThread()); | 701 DCHECK(IsMainThread()); |
705 | 702 |
706 if (main().defer_commits) { | 703 if (main().defer_commits) { |
707 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", | 704 main().pending_deferred_commit = begin_main_frame_state.Pass(); |
708 TRACE_EVENT_SCOPE_THREAD); | 705 layer_tree_host()->DidDeferCommit(); |
709 Proxy::ImplThreadTaskRunner()->PostTask( | 706 TRACE_EVENT_INSTANT0( |
710 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 707 "cc", "EarlyOut_DeferCommits", TRACE_EVENT_SCOPE_THREAD); |
711 impl_thread_weak_ptr_, | |
712 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT)); | |
713 return; | 708 return; |
714 } | 709 } |
715 | 710 |
716 // If the commit finishes, LayerTreeHost will transfer its swap promises to | 711 // If the commit finishes, LayerTreeHost will transfer its swap promises to |
717 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the | 712 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the |
718 // remaining swap promises. | 713 // remaining swap promises. |
719 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); | 714 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); |
720 | 715 |
721 main().commit_requested = false; | 716 main().commit_requested = false; |
722 main().commit_request_sent_to_impl_thread = false; | 717 main().commit_request_sent_to_impl_thread = false; |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 } | 1360 } |
1366 | 1361 |
1367 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1362 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
1368 DCHECK(IsImplThread()); | 1363 DCHECK(IsImplThread()); |
1369 Proxy::MainThreadTaskRunner()->PostTask( | 1364 Proxy::MainThreadTaskRunner()->PostTask( |
1370 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | 1365 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, |
1371 main_thread_weak_ptr_)); | 1366 main_thread_weak_ptr_)); |
1372 } | 1367 } |
1373 | 1368 |
1374 } // namespace cc | 1369 } // namespace cc |
OLD | NEW |