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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 commit_count_++; | 2499 commit_count_++; |
2500 if (commit_count_ == 4) { | 2500 if (commit_count_ == 4) { |
2501 // After two aborted commits, request a real commit now to make sure a | 2501 // After two aborted commits, request a real commit now to make sure a |
2502 // real commit following an aborted commit will still complete and | 2502 // real commit following an aborted commit will still complete and |
2503 // end the test even when the Impl thread is idle. | 2503 // end the test even when the Impl thread is idle. |
2504 layer_tree_host()->SetNeedsCommit(); | 2504 layer_tree_host()->SetNeedsCommit(); |
2505 } | 2505 } |
2506 } | 2506 } |
2507 | 2507 |
2508 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | 2508 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
2509 bool did_handle) override { | 2509 CommitEarlyOutReason reason) override { |
2510 commit_abort_count_++; | 2510 commit_abort_count_++; |
2511 // Initiate another abortable commit. | 2511 // Initiate another abortable commit. |
2512 host_impl->SetNeedsCommit(); | 2512 host_impl->SetNeedsCommit(); |
2513 } | 2513 } |
2514 | 2514 |
2515 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 2515 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
2516 commit_complete_count_++; | 2516 commit_complete_count_++; |
2517 if (commit_complete_count_ == 1) { | 2517 if (commit_complete_count_ == 1) { |
2518 // Initiate an abortable commit after the first commit. | 2518 // Initiate an abortable commit after the first commit. |
2519 host_impl->SetNeedsCommit(); | 2519 host_impl->SetNeedsCommit(); |
(...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4779 | 4779 |
4780 void DidDeferCommit() override { | 4780 void DidDeferCommit() override { |
4781 layer_tree_host()->SetVisible(false); | 4781 layer_tree_host()->SetVisible(false); |
4782 scoped_ptr<SwapPromise> swap_promise( | 4782 scoped_ptr<SwapPromise> swap_promise( |
4783 new TestSwapPromise(&swap_promise_result_)); | 4783 new TestSwapPromise(&swap_promise_result_)); |
4784 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); | 4784 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); |
4785 layer_tree_host()->SetDeferCommits(false); | 4785 layer_tree_host()->SetDeferCommits(false); |
4786 } | 4786 } |
4787 | 4787 |
4788 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | 4788 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
4789 bool did_handle) override { | 4789 CommitEarlyOutReason reason) override { |
4790 EndTest(); | 4790 EndTest(); |
4791 } | 4791 } |
4792 | 4792 |
4793 void AfterTest() override { | 4793 void AfterTest() override { |
4794 { | 4794 { |
4795 base::AutoLock lock(swap_promise_result_.lock); | 4795 base::AutoLock lock(swap_promise_result_.lock); |
4796 EXPECT_FALSE(swap_promise_result_.did_swap_called); | 4796 EXPECT_FALSE(swap_promise_result_.did_swap_called); |
4797 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); | 4797 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); |
4798 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); | 4798 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); |
4799 EXPECT_TRUE(swap_promise_result_.dtor_called); | 4799 EXPECT_TRUE(swap_promise_result_.dtor_called); |
(...skipping 20 matching lines...) Expand all Loading... |
4820 | 4820 |
4821 void DidDeferCommit() override { | 4821 void DidDeferCommit() override { |
4822 layer_tree_host()->DidLoseOutputSurface(); | 4822 layer_tree_host()->DidLoseOutputSurface(); |
4823 scoped_ptr<SwapPromise> swap_promise( | 4823 scoped_ptr<SwapPromise> swap_promise( |
4824 new TestSwapPromise(&swap_promise_result_)); | 4824 new TestSwapPromise(&swap_promise_result_)); |
4825 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); | 4825 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); |
4826 layer_tree_host()->SetDeferCommits(false); | 4826 layer_tree_host()->SetDeferCommits(false); |
4827 } | 4827 } |
4828 | 4828 |
4829 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | 4829 void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
4830 bool did_handle) override { | 4830 CommitEarlyOutReason reason) override { |
4831 // This is needed so that the impl-thread state matches main-thread state. | 4831 // This is needed so that the impl-thread state matches main-thread state. |
4832 host_impl->DidLoseOutputSurface(); | 4832 host_impl->DidLoseOutputSurface(); |
4833 EndTest(); | 4833 EndTest(); |
4834 } | 4834 } |
4835 | 4835 |
4836 void AfterTest() override { | 4836 void AfterTest() override { |
4837 { | 4837 { |
4838 base::AutoLock lock(swap_promise_result_.lock); | 4838 base::AutoLock lock(swap_promise_result_.lock); |
4839 EXPECT_FALSE(swap_promise_result_.did_swap_called); | 4839 EXPECT_FALSE(swap_promise_result_.did_swap_called); |
4840 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); | 4840 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5951 } | 5951 } |
5952 | 5952 |
5953 protected: | 5953 protected: |
5954 FakeContentLayerClient client_; | 5954 FakeContentLayerClient client_; |
5955 size_t notify_ready_to_activate_count_; | 5955 size_t notify_ready_to_activate_count_; |
5956 size_t scheduled_prepare_tiles_count_; | 5956 size_t scheduled_prepare_tiles_count_; |
5957 }; | 5957 }; |
5958 | 5958 |
5959 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); | 5959 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerPrepareTiles); |
5960 | 5960 |
| 5961 // This tests an assertion that DidCommit and WillCommit happen in the same |
| 5962 // stack frame with no tasks that run between them. Various embedders of |
| 5963 // cc depend on this logic. ui::Compositor holds a compositor lock between |
| 5964 // these events and the inspector timeline wants begin/end CompositeLayers |
| 5965 // to be properly nested with other begin/end events. |
| 5966 class LayerTreeHostTestNoTasksBetweenWillAndDidCommit |
| 5967 : public LayerTreeHostTest { |
| 5968 public: |
| 5969 LayerTreeHostTestNoTasksBetweenWillAndDidCommit() : did_commit_(false) {} |
| 5970 |
| 5971 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 5972 |
| 5973 void WillCommit() override { |
| 5974 MainThreadTaskRunner()->PostTask( |
| 5975 FROM_HERE, base::Bind(&LayerTreeHostTestNoTasksBetweenWillAndDidCommit:: |
| 5976 EndTestShouldRunAfterDidCommit, |
| 5977 base::Unretained(this))); |
| 5978 } |
| 5979 |
| 5980 void EndTestShouldRunAfterDidCommit() { |
| 5981 EXPECT_TRUE(did_commit_); |
| 5982 EndTest(); |
| 5983 } |
| 5984 |
| 5985 void DidCommit() override { |
| 5986 EXPECT_FALSE(did_commit_); |
| 5987 did_commit_ = true; |
| 5988 } |
| 5989 |
| 5990 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
| 5991 |
| 5992 private: |
| 5993 bool did_commit_; |
| 5994 }; |
| 5995 |
| 5996 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
| 5997 |
5961 } // namespace cc | 5998 } // namespace cc |
OLD | NEW |