| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
| 10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } | 398 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } |
| 399 | 399 |
| 400 void AfterTest() override {} | 400 void AfterTest() override {} |
| 401 | 401 |
| 402 int request_count_; | 402 int request_count_; |
| 403 }; | 403 }; |
| 404 | 404 |
| 405 SINGLE_THREAD_NOIMPL_TEST_F(MultipleCompositeDoesNotCreateOutputSurface); | 405 SINGLE_THREAD_NOIMPL_TEST_F(MultipleCompositeDoesNotCreateOutputSurface); |
| 406 | 406 |
| 407 // This test makes sure that once a SingleThreadProxy issues a |
| 408 // DidFailToInitializeOutputSurface, that future Composite calls will not |
| 409 // trigger additional requests for output surfaces. |
| 407 class FailedCreateDoesNotCreateExtraOutputSurface | 410 class FailedCreateDoesNotCreateExtraOutputSurface |
| 408 : public LayerTreeHostContextTest { | 411 : public LayerTreeHostContextTest { |
| 409 public: | 412 public: |
| 410 FailedCreateDoesNotCreateExtraOutputSurface() | 413 FailedCreateDoesNotCreateExtraOutputSurface() |
| 411 : LayerTreeHostContextTest(), request_count_(0) {} | 414 : LayerTreeHostContextTest(), num_requests_(0), has_failed_(false) {} |
| 412 | 415 |
| 413 void InitializeSettings(LayerTreeSettings* settings) override { | 416 void InitializeSettings(LayerTreeSettings* settings) override { |
| 414 settings->single_thread_proxy_scheduler = false; | 417 settings->single_thread_proxy_scheduler = false; |
| 415 } | 418 } |
| 416 | 419 |
| 417 void RequestNewOutputSurface() override { | 420 void RequestNewOutputSurface() override { |
| 418 if (request_count_ == 0) { | 421 num_requests_++; |
| 419 ExpectCreateToFail(); | 422 // There should be one initial request and then one request from |
| 420 layer_tree_host()->SetOutputSurface( | 423 // the LayerTreeTest test hooks DidFailToInitializeOutputSurface (which is |
| 421 make_scoped_ptr(new FailureOutputSurface(false))); | 424 // hard to skip). This second request is just ignored and is test cruft. |
| 422 } | 425 EXPECT_LE(num_requests_, 2); |
| 426 if (num_requests_ > 1) |
| 427 return; |
| 428 ExpectCreateToFail(); |
| 429 layer_tree_host()->SetOutputSurface( |
| 430 make_scoped_ptr(new FailureOutputSurface(false))); |
| 423 } | 431 } |
| 424 | 432 |
| 425 void BeginTest() override { | 433 void BeginTest() override { |
| 434 // First composite tries to create a surface. |
| 426 layer_tree_host()->Composite(base::TimeTicks()); | 435 layer_tree_host()->Composite(base::TimeTicks()); |
| 436 EXPECT_EQ(num_requests_, 2); |
| 437 EXPECT_TRUE(has_failed_); |
| 438 |
| 439 // Second composite should not request or fail. |
| 427 layer_tree_host()->Composite(base::TimeTicks()); | 440 layer_tree_host()->Composite(base::TimeTicks()); |
| 441 EXPECT_EQ(num_requests_, 2); |
| 442 EndTest(); |
| 428 } | 443 } |
| 429 | 444 |
| 430 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } | 445 void DidInitializeOutputSurface() override { EXPECT_TRUE(false); } |
| 431 | 446 |
| 432 void DidFailToInitializeOutputSurface() override { | 447 void DidFailToInitializeOutputSurface() override { |
| 433 LayerTreeHostContextTest::DidFailToInitializeOutputSurface(); | 448 LayerTreeHostContextTest::DidFailToInitializeOutputSurface(); |
| 434 EXPECT_GE(2, ++request_count_); | 449 EXPECT_FALSE(has_failed_); |
| 435 EndTest(); | 450 has_failed_ = true; |
| 436 } | 451 } |
| 437 | 452 |
| 438 void AfterTest() override {} | 453 void AfterTest() override {} |
| 439 | 454 |
| 440 int request_count_; | 455 int num_requests_; |
| 456 bool has_failed_; |
| 441 }; | 457 }; |
| 442 | 458 |
| 443 SINGLE_THREAD_NOIMPL_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface); | 459 SINGLE_THREAD_NOIMPL_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface); |
| 444 | 460 |
| 445 class LayerTreeHostContextTestCommitAfterDelayedOutputSurface | 461 class LayerTreeHostContextTestCommitAfterDelayedOutputSurface |
| 446 : public LayerTreeHostContextTest { | 462 : public LayerTreeHostContextTest { |
| 447 public: | 463 public: |
| 448 LayerTreeHostContextTestCommitAfterDelayedOutputSurface() | 464 LayerTreeHostContextTestCommitAfterDelayedOutputSurface() |
| 449 : LayerTreeHostContextTest(), creating_output_(false) {} | 465 : LayerTreeHostContextTest(), creating_output_(false) {} |
| 450 | 466 |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 deferred_ = false; | 1703 deferred_ = false; |
| 1688 PostSetNeedsCommitToMainThread(); | 1704 PostSetNeedsCommitToMainThread(); |
| 1689 } | 1705 } |
| 1690 | 1706 |
| 1691 void ScheduledActionWillSendBeginMainFrame() override { | 1707 void ScheduledActionWillSendBeginMainFrame() override { |
| 1692 if (deferred_) | 1708 if (deferred_) |
| 1693 return; | 1709 return; |
| 1694 deferred_ = true; | 1710 deferred_ = true; |
| 1695 | 1711 |
| 1696 // Defer commits before the BeginFrame arrives, causing it to be delayed. | 1712 // Defer commits before the BeginFrame arrives, causing it to be delayed. |
| 1697 MainThreadTaskRunner()->PostTask( | 1713 PostSetDeferCommitsToMainThread(true); |
| 1698 FROM_HERE, | |
| 1699 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | |
| 1700 DeferCommitsOnMainThread, | |
| 1701 base::Unretained(this), | |
| 1702 true)); | |
| 1703 // Meanwhile, lose the context while we are in defer commits. | 1714 // Meanwhile, lose the context while we are in defer commits. |
| 1704 ImplThreadTaskRunner()->PostTask( | 1715 ImplThreadTaskRunner()->PostTask( |
| 1705 FROM_HERE, | 1716 FROM_HERE, |
| 1706 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | 1717 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: |
| 1707 LoseContextOnImplThread, | 1718 LoseContextOnImplThread, |
| 1708 base::Unretained(this))); | 1719 base::Unretained(this))); |
| 1709 } | 1720 } |
| 1710 | 1721 |
| 1711 void LoseContextOnImplThread() { | 1722 void LoseContextOnImplThread() { |
| 1712 LoseContext(); | 1723 LoseContext(); |
| 1713 | 1724 |
| 1714 // After losing the context, stop deferring commits. | 1725 // After losing the context, stop deferring commits. |
| 1715 MainThreadTaskRunner()->PostTask( | 1726 PostSetDeferCommitsToMainThread(false); |
| 1716 FROM_HERE, | |
| 1717 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame:: | |
| 1718 DeferCommitsOnMainThread, | |
| 1719 base::Unretained(this), | |
| 1720 false)); | |
| 1721 } | |
| 1722 | |
| 1723 void DeferCommitsOnMainThread(bool defer_commits) { | |
| 1724 layer_tree_host()->SetDeferCommits(defer_commits); | |
| 1725 } | 1727 } |
| 1726 | 1728 |
| 1727 void WillBeginMainFrame() override { | 1729 void WillBeginMainFrame() override { |
| 1728 // Don't begin a frame with a lost surface. | 1730 // Don't begin a frame with a lost surface. |
| 1729 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); | 1731 EXPECT_FALSE(layer_tree_host()->output_surface_lost()); |
| 1730 } | 1732 } |
| 1731 | 1733 |
| 1732 void DidCommitAndDrawFrame() override { EndTest(); } | 1734 void DidCommitAndDrawFrame() override { EndTest(); } |
| 1733 | 1735 |
| 1734 void AfterTest() override {} | 1736 void AfterTest() override {} |
| 1735 | 1737 |
| 1736 bool deferred_; | 1738 bool deferred_; |
| 1737 }; | 1739 }; |
| 1738 | 1740 |
| 1739 SINGLE_AND_MULTI_THREAD_TEST_F( | 1741 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1740 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1742 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
| 1741 | 1743 |
| 1742 } // namespace | 1744 } // namespace |
| 1743 } // namespace cc | 1745 } // namespace cc |
| OLD | NEW |