OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } | 522 virtual void AfterTest() OVERRIDE { EXPECT_EQ(5, num_draws_); } |
523 | 523 |
524 private: | 524 private: |
525 int num_draws_; | 525 int num_draws_; |
526 const gfx::Size bounds_; | 526 const gfx::Size bounds_; |
527 const gfx::Rect invalid_rect_; | 527 const gfx::Rect invalid_rect_; |
528 FakeContentLayerClient client_; | 528 FakeContentLayerClient client_; |
529 scoped_refptr<ContentLayer> root_layer_; | 529 scoped_refptr<ContentLayer> root_layer_; |
530 }; | 530 }; |
531 | 531 |
532 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); | 532 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
| 533 LayerTreeHostTestSetNextCommitForcesRedraw); |
533 | 534 |
534 // Tests that if a layer is not drawn because of some reason in the parent then | 535 // Tests that if a layer is not drawn because of some reason in the parent then |
535 // its damage is preserved until the next time it is drawn. | 536 // its damage is preserved until the next time it is drawn. |
536 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { | 537 class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
537 public: | 538 public: |
538 LayerTreeHostTestUndrawnLayersDamageLater() | 539 LayerTreeHostTestUndrawnLayersDamageLater() |
539 : root_layer_(ContentLayer::Create(&client_)) {} | 540 : root_layer_(ContentLayer::Create(&client_)) {} |
540 | 541 |
541 virtual void SetupTree() OVERRIDE { | 542 virtual void SetupTree() OVERRIDE { |
542 root_layer_->SetIsDrawable(true); | 543 root_layer_->SetIsDrawable(true); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 731 |
731 virtual void BeginTest() OVERRIDE { | 732 virtual void BeginTest() OVERRIDE { |
732 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 733 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
733 layer_tree_host()->set_background_color(SK_ColorGRAY); | 734 layer_tree_host()->set_background_color(SK_ColorGRAY); |
734 | 735 |
735 PostSetNeedsCommitToMainThread(); | 736 PostSetNeedsCommitToMainThread(); |
736 } | 737 } |
737 | 738 |
738 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 739 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
739 EXPECT_EQ(frame_count_with_pending_tree_, 0); | 740 EXPECT_EQ(frame_count_with_pending_tree_, 0); |
740 impl->BlockNotifyReadyToActivateForTesting(true); | 741 if (impl->settings().impl_side_painting) |
| 742 impl->BlockNotifyReadyToActivateForTesting(true); |
741 } | 743 } |
742 | 744 |
743 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | 745 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, |
744 const BeginFrameArgs& args) OVERRIDE { | 746 const BeginFrameArgs& args) OVERRIDE { |
745 if (impl->pending_tree()) | 747 if (impl->pending_tree()) |
746 frame_count_with_pending_tree_++; | 748 frame_count_with_pending_tree_++; |
747 | 749 |
748 if (frame_count_with_pending_tree_ == 1) { | 750 if (frame_count_with_pending_tree_ == 1) { |
749 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); | 751 EXPECT_EQ(first_frame_time_.ToInternalValue(), 0); |
750 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; | 752 first_frame_time_ = impl->CurrentBeginFrameArgs().frame_time; |
751 } else if (frame_count_with_pending_tree_ == 2) { | 753 } else if (frame_count_with_pending_tree_ == 2 && |
| 754 impl->settings().impl_side_painting) { |
752 impl->BlockNotifyReadyToActivateForTesting(false); | 755 impl->BlockNotifyReadyToActivateForTesting(false); |
753 } | 756 } |
754 } | 757 } |
755 | 758 |
756 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 759 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
757 if (frame_count_with_pending_tree_ > 1) { | 760 if (frame_count_with_pending_tree_ > 1) { |
758 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); | 761 EXPECT_NE(first_frame_time_.ToInternalValue(), 0); |
759 EXPECT_NE(first_frame_time_.ToInternalValue(), | 762 EXPECT_NE(first_frame_time_.ToInternalValue(), |
760 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); | 763 impl->CurrentBeginFrameArgs().frame_time.ToInternalValue()); |
761 EndTest(); | 764 EndTest(); |
762 return; | 765 return; |
763 } | 766 } |
764 | 767 |
765 EXPECT_FALSE(impl->settings().impl_side_painting); | 768 EXPECT_FALSE(impl->settings().impl_side_painting); |
766 EndTest(); | 769 EndTest(); |
767 } | 770 } |
768 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 771 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
769 if (impl->settings().impl_side_painting) | 772 if (impl->settings().impl_side_painting) |
770 EXPECT_NE(frame_count_with_pending_tree_, 1); | 773 EXPECT_NE(frame_count_with_pending_tree_, 1); |
771 } | 774 } |
772 | 775 |
773 virtual void AfterTest() OVERRIDE {} | 776 virtual void AfterTest() OVERRIDE {} |
774 | 777 |
775 private: | 778 private: |
776 int frame_count_with_pending_tree_; | 779 int frame_count_with_pending_tree_; |
777 base::TimeTicks first_frame_time_; | 780 base::TimeTicks first_frame_time_; |
778 }; | 781 }; |
779 | 782 |
780 SINGLE_AND_MULTI_THREAD_TEST_F( | 783 SINGLE_AND_MULTI_THREAD_BLOCKNOTIFY_TEST_F( |
781 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); | 784 LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); |
782 | 785 |
783 // This test verifies that LayerTreeHostImpl's current frame time gets | 786 // This test verifies that LayerTreeHostImpl's current frame time gets |
784 // updated in consecutive frames when it draws in each frame. | 787 // updated in consecutive frames when it draws in each frame. |
785 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { | 788 class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { |
786 public: | 789 public: |
787 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} | 790 LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} |
788 | 791 |
789 virtual void BeginTest() OVERRIDE { | 792 virtual void BeginTest() OVERRIDE { |
790 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); | 793 layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2398 | 2401 |
2399 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } | 2402 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } |
2400 | 2403 |
2401 private: | 2404 private: |
2402 Layer* layer_; | 2405 Layer* layer_; |
2403 }; | 2406 }; |
2404 | 2407 |
2405 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} | 2408 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} |
2406 | 2409 |
2407 virtual void SetupTree() OVERRIDE { | 2410 virtual void SetupTree() OVERRIDE { |
2408 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); | 2411 if (layer_tree_host()->settings().impl_side_painting) { |
| 2412 scoped_refptr<PictureLayer> root_layer = PictureLayer::Create(&client_); |
| 2413 layer_tree_host()->SetRootLayer(root_layer); |
| 2414 } else { |
| 2415 scoped_refptr<ContentLayer> root_layer = ContentLayer::Create(&client_); |
| 2416 layer_tree_host()->SetRootLayer(root_layer); |
| 2417 } |
| 2418 Layer* root_layer = layer_tree_host()->root_layer(); |
2409 root_layer->SetIsDrawable(true); | 2419 root_layer->SetIsDrawable(true); |
2410 root_layer->SetBounds(gfx::Size(1, 1)); | 2420 root_layer->SetBounds(gfx::Size(1, 1)); |
2411 | 2421 |
2412 layer_tree_host()->SetRootLayer(root_layer); | 2422 client_.set_layer(root_layer); |
2413 client_.set_layer(root_layer.get()); | |
2414 | 2423 |
2415 LayerTreeHostTest::SetupTree(); | 2424 LayerTreeHostTest::SetupTree(); |
2416 } | 2425 } |
2417 | 2426 |
2418 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 2427 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
2419 virtual void AfterTest() OVERRIDE {} | 2428 virtual void AfterTest() OVERRIDE {} |
2420 | 2429 |
2421 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 2430 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
2422 num_commits_++; | 2431 num_commits_++; |
2423 if (num_commits_ == 1) { | 2432 if (num_commits_ == 1) { |
2424 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | 2433 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); |
2425 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); | 2434 EXPECT_SIZE_EQ(gfx::Size(1, 1), root_layer->bounds()); |
2426 } else { | 2435 } else { |
2427 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); | 2436 LayerImpl* root_layer = host_impl->active_tree()->root_layer(); |
2428 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); | 2437 EXPECT_SIZE_EQ(gfx::Size(2, 2), root_layer->bounds()); |
2429 EndTest(); | 2438 EndTest(); |
2430 } | 2439 } |
2431 } | 2440 } |
2432 | 2441 |
2433 private: | 2442 private: |
2434 SetBoundsClient client_; | 2443 SetBoundsClient client_; |
2435 int num_commits_; | 2444 int num_commits_; |
2436 }; | 2445 }; |
2437 | 2446 |
2438 SINGLE_THREAD_TEST_F(LayerTreeHostTestChangeLayerPropertiesInPaintContents); | 2447 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 2448 LayerTreeHostTestChangeLayerPropertiesInPaintContents); |
2439 | 2449 |
2440 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { | 2450 class MockIOSurfaceWebGraphicsContext3D : public TestWebGraphicsContext3D { |
2441 public: | 2451 public: |
2442 MockIOSurfaceWebGraphicsContext3D() { | 2452 MockIOSurfaceWebGraphicsContext3D() { |
2443 test_capabilities_.gpu.iosurface = true; | 2453 test_capabilities_.gpu.iosurface = true; |
2444 test_capabilities_.gpu.texture_rectangle = true; | 2454 test_capabilities_.gpu.texture_rectangle = true; |
2445 } | 2455 } |
2446 | 2456 |
2447 virtual GLuint createTexture() OVERRIDE { | 2457 virtual GLuint createTexture() OVERRIDE { |
2448 return 1; | 2458 return 1; |
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5072 bool visible_; | 5082 bool visible_; |
5073 | 5083 |
5074 FakeContentLayerClient client_; | 5084 FakeContentLayerClient client_; |
5075 scoped_refptr<FakePictureLayer> picture_layer_; | 5085 scoped_refptr<FakePictureLayer> picture_layer_; |
5076 }; | 5086 }; |
5077 | 5087 |
5078 // TODO(vmpstr): Enable with single thread impl-side painting. | 5088 // TODO(vmpstr): Enable with single thread impl-side painting. |
5079 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); | 5089 MULTI_THREAD_TEST_F(LayerTreeHostTestActivateOnInvisible); |
5080 | 5090 |
5081 } // namespace cc | 5091 } // namespace cc |
OLD | NEW |