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" |
11 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
12 #include "cc/test/animation_test_common.h" | 12 #include "cc/test/animation_test_common.h" |
13 #include "cc/test/fake_content_layer.h" | 13 #include "cc/test/fake_content_layer.h" |
14 #include "cc/test/fake_content_layer_client.h" | 14 #include "cc/test/fake_content_layer_client.h" |
15 #include "cc/test/layer_tree_test.h" | 15 #include "cc/test/layer_tree_test.h" |
16 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 namespace { | 19 namespace { |
20 | 20 |
21 class LayerTreeHostAnimationTest : public LayerTreeTest { | 21 class LayerTreeHostAnimationTest : public LayerTreeTest { |
22 public: | 22 public: |
23 virtual void SetupTree() OVERRIDE { | 23 virtual void SetupTree() OVERRIDE { |
24 LayerTreeTest::SetupTree(); | 24 LayerTreeTest::SetupTree(); |
25 layer_tree_host()->root_layer()->set_layer_animation_delegate(this); | 25 layer_tree_host()->root_layer()->set_layer_animation_delegate(this); |
26 } | 26 } |
27 }; | 27 }; |
28 | 28 |
29 // Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to | 29 // Makes sure that SetNeedsUpdateLayers does not cause the CommitRequested() |
30 // be set. | 30 // state to be set. |
31 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested | 31 class LayerTreeHostAnimationTestSetNeedsUpdateLayersShouldNotSetCommitRequested |
32 : public LayerTreeHostAnimationTest { | 32 : public LayerTreeHostAnimationTest { |
33 public: | 33 public: |
34 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested() | 34 LayerTreeHostAnimationTestSetNeedsUpdateLayersShouldNotSetCommitRequested() |
35 : num_commits_(0) {} | 35 : num_commits_(0) {} |
36 | 36 |
37 virtual void BeginTest() OVERRIDE { | 37 virtual void BeginTest() OVERRIDE { |
38 PostSetNeedsCommitToMainThread(); | 38 PostSetNeedsCommitToMainThread(); |
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()->SetNeedsUpdateLayers(); |
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 // BeginFrame, 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()->SetNeedsUpdateLayers(); |
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 SetNeedsUpdateLayers 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 LayerTreeHostAnimationTestSetNeedsUpdateLayersShouldNotSetCommitRequested); |
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, request another frame using SetNeedsAnimate. End the test when | 78 // callback, request another frame using SetNeedsUpdateLayers. 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 BeginFrame | 80 // handling the case where SetNeedsUpdateLayers() is called inside the |
81 // flow. | 81 // BeginFrame flow. |
82 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback | 82 class LayerTreeHostAnimationTestSetNeedsUpdateLayersInsideAnimationCallback |
83 : public LayerTreeHostAnimationTest { | 83 : public LayerTreeHostAnimationTest { |
84 public: | 84 public: |
85 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() | 85 LayerTreeHostAnimationTestSetNeedsUpdateLayersInsideAnimationCallback() |
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 } |
91 | 91 |
92 virtual void Animate(base::TimeTicks) OVERRIDE { | 92 virtual void Animate(base::TimeTicks) OVERRIDE { |
93 if (!num_animates_) { | 93 if (!num_animates_) { |
94 layer_tree_host()->SetNeedsAnimate(); | 94 layer_tree_host()->SetNeedsUpdateLayers(); |
95 num_animates_++; | 95 num_animates_++; |
96 return; | 96 return; |
97 } | 97 } |
98 EndTest(); | 98 EndTest(); |
99 } | 99 } |
100 | 100 |
101 virtual void AfterTest() OVERRIDE {} | 101 virtual void AfterTest() OVERRIDE {} |
102 | 102 |
103 private: | 103 private: |
104 int num_animates_; | 104 int num_animates_; |
105 }; | 105 }; |
106 | 106 |
107 MULTI_THREAD_TEST_F( | 107 MULTI_THREAD_TEST_F( |
108 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback); | 108 LayerTreeHostAnimationTestSetNeedsUpdateLayersInsideAnimationCallback); |
109 | 109 |
110 // Add a layer animation and confirm that | 110 // Add a layer animation and confirm that |
111 // LayerTreeHostImpl::updateAnimationState does get called and continues to | 111 // LayerTreeHostImpl::updateAnimationState does get called and continues to |
112 // get called. | 112 // get called. |
113 class LayerTreeHostAnimationTestAddAnimation | 113 class LayerTreeHostAnimationTestAddAnimation |
114 : public LayerTreeHostAnimationTest { | 114 : public LayerTreeHostAnimationTest { |
115 public: | 115 public: |
116 LayerTreeHostAnimationTestAddAnimation() | 116 LayerTreeHostAnimationTestAddAnimation() |
117 : num_animates_(0), | 117 : num_animates_(0), |
118 received_animation_started_notification_(false), | 118 received_animation_started_notification_(false), |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 num_draw_layers_(0) { | 713 num_draw_layers_(0) { |
714 } | 714 } |
715 | 715 |
716 virtual void BeginTest() OVERRIDE { | 716 virtual void BeginTest() OVERRIDE { |
717 PostSetNeedsCommitToMainThread(); | 717 PostSetNeedsCommitToMainThread(); |
718 } | 718 } |
719 | 719 |
720 virtual void Animate(base::TimeTicks) OVERRIDE { | 720 virtual void Animate(base::TimeTicks) OVERRIDE { |
721 if (num_draw_layers_ == 2) | 721 if (num_draw_layers_ == 2) |
722 return; | 722 return; |
723 layer_tree_host()->SetNeedsAnimate(); | 723 layer_tree_host()->SetNeedsUpdateLayers(); |
724 } | 724 } |
725 | 725 |
726 virtual void Layout() OVERRIDE { | 726 virtual void Layout() OVERRIDE { |
727 layer_tree_host()->root_layer()->SetNeedsDisplay(); | 727 layer_tree_host()->root_layer()->SetNeedsDisplay(); |
728 | |
729 // TODO(trchen): This test is broken. | |
enne (OOO)
2013/11/19 01:48:47
Add a FakeContentLayer and set_needs_always_update
| |
730 // We shouldn't need to request commit here. The commit is supposed to be | |
731 // triggered by tile updates, however mock layers never update tiles. | |
732 layer_tree_host()->SetNeedsCommit(); | |
728 } | 733 } |
729 | 734 |
730 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { | 735 virtual void CommitCompleteOnThread(LayerTreeHostImpl* tree_impl) OVERRIDE { |
731 if (num_draw_layers_ == 1) | 736 if (num_draw_layers_ == 1) |
732 num_commit_complete_++; | 737 num_commit_complete_++; |
733 } | 738 } |
734 | 739 |
735 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 740 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
736 num_draw_layers_++; | 741 num_draw_layers_++; |
737 if (num_draw_layers_ == 2) | 742 if (num_draw_layers_ == 2) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 int finished_times_; | 928 int finished_times_; |
924 FakeContentLayerClient client_; | 929 FakeContentLayerClient client_; |
925 scoped_refptr<FakeContentLayer> content_; | 930 scoped_refptr<FakeContentLayer> content_; |
926 }; | 931 }; |
927 | 932 |
928 MULTI_THREAD_TEST_F( | 933 MULTI_THREAD_TEST_F( |
929 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); | 934 LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations); |
930 | 935 |
931 } // namespace | 936 } // namespace |
932 } // namespace cc | 937 } // namespace cc |
OLD | NEW |