| 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), | 729 : num_commit_complete_(0), num_draw_layers_(0), have_animated_(false) {} |
| 730 num_draw_layers_(0) { | |
| 731 } | |
| 732 | 730 |
| 733 virtual void SetupTree() OVERRIDE { | 731 virtual void SetupTree() OVERRIDE { |
| 734 LayerTreeHostAnimationTest::SetupTree(); | 732 LayerTreeHostAnimationTest::SetupTree(); |
| 735 // Create a fake content layer so we actually produce new content for every | 733 // Create a fake content layer so we actually produce new content for every |
| 736 // animation frame. | 734 // animation frame. |
| 737 content_ = FakeContentLayer::Create(&client_); | 735 content_ = FakeContentLayer::Create(&client_); |
| 738 content_->set_always_update_resources(true); | 736 content_->set_always_update_resources(true); |
| 739 layer_tree_host()->root_layer()->AddChild(content_); | 737 layer_tree_host()->root_layer()->AddChild(content_); |
| 740 } | 738 } |
| 741 | 739 |
| 742 virtual void BeginTest() OVERRIDE { | 740 virtual void BeginTest() OVERRIDE { |
| 743 PostSetNeedsCommitToMainThread(); | 741 PostSetNeedsCommitToMainThread(); |
| 744 } | 742 } |
| 745 | 743 |
| 746 virtual void Animate(base::TimeTicks) OVERRIDE { | 744 virtual void Animate(base::TimeTicks) OVERRIDE { |
| 747 if (num_draw_layers_ == 2) | 745 if (num_draw_layers_ == 2) |
| 748 return; | 746 return; |
| 749 layer_tree_host()->SetNeedsAnimate(); | 747 layer_tree_host()->SetNeedsAnimate(); |
| 748 have_animated_ = true; |
| 750 } | 749 } |
| 751 | 750 |
| 752 virtual void Layout() OVERRIDE { | 751 virtual void Layout() OVERRIDE { |
| 753 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 752 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
| 754 } | 753 } |
| 755 | 754 |
| 756 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { | 755 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { |
| 757 if (num_draw_layers_ == 1) | 756 if (num_draw_layers_ == 1) |
| 758 num_commit_complete_++; | 757 num_commit_complete_++; |
| 759 } | 758 } |
| 760 | 759 |
| 761 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 760 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 762 num_draw_layers_++; | 761 num_draw_layers_++; |
| 763 if (num_draw_layers_ == 2) | 762 if (num_draw_layers_ == 2) |
| 764 EndTest(); | 763 EndTest(); |
| 765 } | 764 } |
| 766 | 765 |
| 767 virtual void AfterTest() OVERRIDE { | 766 virtual void AfterTest() OVERRIDE { |
| 768 // Check that we didn't commit twice between first and second draw. | 767 // Check that we didn't commit twice between first and second draw. |
| 769 EXPECT_EQ(1, num_commit_complete_); | 768 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_; |
| 775 FakeContentLayerClient client_; | 776 FakeContentLayerClient client_; |
| 776 scoped_refptr<FakeContentLayer> content_; | 777 scoped_refptr<FakeContentLayer> content_; |
| 777 }; | 778 }; |
| 778 | 779 |
| 779 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); | 780 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate); |
| 780 | 781 |
| 781 class LayerTreeHostAnimationTestCancelAnimateCommit | 782 class LayerTreeHostAnimationTestCancelAnimateCommit |
| 782 : public LayerTreeHostAnimationTest { | 783 : public LayerTreeHostAnimationTest { |
| 783 public: | 784 public: |
| 784 LayerTreeHostAnimationTestCancelAnimateCommit() | 785 LayerTreeHostAnimationTestCancelAnimateCommit() |
| 785 : num_animate_calls_(0), num_commit_calls_(0), num_draw_calls_(0) {} | 786 : num_animate_calls_(0), num_commit_calls_(0), num_draw_calls_(0) {} |
| 786 | 787 |
| 787 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 788 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 788 | 789 |
| 789 virtual void Animate(base::TimeTicks) OVERRIDE { | 790 virtual void Animate(base::TimeTicks) OVERRIDE { |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 private: | 1335 private: |
| 1335 scoped_refptr<Layer> content_; | 1336 scoped_refptr<Layer> content_; |
| 1336 int num_swap_buffers_; | 1337 int num_swap_buffers_; |
| 1337 }; | 1338 }; |
| 1338 | 1339 |
| 1339 SINGLE_AND_MULTI_THREAD_TEST_F( | 1340 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1340 LayerTreeHostAnimationTestAddAnimationAfterAnimating); | 1341 LayerTreeHostAnimationTestAddAnimationAfterAnimating); |
| 1341 | 1342 |
| 1342 } // namespace | 1343 } // namespace |
| 1343 } // namespace cc | 1344 } // namespace cc |
| OLD | NEW |