| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_curve.h" | 7 #include "cc/animation/animation_curve.h" |
| 8 #include "cc/animation/layer_animation_controller.h" | 8 #include "cc/animation/layer_animation_controller.h" |
| 9 #include "cc/animation/scroll_offset_animation_curve.h" | 9 #include "cc/animation/scroll_offset_animation_curve.h" |
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 virtual void AfterTest() OVERRIDE {} | 719 virtual void AfterTest() OVERRIDE {} |
| 720 }; | 720 }; |
| 721 | 721 |
| 722 SINGLE_AND_MULTI_THREAD_TEST_F( | 722 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 723 LayerTreeHostAnimationTestLayerAddedWithAnimation); | 723 LayerTreeHostAnimationTestLayerAddedWithAnimation); |
| 724 | 724 |
| 725 class LayerTreeHostAnimationTestContinuousAnimate | 725 class LayerTreeHostAnimationTestContinuousAnimate |
| 726 : public LayerTreeHostAnimationTest { | 726 : public LayerTreeHostAnimationTest { |
| 727 public: | 727 public: |
| 728 LayerTreeHostAnimationTestContinuousAnimate() | 728 LayerTreeHostAnimationTestContinuousAnimate() |
| 729 : num_commit_complete_(0), num_draw_layers_(0), have_animated_(false) {} | 729 : num_commit_complete_(0), |
| 730 num_draw_layers_(0) { |
| 731 } |
| 730 | 732 |
| 731 virtual void SetupTree() OVERRIDE { | 733 virtual void SetupTree() OVERRIDE { |
| 732 LayerTreeHostAnimationTest::SetupTree(); | 734 LayerTreeHostAnimationTest::SetupTree(); |
| 733 // Create a fake content layer so we actually produce new content for every | 735 // Create a fake content layer so we actually produce new content for every |
| 734 // animation frame. | 736 // animation frame. |
| 735 content_ = FakeContentLayer::Create(&client_); | 737 content_ = FakeContentLayer::Create(&client_); |
| 736 content_->set_always_update_resources(true); | 738 content_->set_always_update_resources(true); |
| 737 layer_tree_host()->root_layer()->AddChild(content_); | 739 layer_tree_host()->root_layer()->AddChild(content_); |
| 738 } | 740 } |
| 739 | 741 |
| 740 virtual void BeginTest() OVERRIDE { | 742 virtual void BeginTest() OVERRIDE { |
| 741 PostSetNeedsCommitToMainThread(); | 743 PostSetNeedsCommitToMainThread(); |
| 742 } | 744 } |
| 743 | 745 |
| 744 virtual void Animate(base::TimeTicks) OVERRIDE { | 746 virtual void Animate(base::TimeTicks) OVERRIDE { |
| 745 if (num_draw_layers_ == 2) | 747 if (num_draw_layers_ == 2) |
| 746 return; | 748 return; |
| 747 layer_tree_host()->SetNeedsAnimate(); | 749 layer_tree_host()->SetNeedsAnimate(); |
| 748 have_animated_ = true; | |
| 749 } | 750 } |
| 750 | 751 |
| 751 virtual void Layout() OVERRIDE { | 752 virtual void Layout() OVERRIDE { |
| 752 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 753 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
| 753 } | 754 } |
| 754 | 755 |
| 755 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { | 756 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { |
| 756 if (num_draw_layers_ == 1) | 757 if (num_draw_layers_ == 1) |
| 757 num_commit_complete_++; | 758 num_commit_complete_++; |
| 758 } | 759 } |
| 759 | 760 |
| 760 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 761 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 761 num_draw_layers_++; | 762 num_draw_layers_++; |
| 762 if (num_draw_layers_ == 2) | 763 if (num_draw_layers_ == 2) |
| 763 EndTest(); | 764 EndTest(); |
| 764 } | 765 } |
| 765 | 766 |
| 766 virtual void AfterTest() OVERRIDE { | 767 virtual void AfterTest() OVERRIDE { |
| 767 // Check that we didn't commit twice between first and second draw. | 768 // Check that we didn't commit twice between first and second draw. |
| 768 EXPECT_EQ(1, num_commit_complete_); | 769 EXPECT_EQ(1, num_commit_complete_); |
| 769 EXPECT_TRUE(have_animated_); | |
| 770 } | 770 } |
| 771 | 771 |
| 772 private: | 772 private: |
| 773 int num_commit_complete_; | 773 int num_commit_complete_; |
| 774 int num_draw_layers_; | 774 int num_draw_layers_; |
| 775 bool have_animated_; | |
| 776 FakeContentLayerClient client_; | 775 FakeContentLayerClient client_; |
| 777 scoped_refptr<FakeContentLayer> content_; | 776 scoped_refptr<FakeContentLayer> content_; |
| 778 }; | 777 }; |
| 779 | 778 |
| 780 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); | 779 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); |
| 781 | 780 |
| 782 class LayerTreeHostAnimationTestCancelAnimateCommit | 781 class LayerTreeHostAnimationTestCancelAnimateCommit |
| 783 : public LayerTreeHostAnimationTest { | 782 : public LayerTreeHostAnimationTest { |
| 784 public: | 783 public: |
| 785 LayerTreeHostAnimationTestCancelAnimateCommit() | 784 LayerTreeHostAnimationTestCancelAnimateCommit() |
| 786 : num_animate_calls_(0), num_commit_calls_(0), num_draw_calls_(0) {} | 785 : num_animate_calls_(0), num_commit_calls_(0), num_draw_calls_(0) {} |
| 787 | 786 |
| 788 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 787 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 789 | 788 |
| 790 virtual void Animate(base::TimeTicks) OVERRIDE { | 789 virtual void Animate(base::TimeTicks) OVERRIDE { |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 private: | 1342 private: |
| 1344 scoped_refptr<Layer> content_; | 1343 scoped_refptr<Layer> content_; |
| 1345 int num_swap_buffers_; | 1344 int num_swap_buffers_; |
| 1346 }; | 1345 }; |
| 1347 | 1346 |
| 1348 SINGLE_AND_MULTI_THREAD_TEST_F( | 1347 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1349 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1348 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1350 | 1349 |
| 1351 } // namespace | 1350 } // namespace |
| 1352 } // namespace cc | 1351 } // namespace cc |
| OLD | NEW |