| 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/timing_function.h" | 9 #include "cc/animation/timing_function.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { | 41 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE { |
| 42 // We skip the first commit becasue its the commit that populates the | 42 // We skip the first commit becasue its the commit that populates the |
| 43 // impl thread with a tree. After the second commit, the test is done. | 43 // impl thread with a tree. After the second commit, the test is done. |
| 44 if (num_commits_ != 1) | 44 if (num_commits_ != 1) |
| 45 return; | 45 return; |
| 46 | 46 |
| 47 layer_tree_host()->SetNeedsAnimate(); | 47 layer_tree_host()->SetNeedsAnimate(); |
| 48 // Right now, CommitRequested is going to be true, because during | 48 // Right now, CommitRequested is going to be true, because during |
| 49 // BeginFrame, we force CommitRequested to true to prevent requests from | 49 // BeginMainFrame, we force CommitRequested to true to prevent requests from |
| 50 // hitting the impl thread. But, when the next DidCommit happens, we should | 50 // hitting the impl thread. But, when the next DidCommit happens, we should |
| 51 // verify that CommitRequested has gone back to false. | 51 // verify that CommitRequested has gone back to false. |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void DidCommit() OVERRIDE { | 54 virtual void DidCommit() OVERRIDE { |
| 55 if (!num_commits_) { | 55 if (!num_commits_) { |
| 56 EXPECT_FALSE(layer_tree_host()->CommitRequested()); | 56 EXPECT_FALSE(layer_tree_host()->CommitRequested()); |
| 57 layer_tree_host()->SetNeedsAnimate(); | 57 layer_tree_host()->SetNeedsAnimate(); |
| 58 EXPECT_FALSE(layer_tree_host()->CommitRequested()); | 58 EXPECT_FALSE(layer_tree_host()->CommitRequested()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Verifies that the SetNeedsAnimate we made in ::Animate did not | 61 // Verifies that the SetNeedsAnimate we made in ::Animate did not |
| 62 // trigger CommitRequested. | 62 // trigger CommitRequested. |
| 63 EXPECT_FALSE(layer_tree_host()->CommitRequested()); | 63 EXPECT_FALSE(layer_tree_host()->CommitRequested()); |
| 64 EndTest(); | 64 EndTest(); |
| 65 num_commits_++; | 65 num_commits_++; |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void AfterTest() OVERRIDE {} | 68 virtual void AfterTest() OVERRIDE {} |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 int num_commits_; | 71 int num_commits_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 MULTI_THREAD_TEST_F( | 74 MULTI_THREAD_TEST_F( |
| 75 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested); | 75 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested); |
| 76 | 76 |
| 77 // Trigger a frame with SetNeedsCommit. Then, inside the resulting animate | 77 // Trigger a frame with SetNeedsCommit. Then, inside the resulting animate |
| 78 // callback, requet another frame using SetNeedsAnimate. End the test when | 78 // callback, request another frame using SetNeedsAnimate. End the test when |
| 79 // animate gets called yet-again, indicating that the proxy is correctly | 79 // animate gets called yet-again, indicating that the proxy is correctly |
| 80 // handling the case where SetNeedsAnimate() is called inside the begin frame | 80 // handling the case where SetNeedsAnimate() is called inside the BeginMainFrame |
| 81 // flow. | 81 // flow. |
| 82 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback | 82 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback |
| 83 : public LayerTreeHostAnimationTest { | 83 : public LayerTreeHostAnimationTest { |
| 84 public: | 84 public: |
| 85 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() | 85 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() |
| 86 : num_animates_(0) {} | 86 : num_animates_(0) {} |
| 87 | 87 |
| 88 virtual void BeginTest() OVERRIDE { | 88 virtual void BeginTest() OVERRIDE { |
| 89 PostSetNeedsCommitToMainThread(); | 89 PostSetNeedsCommitToMainThread(); |
| 90 } | 90 } |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 if (TestEnded()) | 754 if (TestEnded()) |
| 755 return result; | 755 return result; |
| 756 // Act like there is checkerboard when the second animation wants to draw. | 756 // Act like there is checkerboard when the second animation wants to draw. |
| 757 ++prevented_draw_; | 757 ++prevented_draw_; |
| 758 return false; | 758 return false; |
| 759 } | 759 } |
| 760 | 760 |
| 761 virtual void DidCommitAndDrawFrame() OVERRIDE { | 761 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 762 switch (layer_tree_host()->commit_number()) { | 762 switch (layer_tree_host()->commit_number()) { |
| 763 case 1: | 763 case 1: |
| 764 // The animation is longer than 1 vsync. | 764 // The animation is longer than 1 BeginImplFrame interval. |
| 765 AddOpacityTransitionToLayer(content_, 0.1, 0.2f, 0.8f, false); | 765 AddOpacityTransitionToLayer(content_, 0.1, 0.2f, 0.8f, false); |
| 766 added_animations_++; | 766 added_animations_++; |
| 767 break; | 767 break; |
| 768 case 2: | 768 case 2: |
| 769 // This second animation will not be drawn so it should not start. | 769 // This second animation will not be drawn so it should not start. |
| 770 AddAnimatedTransformToLayer(content_, 0.1, 5, 5); | 770 AddAnimatedTransformToLayer(content_, 0.1, 5, 5); |
| 771 added_animations_++; | 771 added_animations_++; |
| 772 break; | 772 break; |
| 773 } | 773 } |
| 774 } | 774 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 FakeContentLayerClient client_; | 867 FakeContentLayerClient client_; |
| 868 scoped_refptr<FakeContentLayer> root_layer_; | 868 scoped_refptr<FakeContentLayer> root_layer_; |
| 869 int started_times_; | 869 int started_times_; |
| 870 int num_commit_complete_; | 870 int num_commit_complete_; |
| 871 }; | 871 }; |
| 872 | 872 |
| 873 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestPinchZoomScrollbars); | 873 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestPinchZoomScrollbars); |
| 874 | 874 |
| 875 } // namespace | 875 } // namespace |
| 876 } // namespace cc | 876 } // namespace cc |
| OLD | NEW |