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

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: Improve main thread perf by pushing out deadline if no Impl updates. 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);
enne (OOO) 2013/08/15 19:47:59 I think this isn't what this test is looking for.
brianderson 2013/08/15 23:05:10 I tried to make the code match the comments here (
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) {}
enne (OOO) 2013/08/15 19:47:59 style nit: indentation. Consider 'git cl format'-
brianderson 2013/08/15 23:05:10 Magic! Thanks for the pointer.
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) {
enne (OOO) 2013/08/15 19:47:59 Why do you need two begin frames before the first
brianderson 2013/08/15 23:05:10 I really need to clarify the uses of "BeginFrame"
enne (OOO) 2013/08/16 00:53:22 OH. One confusing begin frame name to rule them a
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 private: 1386 private:
1379 FakeContentLayerClient client_; 1387 FakeContentLayerClient client_;
1380 scoped_refptr<FakeContentLayer> parent_; 1388 scoped_refptr<FakeContentLayer> parent_;
1381 scoped_refptr<FakeContentLayer> child_; 1389 scoped_refptr<FakeContentLayer> child_;
1382 }; 1390 };
1383 1391
1384 // Partial updates are not possible with a delegating renderer. 1392 // Partial updates are not possible with a delegating renderer.
1385 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 1393 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
1386 LayerTreeHostTestAtomicCommitWithPartialUpdate); 1394 LayerTreeHostTestAtomicCommitWithPartialUpdate);
1387 1395
1388 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest { 1396 class LayerTreeHostTestFinishAllRendering : public LayerTreeHostTest {
enne (OOO) 2013/08/15 19:47:59 Since you're updating this, can you add a class-le
brianderson 2013/08/15 23:05:10 I will add a comment.
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) {
enne (OOO) 2013/08/15 19:47:59 It looks like you're changing the memory policy du
brianderson 2013/08/15 23:05:10 My understanding of the memory policy comes from t
brianderson 2013/08/15 23:30:25 @reveman or @vmpstr, can changing the memory polic
enne (OOO) 2013/08/16 00:53:22 Ok. Maybe this could be more robust if when you a
brianderson 2013/08/16 01:20:49 Hmmm. I tried calling ManageTiles after changing t
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 {
enne (OOO) 2013/08/15 19:47:59 I think this change here is right, but this is a b
brianderson 2013/08/15 23:05:10 I will add that check since it would check all com
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,
enne (OOO) 2013/08/15 19:47:59 style nit: indentation.
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 child2_->AddChild(leaf_picture_layer_); 3341 child2_->AddChild(leaf_picture_layer_);
3327 if (leaf_content_layer_) 3342 if (leaf_content_layer_)
3328 child2_->AddChild(leaf_content_layer_); 3343 child2_->AddChild(leaf_content_layer_);
3329 3344
3330 other_root_ = PushPropertiesCountingLayer::Create(); 3345 other_root_ = PushPropertiesCountingLayer::Create();
3331 3346
3332 // Don't set the root layer here. 3347 // Don't set the root layer here.
3333 LayerTreeHostTest::SetupTree(); 3348 LayerTreeHostTest::SetupTree();
3334 } 3349 }
3335 3350
3336 virtual void DidCommitAndDrawFrame() OVERRIDE { 3351 virtual void DidCommit() OVERRIDE {
3337 ++num_commits_; 3352 ++num_commits_;
3338 3353
3339 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 3354 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
3340 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 3355 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
3341 EXPECT_EQ(expected_push_properties_grandchild_, 3356 EXPECT_EQ(expected_push_properties_grandchild_,
3342 grandchild_->push_properties_count()); 3357 grandchild_->push_properties_count());
3343 EXPECT_EQ(expected_push_properties_child2_, 3358 EXPECT_EQ(expected_push_properties_child2_,
3344 child2_->push_properties_count()); 3359 child2_->push_properties_count());
3345 EXPECT_EQ(expected_push_properties_other_root_, 3360 EXPECT_EQ(expected_push_properties_other_root_,
3346 other_root_->push_properties_count()); 3361 other_root_->push_properties_count());
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 bool has_thumb = false; 3535 bool has_thumb = false;
3521 scrollbar_layer_ = 3536 scrollbar_layer_ =
3522 FakeScrollbarLayer::Create(paint_scrollbar, has_thumb, root_->id()); 3537 FakeScrollbarLayer::Create(paint_scrollbar, has_thumb, root_->id());
3523 3538
3524 root_->AddChild(scrollbar_layer_); 3539 root_->AddChild(scrollbar_layer_);
3525 3540
3526 layer_tree_host()->SetRootLayer(root_); 3541 layer_tree_host()->SetRootLayer(root_);
3527 LayerTreeHostTest::SetupTree(); 3542 LayerTreeHostTest::SetupTree();
3528 } 3543 }
3529 3544
3530 virtual void DidCommitAndDrawFrame() OVERRIDE { 3545 virtual void DidCommit() OVERRIDE {
3531 switch (layer_tree_host()->source_frame_number()) { 3546 switch (layer_tree_host()->source_frame_number()) {
3532 case 0: 3547 case 0:
3533 break; 3548 break;
3534 case 1: { 3549 case 1: {
3535 // During update, the ignore_set_needs_commit_ bit is set to true to 3550 // During update, the ignore_set_needs_commit_ bit is set to true to
3536 // avoid causing a second commit to be scheduled. If a property change 3551 // avoid causing a second commit to be scheduled. If a property change
3537 // is made during this, however, it needs to be pushed in the upcoming 3552 // is made during this, however, it needs to be pushed in the upcoming
3538 // commit. 3553 // commit.
3539 scoped_ptr<base::AutoReset<bool> > ignore = 3554 scoped_ptr<base::AutoReset<bool> > ignore =
3540 scrollbar_layer_->IgnoreSetNeedsCommit(); 3555 scrollbar_layer_->IgnoreSetNeedsCommit();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3603 size_t expected_push_properties_root_; 3618 size_t expected_push_properties_root_;
3604 size_t expected_push_properties_child_; 3619 size_t expected_push_properties_child_;
3605 size_t expected_push_properties_grandchild1_; 3620 size_t expected_push_properties_grandchild1_;
3606 size_t expected_push_properties_grandchild2_; 3621 size_t expected_push_properties_grandchild2_;
3607 size_t expected_push_properties_grandchild3_; 3622 size_t expected_push_properties_grandchild3_;
3608 }; 3623 };
3609 3624
3610 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush 3625 class LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush
3611 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3626 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3612 protected: 3627 protected:
3613 virtual void DidCommitAndDrawFrame() OVERRIDE { 3628 virtual void DidCommit() OVERRIDE {
3614 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3629 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3615 switch (last_source_frame_number) { 3630 switch (last_source_frame_number) {
3616 case 0: 3631 case 0:
3617 EXPECT_FALSE(root_->needs_push_properties()); 3632 EXPECT_FALSE(root_->needs_push_properties());
3618 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3633 EXPECT_FALSE(root_->descendant_needs_push_properties());
3619 EXPECT_FALSE(child_->needs_push_properties()); 3634 EXPECT_FALSE(child_->needs_push_properties());
3620 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3635 EXPECT_FALSE(child_->descendant_needs_push_properties());
3621 EXPECT_FALSE(grandchild1_->needs_push_properties()); 3636 EXPECT_FALSE(grandchild1_->needs_push_properties());
3622 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties()); 3637 EXPECT_FALSE(grandchild1_->descendant_needs_push_properties());
3623 EXPECT_FALSE(grandchild2_->needs_push_properties()); 3638 EXPECT_FALSE(grandchild2_->needs_push_properties());
(...skipping 19 matching lines...) Expand all
3643 break; 3658 break;
3644 } 3659 }
3645 } 3660 }
3646 }; 3661 };
3647 3662
3648 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush); 3663 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesAddingToTreeRequiresPush);
3649 3664
3650 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion 3665 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion
3651 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3666 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3652 protected: 3667 protected:
3653 virtual void DidCommitAndDrawFrame() OVERRIDE { 3668 virtual void DidCommit() OVERRIDE {
3654 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3669 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3655 switch (last_source_frame_number) { 3670 switch (last_source_frame_number) {
3656 case 0: 3671 case 0:
3657 layer_tree_host()->SetRootLayer(root_); 3672 layer_tree_host()->SetRootLayer(root_);
3658 break; 3673 break;
3659 case 1: 3674 case 1:
3660 EXPECT_FALSE(root_->needs_push_properties()); 3675 EXPECT_FALSE(root_->needs_push_properties());
3661 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3676 EXPECT_FALSE(root_->descendant_needs_push_properties());
3662 EXPECT_FALSE(child_->needs_push_properties()); 3677 EXPECT_FALSE(child_->needs_push_properties());
3663 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3678 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3726 break; 3741 break;
3727 } 3742 }
3728 } 3743 }
3729 }; 3744 };
3730 3745
3731 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion); 3746 MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesRemovingChildStopsRecursion);
3732 3747
3733 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence 3748 class LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence
3734 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3749 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3735 protected: 3750 protected:
3736 virtual void DidCommitAndDrawFrame() OVERRIDE { 3751 virtual void DidCommit() OVERRIDE {
3737 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3752 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3738 switch (last_source_frame_number) { 3753 switch (last_source_frame_number) {
3739 case 0: 3754 case 0:
3740 layer_tree_host()->SetRootLayer(root_); 3755 layer_tree_host()->SetRootLayer(root_);
3741 grandchild1_->set_persist_needs_push_properties(true); 3756 grandchild1_->set_persist_needs_push_properties(true);
3742 grandchild2_->set_persist_needs_push_properties(true); 3757 grandchild2_->set_persist_needs_push_properties(true);
3743 break; 3758 break;
3744 case 1: 3759 case 1:
3745 EXPECT_FALSE(root_->needs_push_properties()); 3760 EXPECT_FALSE(root_->needs_push_properties());
3746 EXPECT_TRUE(root_->descendant_needs_push_properties()); 3761 EXPECT_TRUE(root_->descendant_needs_push_properties());
(...skipping 27 matching lines...) Expand all
3774 } 3789 }
3775 } 3790 }
3776 }; 3791 };
3777 3792
3778 MULTI_THREAD_TEST_F( 3793 MULTI_THREAD_TEST_F(
3779 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence); 3794 LayerTreeHostTestPushPropertiesRemovingChildStopsRecursionWithPersistence);
3780 3795
3781 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree 3796 class LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree
3782 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3797 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3783 protected: 3798 protected:
3784 virtual void DidCommitAndDrawFrame() OVERRIDE { 3799 virtual void DidCommit() OVERRIDE {
3785 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3800 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3786 switch (last_source_frame_number) { 3801 switch (last_source_frame_number) {
3787 case 0: 3802 case 0:
3788 layer_tree_host()->SetRootLayer(root_); 3803 layer_tree_host()->SetRootLayer(root_);
3789 break; 3804 break;
3790 case 1: 3805 case 1:
3791 EXPECT_FALSE(root_->needs_push_properties()); 3806 EXPECT_FALSE(root_->needs_push_properties());
3792 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3807 EXPECT_FALSE(root_->descendant_needs_push_properties());
3793 EXPECT_FALSE(child_->needs_push_properties()); 3808 EXPECT_FALSE(child_->needs_push_properties());
3794 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3809 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3842 } 3857 }
3843 } 3858 }
3844 }; 3859 };
3845 3860
3846 MULTI_THREAD_TEST_F( 3861 MULTI_THREAD_TEST_F(
3847 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree); 3862 LayerTreeHostTestPushPropertiesSetPropertiesWhileOutsideTree);
3848 3863
3849 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild 3864 class LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild
3850 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3865 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3851 protected: 3866 protected:
3852 virtual void DidCommitAndDrawFrame() OVERRIDE { 3867 virtual void DidCommit() OVERRIDE {
3853 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3868 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3854 switch (last_source_frame_number) { 3869 switch (last_source_frame_number) {
3855 case 0: 3870 case 0:
3856 layer_tree_host()->SetRootLayer(root_); 3871 layer_tree_host()->SetRootLayer(root_);
3857 break; 3872 break;
3858 case 1: 3873 case 1:
3859 EXPECT_FALSE(root_->needs_push_properties()); 3874 EXPECT_FALSE(root_->needs_push_properties());
3860 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3875 EXPECT_FALSE(root_->descendant_needs_push_properties());
3861 EXPECT_FALSE(child_->needs_push_properties()); 3876 EXPECT_FALSE(child_->needs_push_properties());
3862 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3877 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3906 } 3921 }
3907 } 3922 }
3908 }; 3923 };
3909 3924
3910 MULTI_THREAD_TEST_F( 3925 MULTI_THREAD_TEST_F(
3911 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild); 3926 LayerTreeHostTestPushPropertiesSetPropertyInParentThenChild);
3912 3927
3913 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent 3928 class LayerTreeHostTestPushPropertiesSetPropertyInChildThenParent
3914 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren { 3929 : public LayerTreeHostTestCasePushPropertiesThreeGrandChildren {
3915 protected: 3930 protected:
3916 virtual void DidCommitAndDrawFrame() OVERRIDE { 3931 virtual void DidCommit() OVERRIDE {
3917 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1; 3932 int last_source_frame_number = layer_tree_host()->source_frame_number() - 1;
3918 switch (last_source_frame_number) { 3933 switch (last_source_frame_number) {
3919 case 0: 3934 case 0:
3920 layer_tree_host()->SetRootLayer(root_); 3935 layer_tree_host()->SetRootLayer(root_);
3921 break; 3936 break;
3922 case 1: 3937 case 1:
3923 EXPECT_FALSE(root_->needs_push_properties()); 3938 EXPECT_FALSE(root_->needs_push_properties());
3924 EXPECT_FALSE(root_->descendant_needs_push_properties()); 3939 EXPECT_FALSE(root_->descendant_needs_push_properties());
3925 EXPECT_FALSE(child_->needs_push_properties()); 3940 EXPECT_FALSE(child_->needs_push_properties());
3926 EXPECT_FALSE(child_->descendant_needs_push_properties()); 3941 EXPECT_FALSE(child_->descendant_needs_push_properties());
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 int num_will_begin_frames_; 4306 int num_will_begin_frames_;
4292 int num_impl_commits_; 4307 int num_impl_commits_;
4293 }; 4308 };
4294 4309
4295 // Commits can only be aborted when using the thread proxy. 4310 // Commits can only be aborted when using the thread proxy.
4296 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); 4311 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4297 4312
4298 } // namespace 4313 } // namespace
4299 4314
4300 } // namespace cc 4315 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698