| 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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 DebugScopedSetImplThread impl(task_runner_provider_); | 464 DebugScopedSetImplThread impl(task_runner_provider_); |
| 465 WillBeginImplFrame(begin_frame_args); | 465 WillBeginImplFrame(begin_frame_args); |
| 466 } | 466 } |
| 467 | 467 |
| 468 // Run the "main thread" and get it to commit. | 468 // Run the "main thread" and get it to commit. |
| 469 { | 469 { |
| 470 #if DCHECK_IS_ON() | 470 #if DCHECK_IS_ON() |
| 471 DCHECK(inside_impl_frame_); | 471 DCHECK(inside_impl_frame_); |
| 472 #endif | 472 #endif |
| 473 DoBeginMainFrame(begin_frame_args); | 473 DoBeginMainFrame(begin_frame_args); |
| 474 DoPainting(); |
| 474 DoCommit(); | 475 DoCommit(); |
| 475 | 476 |
| 476 DCHECK_EQ( | 477 DCHECK_EQ( |
| 477 0u, | 478 0u, |
| 478 layer_tree_host_->GetSwapPromiseManager()->num_queued_swap_promises()) | 479 layer_tree_host_->GetSwapPromiseManager()->num_queued_swap_promises()) |
| 479 << "Commit should always succeed and transfer promises."; | 480 << "Commit should always succeed and transfer promises."; |
| 480 } | 481 } |
| 481 | 482 |
| 482 // Finish the impl frame. | 483 // Finish the impl frame. |
| 483 { | 484 { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); | 652 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); |
| 652 return; | 653 return; |
| 653 } | 654 } |
| 654 | 655 |
| 655 // Prevent new commits from being requested inside DoBeginMainFrame. | 656 // Prevent new commits from being requested inside DoBeginMainFrame. |
| 656 // Note: We do not want to prevent SetNeedsAnimate from requesting | 657 // Note: We do not want to prevent SetNeedsAnimate from requesting |
| 657 // a commit here. | 658 // a commit here. |
| 658 commit_requested_ = true; | 659 commit_requested_ = true; |
| 659 | 660 |
| 660 DoBeginMainFrame(begin_frame_args); | 661 DoBeginMainFrame(begin_frame_args); |
| 662 |
| 663 // New commits requested inside UpdateLayers should be respected. |
| 664 commit_requested_ = false; |
| 665 |
| 666 // At this point the main frame may have deferred commits to avoid committing |
| 667 // right now. |
| 668 if (defer_commits_) { |
| 669 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit_InsideBeginMainFrame", |
| 670 TRACE_EVENT_SCOPE_THREAD); |
| 671 BeginMainFrameAbortedOnImplThread( |
| 672 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); |
| 673 layer_tree_host_->DidBeginMainFrame(); |
| 674 return; |
| 675 } |
| 676 |
| 677 DoPainting(); |
| 661 } | 678 } |
| 662 | 679 |
| 663 void SingleThreadProxy::DoBeginMainFrame( | 680 void SingleThreadProxy::DoBeginMainFrame( |
| 664 const BeginFrameArgs& begin_frame_args) { | 681 const BeginFrameArgs& begin_frame_args) { |
| 665 // In the single-threaded case, the scale deltas should never be touched on | 682 // In the single-threaded case, the scale deltas should never be touched on |
| 666 // the impl layer tree. However, impl-side scroll deltas may be manipulated | 683 // the impl layer tree. However, impl-side scroll deltas may be manipulated |
| 667 // directly via the InputHandler on the UI thread. | 684 // directly via the InputHandler on the UI thread. |
| 668 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 685 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 669 layer_tree_host_impl_->ProcessScrollDeltas(); | 686 layer_tree_host_impl_->ProcessScrollDeltas(); |
| 670 DCHECK_EQ(1.f, scroll_info->page_scale_delta); | 687 DCHECK_EQ(1.f, scroll_info->page_scale_delta); |
| 671 layer_tree_host_->ApplyScrollAndScale(scroll_info.get()); | 688 layer_tree_host_->ApplyScrollAndScale(scroll_info.get()); |
| 672 | 689 |
| 673 layer_tree_host_->WillBeginMainFrame(); | 690 layer_tree_host_->WillBeginMainFrame(); |
| 674 layer_tree_host_->BeginMainFrame(begin_frame_args); | 691 layer_tree_host_->BeginMainFrame(begin_frame_args); |
| 675 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); | 692 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); |
| 676 layer_tree_host_->RequestMainFrameUpdate(); | 693 layer_tree_host_->RequestMainFrameUpdate(); |
| 694 } |
| 677 | 695 |
| 678 // New commits requested inside UpdateLayers should be respected. | 696 void SingleThreadProxy::DoPainting() { |
| 679 commit_requested_ = false; | |
| 680 | |
| 681 layer_tree_host_->UpdateLayers(); | 697 layer_tree_host_->UpdateLayers(); |
| 682 | 698 |
| 683 // TODO(enne): SingleThreadProxy does not support cancelling commits yet, | 699 // TODO(enne): SingleThreadProxy does not support cancelling commits yet, |
| 684 // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside | 700 // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside |
| 685 // thread_proxy.cc | 701 // thread_proxy.cc |
| 686 if (scheduler_on_impl_thread_) | 702 if (scheduler_on_impl_thread_) |
| 687 scheduler_on_impl_thread_->NotifyReadyToCommit(); | 703 scheduler_on_impl_thread_->NotifyReadyToCommit(); |
| 688 } | 704 } |
| 689 | 705 |
| 690 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( | 706 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 void SingleThreadProxy::DidFinishImplFrame() { | 788 void SingleThreadProxy::DidFinishImplFrame() { |
| 773 layer_tree_host_impl_->DidFinishImplFrame(); | 789 layer_tree_host_impl_->DidFinishImplFrame(); |
| 774 #if DCHECK_IS_ON() | 790 #if DCHECK_IS_ON() |
| 775 DCHECK(inside_impl_frame_) | 791 DCHECK(inside_impl_frame_) |
| 776 << "DidFinishImplFrame called while not inside an impl frame!"; | 792 << "DidFinishImplFrame called while not inside an impl frame!"; |
| 777 inside_impl_frame_ = false; | 793 inside_impl_frame_ = false; |
| 778 #endif | 794 #endif |
| 779 } | 795 } |
| 780 | 796 |
| 781 } // namespace cc | 797 } // namespace cc |
| OLD | NEW |