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

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: rebase 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 num_draws_++; 79 num_draws_++;
80 if (!impl->active_tree()->source_frame_number()) 80 if (!impl->active_tree()->source_frame_number())
81 EndTest(); 81 EndTest();
82 } 82 }
83 83
84 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 84 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
85 num_commits_++; 85 num_commits_++;
86 } 86 }
87 87
88 virtual void AfterTest() OVERRIDE { 88 virtual void AfterTest() OVERRIDE {
89 EXPECT_GE(1, num_commits_); 89 EXPECT_GE(num_commits_, 1);
90 EXPECT_GE(1, num_draws_); 90 EXPECT_GE(num_draws_, 1);
91 } 91 }
92 92
93 private: 93 private:
94 int num_commits_; 94 int num_commits_;
95 int num_draws_; 95 int num_draws_;
96 }; 96 };
97 97
98 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); 98 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1);
99 99
100 // 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
615 615
616 // A compositeAndReadback while invisible should force a normal commit without 616 // A compositeAndReadback while invisible should force a normal commit without
617 // assertion. 617 // assertion.
618 class LayerTreeHostTestCompositeAndReadbackWhileInvisible 618 class LayerTreeHostTestCompositeAndReadbackWhileInvisible
619 : public LayerTreeHostTest { 619 : public LayerTreeHostTest {
620 public: 620 public:
621 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {} 621 LayerTreeHostTestCompositeAndReadbackWhileInvisible() : num_commits_(0) {}
622 622
623 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 623 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
624 624
625 virtual void DidCommitAndDrawFrame() OVERRIDE { 625 virtual void DidCommit() OVERRIDE {
626 num_commits_++; 626 num_commits_++;
627 if (num_commits_ == 1) { 627 if (num_commits_ == 1) {
628 layer_tree_host()->SetVisible(false); 628 layer_tree_host()->SetVisible(false);
629 layer_tree_host()->SetNeedsCommit(); 629 layer_tree_host()->SetNeedsCommit();
630 layer_tree_host()->SetNeedsCommit(); 630 layer_tree_host()->SetNeedsCommit();
631 char pixels[4]; 631 char pixels[4];
632 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); 632 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1));
633 } else { 633 } else {
634 EndTest(); 634 EndTest();
635 } 635 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 }; 694 };
695 695
696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); 696 MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
697 697
698 // This test verifies that LayerTreeHostImpl's current frame time gets 698 // This test verifies that LayerTreeHostImpl's current frame time gets
699 // 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
700 // activation failure. 700 // activation failure.
701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails 701 class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
702 : public LayerTreeHostTest { 702 : public LayerTreeHostTest {
703 public: 703 public:
704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {} 704 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
705 : frame_count_with_pending_tree_(0) {}
705 706
706 virtual void BeginTest() OVERRIDE { 707 virtual void BeginTest() OVERRIDE {
707 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); 708 layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
708 layer_tree_host()->set_background_color(SK_ColorGRAY); 709 layer_tree_host()->set_background_color(SK_ColorGRAY);
709 710
710 PostSetNeedsCommitToMainThread(); 711 PostSetNeedsCommitToMainThread();
711 } 712 }
712 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
713 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 720 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
714 if (frame_ >= 1) { 721 if (frame_count_with_pending_tree_ > 1) {
715 EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); 722 EXPECT_NE(first_frame_time_.ToInternalValue(),
723 impl->CurrentFrameTimeTicks().ToInternalValue());
716 EndTest(); 724 EndTest();
717 return; 725 return;
718 } 726 }
719 727
720 EXPECT_FALSE(impl->settings().impl_side_painting); 728 EXPECT_FALSE(impl->settings().impl_side_painting);
721 EndTest(); 729 EndTest();
722 } 730 }
723 731
724 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { 732 virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
725 if (frame_ >= 1) 733 return frame_count_with_pending_tree_ > 1;
726 return true;
727
728 return false;
729 } 734 }
730 735
731 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl) 736 virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl)
732 OVERRIDE { 737 OVERRIDE {
733 frame_++; 738 if (frame_count_with_pending_tree_ > 1)
734 if (frame_ == 1) { 739 return true;
740
741 if (first_frame_time_.is_null()) {
735 first_frame_time_ = impl->CurrentFrameTimeTicks(); 742 first_frame_time_ = impl->CurrentFrameTimeTicks();
736 743
737 // Since base::TimeTicks::Now() uses a low-resolution clock on 744 // Since base::TimeTicks::Now() uses a low-resolution clock on
738 // Windows, we need to make sure that the clock has incremented past 745 // Windows, we need to make sure that the clock has incremented past
739 // first_frame_time_. 746 // first_frame_time_.
740 while (first_frame_time_ == base::TimeTicks::Now()) {} 747 while (first_frame_time_ == base::TimeTicks::Now()) {}
748 }
749 return false;
750 }
741 751
742 return false; 752 virtual void DidActivateTreeOnThread(LayerTreeHostImpl *impl) OVERRIDE {
743 } 753 if (impl->settings().impl_side_painting)
744 754 EXPECT_NE(frame_count_with_pending_tree_, 1);
745 return true;
746 } 755 }
747 756
748 virtual void AfterTest() OVERRIDE {} 757 virtual void AfterTest() OVERRIDE {}
749 758
750 private: 759 private:
751 int frame_; 760 int frame_count_with_pending_tree_;
752 base::TimeTicks first_frame_time_; 761 base::TimeTicks first_frame_time_;
753 }; 762 };
754 763
755 SINGLE_AND_MULTI_THREAD_TEST_F( 764 SINGLE_AND_MULTI_THREAD_TEST_F(
756 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); 765 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails);
757 766
758 // This test verifies that LayerTreeHostImpl's current frame time gets 767 // This test verifies that LayerTreeHostImpl's current frame time gets
759 // updated in consecutive frames when it draws in each frame. 768 // updated in consecutive frames when it draws in each frame.
760 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { 769 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest {
761 public: 770 public:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 PostSetNeedsCommitToMainThread(); 832 PostSetNeedsCommitToMainThread();
824 } 833 }
825 834
826 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) 835 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale)
827 OVERRIDE { 836 OVERRIDE {
828 gfx::Vector2d offset = scroll_layer_->scroll_offset(); 837 gfx::Vector2d offset = scroll_layer_->scroll_offset();
829 scroll_layer_->SetScrollOffset(offset + scroll_delta); 838 scroll_layer_->SetScrollOffset(offset + scroll_delta);
830 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); 839 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
831 } 840 }
832 841
833 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 842 virtual void SwapBuffersOnThread(LayerTreeHostImpl *impl, bool result)
834 impl->ProcessScrollDeltas(); 843 OVERRIDE {
835 // We get one commit before the first draw, and the animation doesn't happen 844 // We get one commit before the first draw, and the animation doesn't happen
836 // until the second draw. 845 // until the second draw.
837 switch (impl->active_tree()->source_frame_number()) { 846 switch (impl->active_tree()->source_frame_number()) {
838 case 0: 847 case 0:
839 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); 848 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
840 // We'll start an animation when we get back to the main thread. 849 // We'll start an animation when we get back to the main thread.
841 break; 850 break;
842 case 1: 851 case 1:
843 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); 852 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
844 PostSetNeedsRedrawToMainThread();
845 break; 853 break;
846 case 2: 854 case 2:
847 EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor()); 855 EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor());
848 EndTest(); 856 EndTest();
849 break; 857 break;
850 default: 858 default:
851 NOTREACHED(); 859 NOTREACHED();
852 } 860 }
853 } 861 }
854 862
855 virtual void DidCommitAndDrawFrame() OVERRIDE { 863 virtual void DidCommit() OVERRIDE {
856 switch (layer_tree_host()->source_frame_number()) { 864 switch (layer_tree_host()->source_frame_number()) {
857 case 1: 865 case 1:
858 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); 866 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f);
859 layer_tree_host()->StartPageScaleAnimation( 867 layer_tree_host()->StartPageScaleAnimation(
860 gfx::Vector2d(), false, 1.25f, base::TimeDelta()); 868 gfx::Vector2d(), false, 1.25f, base::TimeDelta());
861 break; 869 break;
862 } 870 }
863 } 871 }
864 872
865 virtual void AfterTest() OVERRIDE {} 873 virtual void AfterTest() OVERRIDE {}
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 parent_->AddChild(child_); 1264 parent_->AddChild(child_);
1257 1265
1258 layer_tree_host()->SetRootLayer(parent_); 1266 layer_tree_host()->SetRootLayer(parent_);
1259 LayerTreeHostTest::SetupTree(); 1267 LayerTreeHostTest::SetupTree();
1260 } 1268 }
1261 1269
1262 virtual void BeginTest() OVERRIDE { 1270 virtual void BeginTest() OVERRIDE {
1263 PostSetNeedsCommitToMainThread(); 1271 PostSetNeedsCommitToMainThread();
1264 } 1272 }
1265 1273
1266 virtual void DidCommitAndDrawFrame() OVERRIDE { 1274 virtual void DidCommit() OVERRIDE {
1267 switch (layer_tree_host()->source_frame_number()) { 1275 switch (layer_tree_host()->source_frame_number()) {
1268 case 1: 1276 case 1:
1269 parent_->SetNeedsDisplay(); 1277 parent_->SetNeedsDisplay();
1270 child_->SetNeedsDisplay(); 1278 child_->SetNeedsDisplay();
1271 break; 1279 break;
1272 case 2: 1280 case 2:
1273 // Damage part of layers. 1281 // Damage part of layers.
1274 parent_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); 1282 parent_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f));
1275 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f)); 1283 child_->SetNeedsDisplayRect(gfx::RectF(0.f, 0.f, 5.f, 5.f));
1276 break; 1284 break;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 1395
1388 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { 1396 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
1389 public: 1397 public:
1390 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {} 1398 LayerTreeHostTestFinishAllRendering() : once_(false), draw_count_(0) {}
1391 1399
1392 virtual void BeginTest() OVERRIDE { 1400 virtual void BeginTest() OVERRIDE {
1393 layer_tree_host()->SetNeedsRedraw(); 1401 layer_tree_host()->SetNeedsRedraw();
1394 PostSetNeedsCommitToMainThread(); 1402 PostSetNeedsCommitToMainThread();
1395 } 1403 }
1396 1404
1397 virtual void DidCommitAndDrawFrame() OVERRIDE { 1405 virtual void DidCommit() OVERRIDE {
1398 if (once_) 1406 if (once_)
1399 return; 1407 return;
1400 once_ = true; 1408 once_ = true;
1401 layer_tree_host()->SetNeedsRedraw(); 1409 layer_tree_host()->SetNeedsRedraw();
1402 layer_tree_host()->AcquireLayerTextures(); 1410 layer_tree_host()->AcquireLayerTextures();
1403 { 1411 {
1404 base::AutoLock lock(lock_); 1412 base::AutoLock lock(lock_);
1405 draw_count_ = 0; 1413 draw_count_ = 0;
1406 } 1414 }
1407 layer_tree_host()->FinishAllRendering(); 1415 layer_tree_host()->FinishAllRendering();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 surface_layer2_->SetReplicaLayer(replica_layer2_.get()); 1483 surface_layer2_->SetReplicaLayer(replica_layer2_.get());
1476 1484
1477 layer_tree_host()->SetRootLayer(root_layer_); 1485 layer_tree_host()->SetRootLayer(root_layer_);
1478 LayerTreeHostTest::SetupTree(); 1486 LayerTreeHostTest::SetupTree();
1479 } 1487 }
1480 1488
1481 virtual void BeginTest() OVERRIDE { 1489 virtual void BeginTest() OVERRIDE {
1482 PostSetNeedsCommitToMainThread(); 1490 PostSetNeedsCommitToMainThread();
1483 } 1491 }
1484 1492
1493 virtual void DidActivateTreeOnThread(LayerTreeHostImpl *host_impl) OVERRIDE {
1494 if (host_impl->active_tree()->source_frame_number() == 0) {
1495 // Reduce the memory limit to only fit the root layer and one render
1496 // surface. This prevents any contents drawing into surfaces
1497 // from being allocated.
1498 host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
1499 host_impl->SetDiscardBackBufferWhenNotVisible(true);
1500 }
1501 }
1502
1485 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 1503 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
1486 Renderer* renderer = host_impl->renderer(); 1504 Renderer* renderer = host_impl->renderer();
1487 RenderPass::Id surface1_render_pass_id = host_impl->active_tree() 1505 RenderPass::Id surface1_render_pass_id = host_impl->active_tree()
1488 ->root_layer()->children()[0]->render_surface()->RenderPassId(); 1506 ->root_layer()->children()[0]->render_surface()->RenderPassId();
1489 RenderPass::Id surface2_render_pass_id = 1507 RenderPass::Id surface2_render_pass_id =
1490 host_impl->active_tree()->root_layer()->children()[0]->children()[0] 1508 host_impl->active_tree()->root_layer()->children()[0]->children()[0]
1491 ->render_surface()->RenderPassId(); 1509 ->render_surface()->RenderPassId();
1492 1510
1493 switch (host_impl->active_tree()->source_frame_number()) { 1511 switch (host_impl->active_tree()->source_frame_number()) {
1494 case 0: 1512 case 0:
1495 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId( 1513 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(
1496 surface1_render_pass_id)); 1514 surface1_render_pass_id));
1497 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId( 1515 EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(
1498 surface2_render_pass_id)); 1516 surface2_render_pass_id));
1499
1500 // Reduce the memory limit to only fit the root layer and one render
1501 // surface. This prevents any contents drawing into surfaces
1502 // from being allocated.
1503 host_impl->SetMemoryPolicy(ManagedMemoryPolicy(100 * 100 * 4 * 2));
1504 host_impl->SetDiscardBackBufferWhenNotVisible(true);
1505 break; 1517 break;
1506 case 1: 1518 case 1:
1507 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId( 1519 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
1508 surface1_render_pass_id)); 1520 surface1_render_pass_id));
1509 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId( 1521 EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
1510 surface2_render_pass_id)); 1522 surface2_render_pass_id));
1511
1512 EndTest(); 1523 EndTest();
1513 break; 1524 break;
1514 } 1525 }
1515 } 1526 }
1516 1527
1517 virtual void DidCommitAndDrawFrame() OVERRIDE { 1528 virtual void DidCommit() OVERRIDE {
1518 if (layer_tree_host()->source_frame_number() < 2) 1529 if (layer_tree_host()->source_frame_number() < 2)
1519 root_layer_->SetNeedsDisplay(); 1530 root_layer_->SetNeedsDisplay();
1520 } 1531 }
1521 1532
1522 virtual void AfterTest() OVERRIDE { 1533 virtual void AfterTest() OVERRIDE {
1523 EXPECT_LE(2u, root_layer_->update_count()); 1534 EXPECT_LE(2u, root_layer_->update_count());
1524 EXPECT_LE(2u, surface_layer1_->update_count()); 1535 EXPECT_LE(2u, surface_layer1_->update_count());
1525 EXPECT_LE(2u, surface_layer2_->update_count()); 1536 EXPECT_LE(2u, surface_layer2_->update_count());
1526 } 1537 }
1527 1538
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 content_layer_ = ContentLayer::Create(&client_); 1824 content_layer_ = ContentLayer::Create(&client_);
1814 content_layer_->SetBounds(gfx::Size(10, 10)); 1825 content_layer_->SetBounds(gfx::Size(10, 10));
1815 content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); 1826 content_layer_->SetPosition(gfx::PointF(0.f, 0.f));
1816 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f)); 1827 content_layer_->SetAnchorPoint(gfx::PointF(0.f, 0.f));
1817 content_layer_->SetIsDrawable(true); 1828 content_layer_->SetIsDrawable(true);
1818 layer_tree_host()->root_layer()->AddChild(content_layer_); 1829 layer_tree_host()->root_layer()->AddChild(content_layer_);
1819 1830
1820 PostSetNeedsCommitToMainThread(); 1831 PostSetNeedsCommitToMainThread();
1821 } 1832 }
1822 1833
1823 virtual void DidCommitAndDrawFrame() OVERRIDE { 1834 virtual void DidCommit() OVERRIDE {
1824 if (num_draw_layers_ == 2) 1835 if (num_draw_layers_ == 2)
1825 return; 1836 return;
1826 content_layer_->SetNeedsDisplay(); 1837 content_layer_->SetNeedsDisplay();
1827 } 1838 }
1828 1839
1829 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1840 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1830 if (num_draw_layers_ == 1) 1841 if (num_draw_layers_ == 1)
1831 num_commit_complete_++; 1842 num_commit_complete_++;
1832 } 1843 }
1833 1844
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 settings->begin_frame_scheduling_enabled = true; 2221 settings->begin_frame_scheduling_enabled = true;
2211 settings->using_synchronous_renderer_compositor = true; 2222 settings->using_synchronous_renderer_compositor = true;
2212 } 2223 }
2213 2224
2214 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 2225 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
2215 2226
2216 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { 2227 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
2217 // The BeginFrame notification is turned off now but will get enabled 2228 // The BeginFrame notification is turned off now but will get enabled
2218 // once we return. End test while it's enabled. 2229 // once we return. End test while it's enabled.
2219 ImplThreadTaskRunner()->PostTask( 2230 ImplThreadTaskRunner()->PostTask(
2220 FROM_HERE, 2231 FROM_HERE, base::Bind(
2221 base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest, 2232 &LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled::EndTest,
2222 base::Unretained(this))); 2233 base::Unretained(this)));
2223 } 2234 }
2224 2235
2225 virtual void AfterTest() OVERRIDE {} 2236 virtual void AfterTest() OVERRIDE {}
2226 }; 2237 };
2227 2238
2228 MULTI_THREAD_TEST_F( 2239 MULTI_THREAD_TEST_F(
2229 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled); 2240 LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled);
2230 2241
2231 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation 2242 class LayerTreeHostTestUninvertibleTransformDoesNotBlockActivation
2232 : public LayerTreeHostTest { 2243 : public LayerTreeHostTest {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 root->AddChild(child); 2475 root->AddChild(child);
2465 2476
2466 layer_tree_host()->SetRootLayer(root); 2477 layer_tree_host()->SetRootLayer(root);
2467 LayerTreeHostTest::SetupTree(); 2478 LayerTreeHostTest::SetupTree();
2468 } 2479 }
2469 2480
2470 virtual void BeginTest() OVERRIDE { 2481 virtual void BeginTest() OVERRIDE {
2471 PostSetNeedsCommitToMainThread(); 2482 PostSetNeedsCommitToMainThread();
2472 } 2483 }
2473 2484
2474 virtual void DidCommitAndDrawFrame() OVERRIDE { 2485 virtual void DidCommit() OVERRIDE {
2475 WaitForCallback(); 2486 WaitForCallback();
2476 } 2487 }
2477 2488
2478 void WaitForCallback() { 2489 void WaitForCallback() {
2479 base::MessageLoop::current()->PostTask( 2490 base::MessageLoop::current()->PostTask(
2480 FROM_HERE, 2491 FROM_HERE,
2481 base::Bind( 2492 base::Bind(
2482 &LayerTreeHostTestAsyncReadback::NextStep, 2493 &LayerTreeHostTestAsyncReadback::NextStep,
2483 base::Unretained(this))); 2494 base::Unretained(this)));
2484 } 2495 }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 layer_tree_host()->SetNeedsRedraw(); 3017 layer_tree_host()->SetNeedsRedraw();
3007 break; 3018 break;
3008 case 3: 3019 case 3:
3009 // CompositeAndReadback in Round 4, first commit. 3020 // CompositeAndReadback in Round 4, first commit.
3010 EXPECT_EQ(2, frame_); 3021 EXPECT_EQ(2, frame_);
3011 break; 3022 break;
3012 case 4: 3023 case 4:
3013 // Round 4 done. 3024 // Round 4 done.
3014 EXPECT_EQ(2, frame_); 3025 EXPECT_EQ(2, frame_);
3015 layer_tree_host()->SetNeedsCommit(); 3026 layer_tree_host()->SetNeedsCommit();
3027 // We can't SetNeedsRedraw immediately because it will race the commit.
3028 break;
3029 case 5:
3030 EXPECT_EQ(2, frame_);
3016 layer_tree_host()->SetNeedsRedraw(); 3031 layer_tree_host()->SetNeedsRedraw();
3017 break; 3032 break;
3018 } 3033 }
3019 } 3034 }
3020 3035
3021 virtual void DidCompleteSwapBuffers() OVERRIDE { 3036 virtual void DidCompleteSwapBuffers() OVERRIDE {
3022 int commit = layer_tree_host()->source_frame_number(); 3037 int commit = layer_tree_host()->source_frame_number();
3023 ++frame_; 3038 ++frame_;
3024 char pixels[4] = {0}; 3039 char pixels[4] = {0};
3025 switch (frame_) { 3040 switch (frame_) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 root_->AddChild(child2_); 3335 root_->AddChild(child2_);
3321 child_->AddChild(grandchild_); 3336 child_->AddChild(grandchild_);
3322 child2_->AddChild(leaf_scrollbar_layer_); 3337 child2_->AddChild(leaf_scrollbar_layer_);
3323 3338
3324 other_root_ = PushPropertiesCountingLayer::Create(); 3339 other_root_ = PushPropertiesCountingLayer::Create();
3325 3340
3326 // Don't set the root layer here. 3341 // Don't set the root layer here.
3327 LayerTreeHostTest::SetupTree(); 3342 LayerTreeHostTest::SetupTree();
3328 } 3343 }
3329 3344
3330 virtual void DidCommitAndDrawFrame() OVERRIDE { 3345 virtual void DidCommit() OVERRIDE {
3331 ++num_commits_; 3346 ++num_commits_;
3332 3347
3333 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 3348 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
3334 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 3349 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
3335 EXPECT_EQ(expected_push_properties_grandchild_, 3350 EXPECT_EQ(expected_push_properties_grandchild_,
3336 grandchild_->push_properties_count()); 3351 grandchild_->push_properties_count());
3337 EXPECT_EQ(expected_push_properties_child2_, 3352 EXPECT_EQ(expected_push_properties_child2_,
3338 child2_->push_properties_count()); 3353 child2_->push_properties_count());
3339 EXPECT_EQ(expected_push_properties_other_root_, 3354 EXPECT_EQ(expected_push_properties_other_root_,
3340 other_root_->push_properties_count()); 3355 other_root_->push_properties_count());
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3502 bool has_thumb = false; 3517 bool has_thumb = false;
3503 scrollbar_layer_ = 3518 scrollbar_layer_ =
3504 FakeScrollbarLayer::Create(paint_scrollbar, has_thumb, root_->id()); 3519 FakeScrollbarLayer::Create(paint_scrollbar, has_thumb, root_->id());
3505 3520
3506 root_->AddChild(scrollbar_layer_); 3521 root_->AddChild(scrollbar_layer_);
3507 3522
3508 layer_tree_host()->SetRootLayer(root_); 3523 layer_tree_host()->SetRootLayer(root_);
3509 LayerTreeHostTest::SetupTree(); 3524 LayerTreeHostTest::SetupTree();
3510 } 3525 }
3511 3526
3512 virtual void DidCommitAndDrawFrame() OVERRIDE { 3527 virtual void DidCommit() OVERRIDE {
3513 switch (layer_tree_host()->source_frame_number()) { 3528 switch (layer_tree_host()->source_frame_number()) {
3514 case 0: 3529 case 0:
3515 break; 3530 break;
3516 case 1: { 3531 case 1: {
3517 // During update, the ignore_set_needs_commit_ bit is set to true to 3532 // During update, the ignore_set_needs_commit_ bit is set to true to
3518 // avoid causing a second commit to be scheduled. If a property change 3533 // avoid causing a second commit to be scheduled. If a property change
3519 // is made during this, however, it needs to be pushed in the upcoming 3534 // is made during this, however, it needs to be pushed in the upcoming
3520 // commit. 3535 // commit.
3521 scoped_ptr<base::AutoReset<bool> > ignore = 3536 scoped_ptr<base::AutoReset<bool> > ignore =
3522 scrollbar_layer_->IgnoreSetNeedsCommit(); 3537 scrollbar_layer_->IgnoreSetNeedsCommit();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 size_t expected_push_properties_root_; 3600 size_t expected_push_properties_root_;
3586 size_t expected_push_properties_child_; 3601 size_t expected_push_properties_child_;
3587 size_t expected_push_properties_grandchild1_; 3602 size_t expected_push_properties_grandchild1_;
3588 size_t expected_push_properties_grandchild2_; 3603 size_t expected_push_properties_grandchild2_;
3589 size_t expected_push_properties_grandchild3_; 3604 size_t expected_push_properties_grandchild3_;
3590 }; 3605 };
3591 3606
3592 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush 3607 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush
3593 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3608 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3594 protected: 3609 protected:
3595 virtual void DidCommitAndDrawFrame() OVERRIDE { 3610 virtual void DidCommit() OVERRIDE {
3596 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3611 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3597 switch (last_source_frame_number) { 3612 switch (last_source_frame_number) {
3598 case 0: 3613 case 0:
3599 EXPECT_FALSE(root_->needs_push_properties()); 3614 EXPECT_FALSE(root_->needs_push_properties());
3600 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3615 EXPECT_FALSE(root_->descendant_needs_push_properties());
3601 EXPECT_FALSE(child_->needs_push_properties()); 3616 EXPECT_FALSE(child_->needs_push_properties());
3602 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3617 EXPECT_FALSE(child_->descendant_needs_push_properties());
3603 EXPECT_FALSE(grandchild1_->needs_push_properties()); 3618 EXPECT_FALSE(grandchild1_->needs_push_properties());
3604 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties()); 3619 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties());
3605 EXPECT_FALSE(grandchild2_->needs_push_properties()); 3620 EXPECT_FALSE(grandchild2_->needs_push_properties());
(...skipping 19 matching lines...) Expand all
3625 break; 3640 break;
3626 } 3641 }
3627 } 3642 }
3628 }; 3643 };
3629 3644
3630 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush); 3645 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush);
3631 3646
3632 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion 3647 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
3633 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3648 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3634 protected: 3649 protected:
3635 virtual void DidCommitAndDrawFrame() OVERRIDE { 3650 virtual void DidCommit() OVERRIDE {
3636 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3651 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3637 switch (last_source_frame_number) { 3652 switch (last_source_frame_number) {
3638 case 0: 3653 case 0:
3639 layer_tree_host()->SetRootLayer(root_); 3654 layer_tree_host()->SetRootLayer(root_);
3640 break; 3655 break;
3641 case 1: 3656 case 1:
3642 EXPECT_FALSE(root_->needs_push_properties()); 3657 EXPECT_FALSE(root_->needs_push_properties());
3643 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3658 EXPECT_FALSE(root_->descendant_needs_push_properties());
3644 EXPECT_FALSE(child_->needs_push_properties()); 3659 EXPECT_FALSE(child_->needs_push_properties());
3645 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3660 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 break; 3723 break;
3709 } 3724 }
3710 } 3725 }
3711 }; 3726 };
3712 3727
3713 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion); 3728 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion);
3714 3729
3715 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence 3730 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
3716 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3731 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3717 protected: 3732 protected:
3718 virtual void DidCommitAndDrawFrame() OVERRIDE { 3733 virtual void DidCommit() OVERRIDE {
3719 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3734 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3720 switch (last_source_frame_number) { 3735 switch (last_source_frame_number) {
3721 case 0: 3736 case 0:
3722 layer_tree_host()->SetRootLayer(root_); 3737 layer_tree_host()->SetRootLayer(root_);
3723 grandchild1_->set_persist_needs_push_properties(true); 3738 grandchild1_->set_persist_needs_push_properties(true);
3724 grandchild2_->set_persist_needs_push_properties(true); 3739 grandchild2_->set_persist_needs_push_properties(true);
3725 break; 3740 break;
3726 case 1: 3741 case 1:
3727 EXPECT_FALSE(root_->needs_push_properties()); 3742 EXPECT_FALSE(root_->needs_push_properties());
3728 EXPECT_TRUE(root_->descendant_needs_push_properties()); 3743 EXPECT_TRUE(root_->descendant_needs_push_properties());
(...skipping 27 matching lines...) Expand all
3756 } 3771 }
3757 } 3772 }
3758 }; 3773 };
3759 3774
3760 MULTI_THREAD_TEST_F( 3775 MULTI_THREAD_TEST_F(
3761 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence); 3776 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence);
3762 3777
3763 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree 3778 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
3764 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3779 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3765 protected: 3780 protected:
3766 virtual void DidCommitAndDrawFrame() OVERRIDE { 3781 virtual void DidCommit() OVERRIDE {
3767 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3782 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3768 switch (last_source_frame_number) { 3783 switch (last_source_frame_number) {
3769 case 0: 3784 case 0:
3770 layer_tree_host()->SetRootLayer(root_); 3785 layer_tree_host()->SetRootLayer(root_);
3771 break; 3786 break;
3772 case 1: 3787 case 1:
3773 EXPECT_FALSE(root_->needs_push_properties()); 3788 EXPECT_FALSE(root_->needs_push_properties());
3774 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3789 EXPECT_FALSE(root_->descendant_needs_push_properties());
3775 EXPECT_FALSE(child_->needs_push_properties()); 3790 EXPECT_FALSE(child_->needs_push_properties());
3776 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3791 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3824 } 3839 }
3825 } 3840 }
3826 }; 3841 };
3827 3842
3828 MULTI_THREAD_TEST_F( 3843 MULTI_THREAD_TEST_F(
3829 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree); 3844 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree);
3830 3845
3831 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild 3846 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
3832 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3847 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3833 protected: 3848 protected:
3834 virtual void DidCommitAndDrawFrame() OVERRIDE { 3849 virtual void DidCommit() OVERRIDE {
3835 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3850 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3836 switch (last_source_frame_number) { 3851 switch (last_source_frame_number) {
3837 case 0: 3852 case 0:
3838 layer_tree_host()->SetRootLayer(root_); 3853 layer_tree_host()->SetRootLayer(root_);
3839 break; 3854 break;
3840 case 1: 3855 case 1:
3841 EXPECT_FALSE(root_->needs_push_properties()); 3856 EXPECT_FALSE(root_->needs_push_properties());
3842 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3857 EXPECT_FALSE(root_->descendant_needs_push_properties());
3843 EXPECT_FALSE(child_->needs_push_properties()); 3858 EXPECT_FALSE(child_->needs_push_properties());
3844 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3859 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3888 } 3903 }
3889 } 3904 }
3890 }; 3905 };
3891 3906
3892 MULTI_THREAD_TEST_F( 3907 MULTI_THREAD_TEST_F(
3893 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild); 3908 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild);
3894 3909
3895 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent 3910 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
3896 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3911 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3897 protected: 3912 protected:
3898 virtual void DidCommitAndDrawFrame() OVERRIDE { 3913 virtual void DidCommit() OVERRIDE {
3899 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3914 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3900 switch (last_source_frame_number) { 3915 switch (last_source_frame_number) {
3901 case 0: 3916 case 0:
3902 layer_tree_host()->SetRootLayer(root_); 3917 layer_tree_host()->SetRootLayer(root_);
3903 break; 3918 break;
3904 case 1: 3919 case 1:
3905 EXPECT_FALSE(root_->needs_push_properties()); 3920 EXPECT_FALSE(root_->needs_push_properties());
3906 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3921 EXPECT_FALSE(root_->descendant_needs_push_properties());
3907 EXPECT_FALSE(child_->needs_push_properties()); 3922 EXPECT_FALSE(child_->needs_push_properties());
3908 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3923 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
4273 int num_will_begin_frames_; 4288 int num_will_begin_frames_;
4274 int num_impl_commits_; 4289 int num_impl_commits_;
4275 }; 4290 };
4276 4291
4277 // Commits can only be aborted when using the thread proxy. 4292 // Commits can only be aborted when using the thread proxy.
4278 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4293 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4279 4294
4280 } // namespace 4295 } // namespace
4281 4296
4282 } // namespace cc 4297 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698