Chromium Code Reviews| 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 4466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4477 { | 4477 { |
| 4478 // The first commit completes and causes swap buffer which finishes | 4478 // The first commit completes and causes swap buffer which finishes |
| 4479 // the promise. | 4479 // the promise. |
| 4480 base::AutoLock lock(swap_promise_result_[0].lock); | 4480 base::AutoLock lock(swap_promise_result_[0].lock); |
| 4481 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); | 4481 EXPECT_TRUE(swap_promise_result_[0].did_swap_called); |
| 4482 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); | 4482 EXPECT_FALSE(swap_promise_result_[0].did_not_swap_called); |
| 4483 EXPECT_TRUE(swap_promise_result_[0].dtor_called); | 4483 EXPECT_TRUE(swap_promise_result_[0].dtor_called); |
| 4484 } | 4484 } |
| 4485 | 4485 |
| 4486 { | 4486 { |
| 4487 // The second commit aborts. | 4487 // The second commit is aborted since it contains no updates. |
| 4488 base::AutoLock lock(swap_promise_result_[1].lock); | 4488 base::AutoLock lock(swap_promise_result_[1].lock); |
| 4489 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); | 4489 EXPECT_FALSE(swap_promise_result_[1].did_swap_called); |
| 4490 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); | 4490 EXPECT_TRUE(swap_promise_result_[1].did_not_swap_called); |
| 4491 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_[1].reason); | 4491 EXPECT_EQ(SwapPromise::COMMIT_NO_UPDATE, swap_promise_result_[1].reason); |
| 4492 EXPECT_TRUE(swap_promise_result_[1].dtor_called); | 4492 EXPECT_TRUE(swap_promise_result_[1].dtor_called); |
| 4493 } | 4493 } |
| 4494 | 4494 |
| 4495 { | 4495 { |
| 4496 // The last commit completes but it does not cause swap buffer because | 4496 // The last commit completes but it does not cause swap buffer because |
| 4497 // there is no damage in the frame data. | 4497 // there is no damage in the frame data. |
| 4498 base::AutoLock lock(swap_promise_result_[2].lock); | 4498 base::AutoLock lock(swap_promise_result_[2].lock); |
| 4499 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); | 4499 EXPECT_FALSE(swap_promise_result_[2].did_swap_called); |
| 4500 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); | 4500 EXPECT_TRUE(swap_promise_result_[2].did_not_swap_called); |
| 4501 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); | 4501 EXPECT_EQ(SwapPromise::SWAP_FAILS, swap_promise_result_[2].reason); |
| 4502 EXPECT_TRUE(swap_promise_result_[2].dtor_called); | 4502 EXPECT_TRUE(swap_promise_result_[2].dtor_called); |
| 4503 } | 4503 } |
| 4504 } | 4504 } |
| 4505 | 4505 |
| 4506 int commit_count_; | 4506 int commit_count_; |
| 4507 int commit_complete_count_; | 4507 int commit_complete_count_; |
| 4508 TestSwapPromiseResult swap_promise_result_[3]; | 4508 TestSwapPromiseResult swap_promise_result_[3]; |
| 4509 }; | 4509 }; |
| 4510 | 4510 |
| 4511 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); | 4511 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromise); |
| 4512 | 4512 |
| 4513 class LayerTreeHostTestBreakSwapPromiseForAbortedCommit | |
| 4514 : public LayerTreeHostTest { | |
| 4515 protected: | |
| 4516 LayerTreeHostTestBreakSwapPromiseForAbortedCommit() : commit_count_(0) {} | |
| 4517 | |
| 4518 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | |
| 4519 settings->throttle_frame_production = false; | |
| 4520 } | |
| 4521 | |
| 4522 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
| 4523 | |
| 4524 virtual void DidCommit() OVERRIDE { | |
| 4525 commit_count_++; | |
| 4526 if (commit_count_ == 1) { | |
| 4527 scoped_ptr<SwapPromise> swap_promise( | |
| 4528 new TestSwapPromise(&swap_promise_result_)); | |
| 4529 layer_tree_host()->QueueSwapPromise(swap_promise.Pass()); | |
| 4530 } | |
| 4531 } | |
| 4532 | |
| 4533 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | |
| 4534 bool did_handle) OVERRIDE { | |
| 4535 EndTest(); | |
| 4536 } | |
| 4537 | |
| 4538 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | |
| 4539 // Initiate an abortable commit. | |
|
piman
2014/06/25 21:20:32
What causes this commit to be aborted?
mkosiba (inactive)
2014/06/25 22:08:33
I'd be thrilled to know too, to be honest. I spent
mkosiba (inactive)
2014/06/26 12:36:47
Ok, so I think this has something to do with the s
piman
2014/06/26 20:40:12
Mmh, I think the case where that happens is the Ea
mkosiba (inactive)
2014/06/27 14:18:59
That works, thanks!
| |
| 4540 host_impl->SetNeedsCommit(); | |
| 4541 } | |
| 4542 | |
| 4543 virtual void AfterTest() OVERRIDE { | |
| 4544 EXPECT_EQ(commit_count_, 2); | |
| 4545 { | |
| 4546 base::AutoLock lock(swap_promise_result_.lock); | |
| 4547 EXPECT_FALSE(swap_promise_result_.did_swap_called); | |
| 4548 EXPECT_TRUE(swap_promise_result_.did_not_swap_called); | |
| 4549 EXPECT_EQ(SwapPromise::COMMIT_FAILS, swap_promise_result_.reason); | |
| 4550 EXPECT_TRUE(swap_promise_result_.dtor_called); | |
| 4551 } | |
| 4552 } | |
| 4553 | |
| 4554 int commit_count_; | |
| 4555 TestSwapPromiseResult swap_promise_result_; | |
| 4556 }; | |
| 4557 | |
| 4558 MULTI_THREAD_TEST_F(LayerTreeHostTestBreakSwapPromiseForAbortedCommit); | |
| 4559 | |
| 4513 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { | 4560 class SimpleSwapPromiseMonitor : public SwapPromiseMonitor { |
| 4514 public: | 4561 public: |
| 4515 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, | 4562 SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host, |
| 4516 LayerTreeHostImpl* layer_tree_host_impl, | 4563 LayerTreeHostImpl* layer_tree_host_impl, |
| 4517 int* set_needs_commit_count, | 4564 int* set_needs_commit_count, |
| 4518 int* set_needs_redraw_count) | 4565 int* set_needs_redraw_count) |
| 4519 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), | 4566 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), |
| 4520 set_needs_commit_count_(set_needs_commit_count), | 4567 set_needs_commit_count_(set_needs_commit_count), |
| 4521 set_needs_redraw_count_(set_needs_redraw_count) {} | 4568 set_needs_redraw_count_(set_needs_redraw_count) {} |
| 4522 | 4569 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4894 const gfx::Size bounds_; | 4941 const gfx::Size bounds_; |
| 4895 FakeContentLayerClient client_; | 4942 FakeContentLayerClient client_; |
| 4896 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 4943 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
| 4897 scoped_refptr<FakePictureLayer> picture_layer_; | 4944 scoped_refptr<FakePictureLayer> picture_layer_; |
| 4898 Layer* child_layer_; | 4945 Layer* child_layer_; |
| 4899 }; | 4946 }; |
| 4900 | 4947 |
| 4901 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 4948 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
| 4902 | 4949 |
| 4903 } // namespace cc | 4950 } // namespace cc |
| OLD | NEW |