Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Add an --enable-deadline-scheduler commandline flag. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 using testing::AnyNumber; 58 using testing::AnyNumber;
59 using testing::AtLeast; 59 using testing::AtLeast;
60 using testing::Mock; 60 using testing::Mock;
61 61
62 namespace cc { 62 namespace cc {
63 namespace { 63 namespace {
64 64
65 class LayerTreeHostTest : public LayerTreeTest { 65 class LayerTreeHostTest : public LayerTreeTest {
66 }; 66 };
67 67
68 // Two setNeedsCommits in a row should lead to at least 1 commit and at least 1 68 // Two setNeedsCommits in a row should lead to 1 commit and 1 draw.
69 // draw with frame 0.
70 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest { 69 class LayerTreeHostTestSetNeedsCommit1 : public LayerTreeHostTest {
71 public: 70 public:
72 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {} 71 LayerTreeHostTestSetNeedsCommit1() : num_commits_(0), num_draws_(0) {}
73 72
74 virtual void BeginTest() OVERRIDE { 73 virtual void BeginTest() OVERRIDE {
75 PostSetNeedsCommitToMainThread(); 74 PostSetNeedsCommitToMainThread();
76 PostSetNeedsCommitToMainThread(); 75 PostSetNeedsCommitToMainThread();
77 } 76 }
78 77
79 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 78 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
80 num_draws_++; 79 num_draws_++;
81 if (!impl->active_tree()->source_frame_number()) 80 if (!impl->active_tree()->source_frame_number())
82 EndTest(); 81 EndTest();
83 } 82 }
84 83
85 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 84 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
86 num_commits_++; 85 num_commits_++;
87 } 86 }
88 87
89 virtual void AfterTest() OVERRIDE { 88 virtual void AfterTest() OVERRIDE {
90 EXPECT_GE(1, num_commits_); 89 EXPECT_EQ(num_commits_, 1);
91 EXPECT_GE(1, num_draws_); 90 EXPECT_EQ(num_draws_, 1);
92 } 91 }
93 92
94 private: 93 private:
95 int num_commits_; 94 int num_commits_;
96 int num_draws_; 95 int num_draws_;
97 }; 96 };
98 97
99 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); 98 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1);
100 99
101 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that 100 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 615
617 // A compositeAndReadback while invisible should force a normal commit without 616 // A compositeAndReadback while invisible should force a normal commit without
618 // assertion. 617 // assertion.
619 class LayerTreeHostTestCompositeAndReadbackWhileInvisible 618 class LayerTreeHostTestCompositeAndReadbackWhileInvisible
620 : public LayerTreeHostTest { 619 : public LayerTreeHostTest {
621 public: 620 public:
622 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {} 621 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {}
623 622
624 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 623 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
625 624
626 virtual void DidCommitAndDrawFrame() OVERRIDE { 625 virtual void DidCommit() OVERRIDE {
627 num_commits_++; 626 num_commits_++;
628 if (num_commits_ == 1) { 627 if (num_commits_ == 1) {
629 layer_tree_host()->SetVisible(false); 628 layer_tree_host()->SetVisible(false);
630 layer_tree_host()->SetNeedsCommit(); 629 layer_tree_host()->SetNeedsCommit();
631 layer_tree_host()->SetNeedsCommit(); 630 layer_tree_host()->SetNeedsCommit();
632 char pixels[4]; 631 char pixels[4];
633 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); 632 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1));
634 } else { 633 } else {
635 EndTest(); 634 EndTest();
636 } 635 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 }; 694 };
696 695
697 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); 696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
698 697
699 // This test verifies that LayerTreeHostImpl's current frame time gets 698 // This test verifies that LayerTreeHostImpl's current frame time gets
700 // updated in consecutive frames when it doesn't draw due to tree 699 // updated in consecutive frames when it doesn't draw due to tree
701 // activation failure. 700 // activation failure.
702 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails 701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
703 : public LayerTreeHostTest { 702 : public LayerTreeHostTest {
704 public: 703 public:
705 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {} 704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
705 : frame_count_with_pending_tree_(0) {}
706 706
707 virtual void BeginTest() OVERRIDE { 707 virtual void BeginTest() OVERRIDE {
708 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 708 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
709 layer_tree_host()->set_background_color(SK_ColorGRAY); 709 layer_tree_host()->set_background_color(SK_ColorGRAY);
710 710
711 PostSetNeedsCommitToMainThread(); 711 PostSetNeedsCommitToMainThread();
712 } 712 }
713 713
714 virtual void WillBeginFrameOnThread(LayerTreeHostImpl* host_impl,
715 const BeginFrameArgs& args) OVERRIDE {
716 if (host_impl->pending_tree())
717 frame_count_with_pending_tree_++;
718 }
719
714 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 720 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
715 if (frame_ >= 1) { 721 if (frame_count_with_pending_tree_ > 1) {
716 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); 722 EXPECT_NE(first_frame_time_.ToInternalValue(),
723 impl->CurrentFrameTimeTicks().ToInternalValue());
717 EndTest(); 724 EndTest();
718 return; 725 return;
719 } 726 }
720 727
721 EXPECT_FALSE(impl->settings().impl_side_painting); 728 EXPECT_FALSE(impl->settings().impl_side_painting);
722 EndTest(); 729 EndTest();
723 } 730 }
724 731
725 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { 732 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
726 if (frame_ >= 1) 733 return frame_count_with_pending_tree_ > 1;
727 return true;
728
729 return false;
730 } 734 }
731 735
732 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl) 736 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
733 OVERRIDE { 737 if (impl->settings().impl_side_painting)
734 frame_++; 738 EXPECT_NE(frame_count_with_pending_tree_, 1);
735 if (frame_ == 1) {
736 first_frame_time_ = impl->CurrentFrameTimeTicks();
737
738 // Since base::TimeTicks::Now() uses a low-resolution clock on
739 // Windows, we need to make sure that the clock has incremented past
740 // first_frame_time_.
741 while (first_frame_time_ == base::TimeTicks::Now()) {}
742
743 return false;
744 }
745
746 return true;
747 } 739 }
748 740
749 virtual void AfterTest() OVERRIDE {} 741 virtual void AfterTest() OVERRIDE {}
750 742
751 private: 743 private:
752 int frame_; 744 int frame_count_with_pending_tree_;
753 base::TimeTicks first_frame_time_; 745 base::TimeTicks first_frame_time_;
754 }; 746 };
755 747
756 SINGLE_AND_MULTI_THREAD_TEST_F( 748 SINGLE_AND_MULTI_THREAD_TEST_F(
757 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); 749 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
758 750
759 // This test verifies that LayerTreeHostImpl's current frame time gets 751 // This test verifies that LayerTreeHostImpl's current frame time gets
760 // updated in consecutive frames when it draws in each frame. 752 // updated in consecutive frames when it draws in each frame.
761 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { 753 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
762 public: 754 public:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 PostSetNeedsCommitToMainThread(); 816 PostSetNeedsCommitToMainThread();
825 } 817 }
826 818
827 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) 819 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale)
828 OVERRIDE { 820 OVERRIDE {
829 gfx::Vector2d offset = scroll_layer_->scroll_offset(); 821 gfx::Vector2d offset = scroll_layer_->scroll_offset();
830 scroll_layer_->SetScrollOffset(offset + scroll_delta); 822 scroll_layer_->SetScrollOffset(offset + scroll_delta);
831 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); 823 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
832 } 824 }
833 825
834 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 826 virtual void SwapBuffersOnThread(LayerTreeHostImpl* impl,
835 impl->ProcessScrollDeltas(); 827 bool result) OVERRIDE {
836 // We get one commit before the first draw, and the animation doesn't happen 828 // We get one commit before the first draw, and the animation doesn't happen
837 // until the second draw. 829 // until the second draw.
838 switch (impl->active_tree()->source_frame_number()) { 830 switch (impl->active_tree()->source_frame_number()) {
839 case 0: 831 case 0:
840 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); 832 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
841 // We'll start an animation when we get back to the main thread. 833 // We'll start an animation when we get back to the main thread.
842 break; 834 break;
843 case 1: 835 case 1:
844 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); 836 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
845 PostSetNeedsRedrawToMainThread();
846 break; 837 break;
847 case 2: 838 case 2:
848 EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor()); 839 EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor());
849 EndTest(); 840 EndTest();
850 break; 841 break;
851 default: 842 default:
852 NOTREACHED(); 843 NOTREACHED();
853 } 844 }
854 } 845 }
855 846
856 virtual void DidCommitAndDrawFrame() OVERRIDE { 847 virtual void DidCommit() OVERRIDE {
857 switch (layer_tree_host()->source_frame_number()) { 848 switch (layer_tree_host()->source_frame_number()) {
858 case 1: 849 case 1:
859 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); 850 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f);
860 layer_tree_host()->StartPageScaleAnimation( 851 layer_tree_host()->StartPageScaleAnimation(
861 gfx::Vector2d(), false, 1.25f, base::TimeDelta()); 852 gfx::Vector2d(), false, 1.25f, base::TimeDelta());
862 break; 853 break;
863 } 854 }
864 } 855 }
865 856
866 virtual void AfterTest() OVERRIDE {} 857 virtual void AfterTest() OVERRIDE {}
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 parent_->AddChild(child_); 1301 parent_->AddChild(child_);
1311 1302
1312 layer_tree_host()->SetRootLayer(parent_); 1303 layer_tree_host()->SetRootLayer(parent_);
1313 LayerTreeHostTest::SetupTree(); 1304 LayerTreeHostTest::SetupTree();
1314 } 1305 }
1315 1306
1316 virtual void BeginTest() OVERRIDE { 1307 virtual void BeginTest() OVERRIDE {
1317 PostSetNeedsCommitToMainThread(); 1308 PostSetNeedsCommitToMainThread();
1318 } 1309 }
1319 1310
1320 virtual void DidCommitAndDrawFrame() OVERRIDE { 1311 virtual void DidCommit() OVERRIDE {
1321 switch (layer_tree_host()->source_frame_number()) { 1312 switch (layer_tree_host()->source_frame_number()) {
1322 case 1: 1313 case 1:
1323 parent_->SetNeedsDisplay(); 1314 parent_->SetNeedsDisplay();
1324 child_->SetNeedsDisplay(); 1315 child_->SetNeedsDisplay();
1325 break; 1316 break;
1326 case 2: 1317 case 2:
1327 // Damage part of layers. 1318 // Damage part of layers.
1328 parent_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); 1319 parent_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f));
1329 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); 1320 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f));
1330 break; 1321 break;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1432
1442 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { 1433 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
1443 public: 1434 public:
1444 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {} 1435 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {}
1445 1436
1446 virtual void BeginTest() OVERRIDE { 1437 virtual void BeginTest() OVERRIDE {
1447 layer_tree_host()->SetNeedsRedraw(); 1438 layer_tree_host()->SetNeedsRedraw();
1448 PostSetNeedsCommitToMainThread(); 1439 PostSetNeedsCommitToMainThread();
1449 } 1440 }
1450 1441
1451 virtual void DidCommitAndDrawFrame() OVERRIDE { 1442 virtual void DidCommit() OVERRIDE {
1452 if (once_) 1443 if (once_)
1453 return; 1444 return;
1454 once_ = true; 1445 once_ = true;
1455 layer_tree_host()->SetNeedsRedraw(); 1446 layer_tree_host()->SetNeedsRedraw();
1456 layer_tree_host()->AcquireLayerTextures(); 1447 layer_tree_host()->AcquireLayerTextures();
1457 { 1448 {
1458 base::AutoLock lock(lock_); 1449 base::AutoLock lock(lock_);
1459 draw_count_ = 0; 1450 draw_count_ = 0;
1460 } 1451 }
1461 layer_tree_host()->FinishAllRendering(); 1452 layer_tree_host()->FinishAllRendering();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 surface_layer2_->SetReplicaLayer(replica_layer2_.get()); 1520 surface_layer2_->SetReplicaLayer(replica_layer2_.get());
1530 1521
1531 layer_tree_host()->SetRootLayer(root_layer_); 1522 layer_tree_host()->SetRootLayer(root_layer_);
1532 LayerTreeHostTest::SetupTree(); 1523 LayerTreeHostTest::SetupTree();
1533 } 1524 }
1534 1525
1535 virtual void BeginTest() OVERRIDE { 1526 virtual void BeginTest() OVERRIDE {
1536 PostSetNeedsCommitToMainThread(); 1527 PostSetNeedsCommitToMainThread();
1537 } 1528 }
1538 1529
1530 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1531 if (host_impl->active_tree()->source_frame_number() == 0) {
1532 // Reduce the memory limit to only fit the root layer and one render
1533 // surface. This prevents any contents drawing into surfaces
1534 // from being allocated.
1535 host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
1536 host_impl->SetDiscardBackBufferWhenNotVisible(true);
1537
1538 // If ManageTiles ever deallocates resources before the subsequent draw,
1539 // this test will need to change.
1540 host_impl->ManageTiles();
1541 }
1542 }
1543
1539 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1544 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1540 Renderer* renderer = host_impl->renderer(); 1545 Renderer* renderer = host_impl->renderer();
1541 RenderPass::Id surface1_render_pass_id = host_impl->active_tree() 1546 RenderPass::Id surface1_render_pass_id = host_impl->active_tree()
1542 ->root_layer()->children()[0]->render_surface()->RenderPassId(); 1547 ->root_layer()->children()[0]->render_surface()->RenderPassId();
1543 RenderPass::Id surface2_render_pass_id = 1548 RenderPass::Id surface2_render_pass_id =
1544 host_impl->active_tree()->root_layer()->children()[0]->children()[0] 1549 host_impl->active_tree()->root_layer()->children()[0]->children()[0]
1545 ->render_surface()->RenderPassId(); 1550 ->render_surface()->RenderPassId();
1546 1551
1547 switch (host_impl->active_tree()->source_frame_number()) { 1552 switch (host_impl->active_tree()->source_frame_number()) {
1548 case 0: 1553 case 0:
1549 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId( 1554 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(
1550 surface1_render_pass_id)); 1555 surface1_render_pass_id));
1551 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId( 1556 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(
1552 surface2_render_pass_id)); 1557 surface2_render_pass_id));
1553
1554 // Reduce the memory limit to only fit the root layer and one render
1555 // surface. This prevents any contents drawing into surfaces
1556 // from being allocated.
1557 host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
1558 host_impl->SetDiscardBackBufferWhenNotVisible(true);
1559 break; 1558 break;
1560 case 1: 1559 case 1:
1561 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId( 1560 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
1562 surface1_render_pass_id)); 1561 surface1_render_pass_id));
1563 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId( 1562 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
1564 surface2_render_pass_id)); 1563 surface2_render_pass_id));
1565
1566 EndTest(); 1564 EndTest();
1567 break; 1565 break;
1568 } 1566 }
1569 } 1567 }
1570 1568
1571 virtual void DidCommitAndDrawFrame() OVERRIDE { 1569 virtual void DidCommit() OVERRIDE {
1572 if (layer_tree_host()->source_frame_number() < 2) 1570 if (layer_tree_host()->source_frame_number() < 2)
1573 root_layer_->SetNeedsDisplay(); 1571 root_layer_->SetNeedsDisplay();
1574 } 1572 }
1575 1573
1576 virtual void AfterTest() OVERRIDE { 1574 virtual void AfterTest() OVERRIDE {
1577 EXPECT_LE(2u, root_layer_->update_count()); 1575 EXPECT_LE(2u, root_layer_->update_count());
1578 EXPECT_LE(2u, surface_layer1_->update_count()); 1576 EXPECT_LE(2u, surface_layer1_->update_count());
1579 EXPECT_LE(2u, surface_layer2_->update_count()); 1577 EXPECT_LE(2u, surface_layer2_->update_count());
1580 } 1578 }
1581 1579
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 content_layer_ = ContentLayer::Create(&client_); 1865 content_layer_ = ContentLayer::Create(&client_);
1868 content_layer_->SetBounds(gfx::Size(10, 10)); 1866 content_layer_->SetBounds(gfx::Size(10, 10));
1869 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); 1867 content_layer_->SetPosition(gfx::PointF(0.f, 0.f));
1870 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); 1868 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
1871 content_layer_->SetIsDrawable(true); 1869 content_layer_->SetIsDrawable(true);
1872 layer_tree_host()->root_layer()->AddChild(content_layer_); 1870 layer_tree_host()->root_layer()->AddChild(content_layer_);
1873 1871
1874 PostSetNeedsCommitToMainThread(); 1872 PostSetNeedsCommitToMainThread();
1875 } 1873 }
1876 1874
1877 virtual void DidCommitAndDrawFrame() OVERRIDE { 1875 virtual void DidCommit() OVERRIDE { content_layer_->SetNeedsDisplay(); }
1878 if (num_draw_layers_ == 2)
1879 return;
1880 content_layer_->SetNeedsDisplay();
1881 }
1882 1876
1883 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1877 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1884 if (num_draw_layers_ == 1) 1878 EXPECT_EQ(num_draw_layers_, num_commit_complete_);
1885 num_commit_complete_++; 1879 num_commit_complete_++;
1886 } 1880 }
1887 1881
1888 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1882 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1889 num_draw_layers_++; 1883 num_draw_layers_++;
1890 if (num_draw_layers_ == 2) 1884 if (num_draw_layers_ == 2)
1891 EndTest(); 1885 EndTest();
1892 } 1886 }
1893 1887
1894 virtual void AfterTest() OVERRIDE { 1888 virtual void AfterTest() OVERRIDE {}
1895 // Check that we didn't commit twice between first and second draw.
1896 EXPECT_EQ(1, num_commit_complete_);
1897 }
1898 1889
1899 private: 1890 private:
1900 FakeContentLayerClient client_; 1891 FakeContentLayerClient client_;
1901 scoped_refptr<Layer> content_layer_; 1892 scoped_refptr<Layer> content_layer_;
1902 int num_commit_complete_; 1893 int num_commit_complete_;
1903 int num_draw_layers_; 1894 int num_draw_layers_;
1904 }; 1895 };
1905 1896
1906 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate); 1897 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousInvalidate);
1907 1898
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 settings->using_synchronous_renderer_compositor = true; 2256 settings->using_synchronous_renderer_compositor = true;
2266 } 2257 }
2267 2258
2268 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2259 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2269 2260
2270 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2261 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2271 // The BeginFrame notification is turned off now but will get enabled 2262 // The BeginFrame notification is turned off now but will get enabled
2272 // once we return. End test while it's enabled. 2263 // once we return. End test while it's enabled.
2273 ImplThreadTaskRunner()->PostTask( 2264 ImplThreadTaskRunner()->PostTask(
2274 FROM_HERE, 2265 FROM_HERE,
2275 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, 2266 base::Bind(
2276 base::Unretained(this))); 2267 &LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled::
2268 EndTest,
2269 base::Unretained(this)));
2277 } 2270 }
2278 2271
2279 virtual void AfterTest() OVERRIDE {} 2272 virtual void AfterTest() OVERRIDE {}
2280 }; 2273 };
2281 2274
2282 MULTI_THREAD_TEST_F( 2275 MULTI_THREAD_TEST_F(
2283 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); 2276 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled);
2284 2277
2285 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation 2278 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation
2286 : public LayerTreeHostTest { 2279 : public LayerTreeHostTest {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 root->AddChild(child); 2506 root->AddChild(child);
2514 2507
2515 layer_tree_host()->SetRootLayer(root); 2508 layer_tree_host()->SetRootLayer(root);
2516 LayerTreeHostTest::SetupTree(); 2509 LayerTreeHostTest::SetupTree();
2517 } 2510 }
2518 2511
2519 virtual void BeginTest() OVERRIDE { 2512 virtual void BeginTest() OVERRIDE {
2520 PostSetNeedsCommitToMainThread(); 2513 PostSetNeedsCommitToMainThread();
2521 } 2514 }
2522 2515
2523 virtual void DidCommitAndDrawFrame() OVERRIDE { 2516 virtual void DidCommit() OVERRIDE { WaitForCallback(); }
2524 WaitForCallback();
2525 }
2526 2517
2527 void WaitForCallback() { 2518 void WaitForCallback() {
2528 base::MessageLoop::current()->PostTask( 2519 base::MessageLoop::current()->PostTask(
2529 FROM_HERE, 2520 FROM_HERE,
2530 base::Bind( 2521 base::Bind(
2531 &LayerTreeHostTestAsyncReadback::NextStep, 2522 &LayerTreeHostTestAsyncReadback::NextStep,
2532 base::Unretained(this))); 2523 base::Unretained(this)));
2533 } 2524 }
2534 2525
2535 void NextStep() { 2526 void NextStep() {
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 layer_tree_host()->SetNeedsRedraw(); 3188 layer_tree_host()->SetNeedsRedraw();
3198 break; 3189 break;
3199 case 3: 3190 case 3:
3200 // CompositeAndReadback in Round 4, first commit. 3191 // CompositeAndReadback in Round 4, first commit.
3201 EXPECT_EQ(2, frame_); 3192 EXPECT_EQ(2, frame_);
3202 break; 3193 break;
3203 case 4: 3194 case 4:
3204 // Round 4 done. 3195 // Round 4 done.
3205 EXPECT_EQ(2, frame_); 3196 EXPECT_EQ(2, frame_);
3206 layer_tree_host()->SetNeedsCommit(); 3197 layer_tree_host()->SetNeedsCommit();
3198 // We can't SetNeedsRedraw immediately because it will race the commit.
3199 break;
3200 case 5:
3201 EXPECT_EQ(2, frame_);
3207 layer_tree_host()->SetNeedsRedraw(); 3202 layer_tree_host()->SetNeedsRedraw();
3208 break; 3203 break;
3209 } 3204 }
3210 } 3205 }
3211 3206
3212 virtual void DidCompleteSwapBuffers() OVERRIDE { 3207 virtual void DidCompleteSwapBuffers() OVERRIDE {
3213 int commit = layer_tree_host()->source_frame_number(); 3208 int commit = layer_tree_host()->source_frame_number();
3214 ++frame_; 3209 ++frame_;
3215 char pixels[4] = {0}; 3210 char pixels[4] = {0};
3216 switch (frame_) { 3211 switch (frame_) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 child2_->AddChild(leaf_picture_layer_); 3514 child2_->AddChild(leaf_picture_layer_);
3520 if (leaf_content_layer_) 3515 if (leaf_content_layer_)
3521 child2_->AddChild(leaf_content_layer_); 3516 child2_->AddChild(leaf_content_layer_);
3522 3517
3523 other_root_ = PushPropertiesCountingLayer::Create(); 3518 other_root_ = PushPropertiesCountingLayer::Create();
3524 3519
3525 // Don't set the root layer here. 3520 // Don't set the root layer here.
3526 LayerTreeHostTest::SetupTree(); 3521 LayerTreeHostTest::SetupTree();
3527 } 3522 }
3528 3523
3529 virtual void DidCommitAndDrawFrame() OVERRIDE { 3524 virtual void DidCommit() OVERRIDE {
3530 ++num_commits_; 3525 ++num_commits_;
3531 3526
3532 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 3527 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
3533 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 3528 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
3534 EXPECT_EQ(expected_push_properties_grandchild_, 3529 EXPECT_EQ(expected_push_properties_grandchild_,
3535 grandchild_->push_properties_count()); 3530 grandchild_->push_properties_count());
3536 EXPECT_EQ(expected_push_properties_child2_, 3531 EXPECT_EQ(expected_push_properties_child2_,
3537 child2_->push_properties_count()); 3532 child2_->push_properties_count());
3538 EXPECT_EQ(expected_push_properties_other_root_, 3533 EXPECT_EQ(expected_push_properties_other_root_,
3539 other_root_->push_properties_count()); 3534 other_root_->push_properties_count());
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3713 bool has_thumb = false; 3708 bool has_thumb = false;
3714 scrollbar_layer_ = 3709 scrollbar_layer_ =
3715 FakeScrollbarLayer::Create(paint_scrollbar, has_thumb, root_->id()); 3710 FakeScrollbarLayer::Create(paint_scrollbar, has_thumb, root_->id());
3716 3711
3717 root_->AddChild(scrollbar_layer_); 3712 root_->AddChild(scrollbar_layer_);
3718 3713
3719 layer_tree_host()->SetRootLayer(root_); 3714 layer_tree_host()->SetRootLayer(root_);
3720 LayerTreeHostTest::SetupTree(); 3715 LayerTreeHostTest::SetupTree();
3721 } 3716 }
3722 3717
3723 virtual void DidCommitAndDrawFrame() OVERRIDE { 3718 virtual void DidCommit() OVERRIDE {
3724 switch (layer_tree_host()->source_frame_number()) { 3719 switch (layer_tree_host()->source_frame_number()) {
3725 case 0: 3720 case 0:
3726 break; 3721 break;
3727 case 1: { 3722 case 1: {
3728 // During update, the ignore_set_needs_commit_ bit is set to true to 3723 // During update, the ignore_set_needs_commit_ bit is set to true to
3729 // avoid causing a second commit to be scheduled. If a property change 3724 // avoid causing a second commit to be scheduled. If a property change
3730 // is made during this, however, it needs to be pushed in the upcoming 3725 // is made during this, however, it needs to be pushed in the upcoming
3731 // commit. 3726 // commit.
3732 scoped_ptr<base::AutoReset<bool> > ignore = 3727 scoped_ptr<base::AutoReset<bool> > ignore =
3733 scrollbar_layer_->IgnoreSetNeedsCommit(); 3728 scrollbar_layer_->IgnoreSetNeedsCommit();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3796 size_t expected_push_properties_root_; 3791 size_t expected_push_properties_root_;
3797 size_t expected_push_properties_child_; 3792 size_t expected_push_properties_child_;
3798 size_t expected_push_properties_grandchild1_; 3793 size_t expected_push_properties_grandchild1_;
3799 size_t expected_push_properties_grandchild2_; 3794 size_t expected_push_properties_grandchild2_;
3800 size_t expected_push_properties_grandchild3_; 3795 size_t expected_push_properties_grandchild3_;
3801 }; 3796 };
3802 3797
3803 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush 3798 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush
3804 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3799 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3805 protected: 3800 protected:
3806 virtual void DidCommitAndDrawFrame() OVERRIDE { 3801 virtual void DidCommit() OVERRIDE {
3807 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3802 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3808 switch (last_source_frame_number) { 3803 switch (last_source_frame_number) {
3809 case 0: 3804 case 0:
3810 EXPECT_FALSE(root_->needs_push_properties()); 3805 EXPECT_FALSE(root_->needs_push_properties());
3811 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3806 EXPECT_FALSE(root_->descendant_needs_push_properties());
3812 EXPECT_FALSE(child_->needs_push_properties()); 3807 EXPECT_FALSE(child_->needs_push_properties());
3813 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3808 EXPECT_FALSE(child_->descendant_needs_push_properties());
3814 EXPECT_FALSE(grandchild1_->needs_push_properties()); 3809 EXPECT_FALSE(grandchild1_->needs_push_properties());
3815 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties()); 3810 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties());
3816 EXPECT_FALSE(grandchild2_->needs_push_properties()); 3811 EXPECT_FALSE(grandchild2_->needs_push_properties());
(...skipping 19 matching lines...) Expand all
3836 break; 3831 break;
3837 } 3832 }
3838 } 3833 }
3839 }; 3834 };
3840 3835
3841 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush); 3836 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush);
3842 3837
3843 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion 3838 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
3844 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3839 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3845 protected: 3840 protected:
3846 virtual void DidCommitAndDrawFrame() OVERRIDE { 3841 virtual void DidCommit() OVERRIDE {
3847 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3842 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3848 switch (last_source_frame_number) { 3843 switch (last_source_frame_number) {
3849 case 0: 3844 case 0:
3850 layer_tree_host()->SetRootLayer(root_); 3845 layer_tree_host()->SetRootLayer(root_);
3851 break; 3846 break;
3852 case 1: 3847 case 1:
3853 EXPECT_FALSE(root_->needs_push_properties()); 3848 EXPECT_FALSE(root_->needs_push_properties());
3854 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3849 EXPECT_FALSE(root_->descendant_needs_push_properties());
3855 EXPECT_FALSE(child_->needs_push_properties()); 3850 EXPECT_FALSE(child_->needs_push_properties());
3856 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3851 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 break; 3914 break;
3920 } 3915 }
3921 } 3916 }
3922 }; 3917 };
3923 3918
3924 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion); 3919 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion);
3925 3920
3926 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence 3921 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
3927 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3922 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3928 protected: 3923 protected:
3929 virtual void DidCommitAndDrawFrame() OVERRIDE { 3924 virtual void DidCommit() OVERRIDE {
3930 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3925 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3931 switch (last_source_frame_number) { 3926 switch (last_source_frame_number) {
3932 case 0: 3927 case 0:
3933 layer_tree_host()->SetRootLayer(root_); 3928 layer_tree_host()->SetRootLayer(root_);
3934 grandchild1_->set_persist_needs_push_properties(true); 3929 grandchild1_->set_persist_needs_push_properties(true);
3935 grandchild2_->set_persist_needs_push_properties(true); 3930 grandchild2_->set_persist_needs_push_properties(true);
3936 break; 3931 break;
3937 case 1: 3932 case 1:
3938 EXPECT_FALSE(root_->needs_push_properties()); 3933 EXPECT_FALSE(root_->needs_push_properties());
3939 EXPECT_TRUE(root_->descendant_needs_push_properties()); 3934 EXPECT_TRUE(root_->descendant_needs_push_properties());
(...skipping 27 matching lines...) Expand all
3967 } 3962 }
3968 } 3963 }
3969 }; 3964 };
3970 3965
3971 MULTI_THREAD_TEST_F( 3966 MULTI_THREAD_TEST_F(
3972 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence); 3967 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence);
3973 3968
3974 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree 3969 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
3975 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3970 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3976 protected: 3971 protected:
3977 virtual void DidCommitAndDrawFrame() OVERRIDE { 3972 virtual void DidCommit() OVERRIDE {
3978 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3973 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3979 switch (last_source_frame_number) { 3974 switch (last_source_frame_number) {
3980 case 0: 3975 case 0:
3981 layer_tree_host()->SetRootLayer(root_); 3976 layer_tree_host()->SetRootLayer(root_);
3982 break; 3977 break;
3983 case 1: 3978 case 1:
3984 EXPECT_FALSE(root_->needs_push_properties()); 3979 EXPECT_FALSE(root_->needs_push_properties());
3985 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3980 EXPECT_FALSE(root_->descendant_needs_push_properties());
3986 EXPECT_FALSE(child_->needs_push_properties()); 3981 EXPECT_FALSE(child_->needs_push_properties());
3987 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3982 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 } 4030 }
4036 } 4031 }
4037 }; 4032 };
4038 4033
4039 MULTI_THREAD_TEST_F( 4034 MULTI_THREAD_TEST_F(
4040 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree); 4035 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree);
4041 4036
4042 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild 4037 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
4043 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 4038 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
4044 protected: 4039 protected:
4045 virtual void DidCommitAndDrawFrame() OVERRIDE { 4040 virtual void DidCommit() OVERRIDE {
4046 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 4041 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
4047 switch (last_source_frame_number) { 4042 switch (last_source_frame_number) {
4048 case 0: 4043 case 0:
4049 layer_tree_host()->SetRootLayer(root_); 4044 layer_tree_host()->SetRootLayer(root_);
4050 break; 4045 break;
4051 case 1: 4046 case 1:
4052 EXPECT_FALSE(root_->needs_push_properties()); 4047 EXPECT_FALSE(root_->needs_push_properties());
4053 EXPECT_FALSE(root_->descendant_needs_push_properties()); 4048 EXPECT_FALSE(root_->descendant_needs_push_properties());
4054 EXPECT_FALSE(child_->needs_push_properties()); 4049 EXPECT_FALSE(child_->needs_push_properties());
4055 EXPECT_FALSE(child_->descendant_needs_push_properties()); 4050 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4099 } 4094 }
4100 } 4095 }
4101 }; 4096 };
4102 4097
4103 MULTI_THREAD_TEST_F( 4098 MULTI_THREAD_TEST_F(
4104 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild); 4099 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild);
4105 4100
4106 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent 4101 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
4107 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 4102 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
4108 protected: 4103 protected:
4109 virtual void DidCommitAndDrawFrame() OVERRIDE { 4104 virtual void DidCommit() OVERRIDE {
4110 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 4105 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
4111 switch (last_source_frame_number) { 4106 switch (last_source_frame_number) {
4112 case 0: 4107 case 0:
4113 layer_tree_host()->SetRootLayer(root_); 4108 layer_tree_host()->SetRootLayer(root_);
4114 break; 4109 break;
4115 case 1: 4110 case 1:
4116 EXPECT_FALSE(root_->needs_push_properties()); 4111 EXPECT_FALSE(root_->needs_push_properties());
4117 EXPECT_FALSE(root_->descendant_needs_push_properties()); 4112 EXPECT_FALSE(root_->descendant_needs_push_properties());
4118 EXPECT_FALSE(child_->needs_push_properties()); 4113 EXPECT_FALSE(child_->needs_push_properties());
4119 EXPECT_FALSE(child_->descendant_needs_push_properties()); 4114 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
4484 int num_will_begin_frames_; 4479 int num_will_begin_frames_;
4485 int num_impl_commits_; 4480 int num_impl_commits_;
4486 }; 4481 };
4487 4482
4488 // Commits can only be aborted when using the thread proxy. 4483 // Commits can only be aborted when using the thread proxy.
4489 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4484 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4490 4485
4491 } // namespace 4486 } // namespace
4492 4487
4493 } // namespace cc 4488 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698