Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 12676029: cc: Fix capitalization style in chromified files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/fake_content_layer.h" 12 #include "cc/test/fake_content_layer.h"
13 #include "cc/test/fake_content_layer_client.h" 13 #include "cc/test/fake_content_layer_client.h"
14 #include "cc/test/layer_tree_test.h" 14 #include "cc/test/layer_tree_test.h"
15 15
16 namespace cc { 16 namespace cc {
17 namespace { 17 namespace {
18 18
19 class LayerTreeHostAnimationTest : public LayerTreeTest { 19 class LayerTreeHostAnimationTest : public LayerTreeTest {
20 public: 20 public:
21 virtual void SetupTree() OVERRIDE { 21 virtual void SetupTree() OVERRIDE {
22 LayerTreeTest::SetupTree(); 22 LayerTreeTest::SetupTree();
23 layer_tree_host()->root_layer()->set_layer_animation_delegate(this); 23 layer_tree_host()->root_layer()->set_layer_animation_delegate(this);
24 } 24 }
25 }; 25 };
26 26
27 // Makes sure that setNeedsAnimate does not cause the commitRequested() state to 27 // Makes sure that SetNeedsAnimate does not cause the CommitRequested() state to
28 // be set. 28 // be set.
29 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested : 29 class LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested :
30 public LayerTreeHostAnimationTest { 30 public LayerTreeHostAnimationTest {
31 public: 31 public:
32 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested() 32 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested()
33 : num_commits_(0) { 33 : num_commits_(0) {
34 } 34 }
35 35
36 virtual void BeginTest() OVERRIDE { 36 virtual void BeginTest() OVERRIDE {
37 PostSetNeedsCommitToMainThread(); 37 PostSetNeedsCommitToMainThread();
38 } 38 }
39 39
40 virtual void Animate(base::TimeTicks monotonicTime) OVERRIDE { 40 virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE {
41 // We skip the first commit becasue its the commit that populates the 41 // We skip the first commit becasue its the commit that populates the
42 // impl thread with a tree. After the second commit, the test is done. 42 // impl thread with a tree. After the second commit, the test is done.
43 if (num_commits_ != 1) 43 if (num_commits_ != 1)
44 return; 44 return;
45 45
46 layer_tree_host()->SetNeedsAnimate(); 46 layer_tree_host()->SetNeedsAnimate();
47 // Right now, commitRequested is going to be true, because during 47 // Right now, CommitRequested is going to be true, because during
48 // beginFrame, we force commitRequested to true to prevent requests from 48 // BeginFrame, we force CommitRequested to true to prevent requests from
49 // hitting the impl thread. But, when the next didCommit happens, we should 49 // hitting the impl thread. But, when the next DidCommit happens, we should
50 // verify that commitRequested has gone back to false. 50 // verify that CommitRequested has gone back to false.
51 } 51 }
52 52
53 virtual void DidCommit() OVERRIDE { 53 virtual void DidCommit() OVERRIDE {
54 if (!num_commits_) { 54 if (!num_commits_) {
55 EXPECT_FALSE(layer_tree_host()->CommitRequested()); 55 EXPECT_FALSE(layer_tree_host()->CommitRequested());
56 layer_tree_host()->SetNeedsAnimate(); 56 layer_tree_host()->SetNeedsAnimate();
57 EXPECT_FALSE(layer_tree_host()->CommitRequested()); 57 EXPECT_FALSE(layer_tree_host()->CommitRequested());
58 } 58 }
59 59
60 // Verifies that the setNeedsAnimate we made in ::animate did not 60 // Verifies that the SetNeedsAnimate we made in ::animate did not
61 // trigger commitRequested. 61 // trigger CommitRequested.
62 EXPECT_FALSE(layer_tree_host()->CommitRequested()); 62 EXPECT_FALSE(layer_tree_host()->CommitRequested());
63 EndTest(); 63 EndTest();
64 num_commits_++; 64 num_commits_++;
65 } 65 }
66 66
67 virtual void AfterTest() OVERRIDE {} 67 virtual void AfterTest() OVERRIDE {}
68 68
69 private: 69 private:
70 int num_commits_; 70 int num_commits_;
71 }; 71 };
72 72
73 MULTI_THREAD_TEST_F( 73 MULTI_THREAD_TEST_F(
74 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested) 74 LayerTreeHostAnimationTestSetNeedsAnimateShouldNotSetCommitRequested)
75 75
76 // Trigger a frame with setNeedsCommit. Then, inside the resulting animate 76 // Trigger a frame with SetNeedsCommit. Then, inside the resulting animate
77 // callback, requet another frame using setNeedsAnimate. End the test when 77 // callback, requet another frame using SetNeedsAnimate. End the test when
78 // animate gets called yet-again, indicating that the proxy is correctly 78 // animate gets called yet-again, indicating that the proxy is correctly
79 // handling the case where setNeedsAnimate() is called inside the begin frame 79 // handling the case where SetNeedsAnimate() is called inside the begin frame
80 // flow. 80 // flow.
81 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback : 81 class LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback :
82 public LayerTreeHostAnimationTest { 82 public LayerTreeHostAnimationTest {
83 public: 83 public:
84 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback() 84 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback()
85 : num_animates_(0) { 85 : num_animates_(0) {
86 } 86 }
87 87
88 virtual void BeginTest() OVERRIDE { 88 virtual void BeginTest() OVERRIDE {
89 PostSetNeedsCommitToMainThread(); 89 PostSetNeedsCommitToMainThread();
(...skipping 11 matching lines...) Expand all
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 LayerTreeHostAnimationTestSetNeedsAnimateInsideAnimationCallback)
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)
119 , start_time_(0) { 119 , start_time_(0) {
120 } 120 }
121 121
122 virtual void BeginTest() OVERRIDE { 122 virtual void BeginTest() OVERRIDE {
123 PostAddInstantAnimationToMainThread(); 123 PostAddInstantAnimationToMainThread();
124 } 124 }
125 125
126 virtual void UpdateAnimationState( 126 virtual void UpdateAnimationState(
127 LayerTreeHostImpl* impl_host, 127 LayerTreeHostImpl* impl_host,
128 bool hasUnfinishedAnimation) OVERRIDE { 128 bool has_unfinished_animation) OVERRIDE {
129 if (!num_animates_) { 129 if (!num_animates_) {
130 // The animation had zero duration so layerTreeHostImpl should no 130 // The animation had zero duration so LayerTreeHostImpl should no
131 // longer need to animate its layers. 131 // longer need to animate its layers.
132 EXPECT_FALSE(hasUnfinishedAnimation); 132 EXPECT_FALSE(has_unfinished_animation);
133 num_animates_++; 133 num_animates_++;
134 return; 134 return;
135 } 135 }
136 136
137 if (received_animation_started_notification_) { 137 if (received_animation_started_notification_) {
138 EXPECT_LT(0, start_time_); 138 EXPECT_LT(0, start_time_);
139 EndTest(); 139 EndTest();
140 } 140 }
141 } 141 }
142 142
(...skipping 24 matching lines...) Expand all
167 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws() 167 LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws()
168 : started_animating_(false) { 168 : started_animating_(false) {
169 } 169 }
170 170
171 virtual void BeginTest() OVERRIDE { 171 virtual void BeginTest() OVERRIDE {
172 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 172 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
173 } 173 }
174 174
175 virtual void AnimateLayers( 175 virtual void AnimateLayers(
176 LayerTreeHostImpl* host_impl, 176 LayerTreeHostImpl* host_impl,
177 base::TimeTicks monotonicTime) OVERRIDE { 177 base::TimeTicks monotonic_time) OVERRIDE {
178 started_animating_ = true; 178 started_animating_ = true;
179 } 179 }
180 180
181 virtual void DrawLayersOnThread(LayerTreeHostImpl*) OVERRIDE { 181 virtual void DrawLayersOnThread(LayerTreeHostImpl*) OVERRIDE {
182 if (started_animating_) 182 if (started_animating_)
183 EndTest(); 183 EndTest();
184 } 184 }
185 185
186 virtual bool PrepareToDrawOnThread( 186 virtual bool PrepareToDrawOnThread(
187 LayerTreeHostImpl* host_impl, 187 LayerTreeHostImpl* host_impl,
(...skipping 16 matching lines...) Expand all
204 public LayerTreeHostAnimationTest { 204 public LayerTreeHostAnimationTest {
205 public: 205 public:
206 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded() 206 LayerTreeHostAnimationTestTickAnimationWhileBackgrounded()
207 : num_animates_(0) { 207 : num_animates_(0) {
208 } 208 }
209 209
210 virtual void BeginTest() OVERRIDE { 210 virtual void BeginTest() OVERRIDE {
211 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 211 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
212 } 212 }
213 213
214 // Use willAnimateLayers to set visible false before the animation runs and 214 // Use WillAnimateLayers to set visible false before the animation runs and
215 // causes a commit, so we block the second visible animate in single-thread 215 // causes a commit, so we block the second visible animate in single-thread
216 // mode. 216 // mode.
217 virtual void WillAnimateLayers( 217 virtual void WillAnimateLayers(
218 LayerTreeHostImpl* host_impl, 218 LayerTreeHostImpl* host_impl,
219 base::TimeTicks monotonicTime) OVERRIDE { 219 base::TimeTicks monotonic_time) OVERRIDE {
220 if (num_animates_ < 2) { 220 if (num_animates_ < 2) {
221 if (!num_animates_) { 221 if (!num_animates_) {
222 // We have a long animation running. It should continue to tick even 222 // We have a long animation running. It should continue to tick even
223 // if we are not visible. 223 // if we are not visible.
224 PostSetVisibleToMainThread(false); 224 PostSetVisibleToMainThread(false);
225 } 225 }
226 num_animates_++; 226 num_animates_++;
227 return; 227 return;
228 } 228 }
229 EndTest(); 229 EndTest();
(...skipping 13 matching lines...) Expand all
243 public LayerTreeHostAnimationTest { 243 public LayerTreeHostAnimationTest {
244 public: 244 public:
245 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {} 245 LayerTreeHostAnimationTestAddAnimationWithTimingFunction() {}
246 246
247 virtual void BeginTest() OVERRIDE { 247 virtual void BeginTest() OVERRIDE {
248 PostAddAnimationToMainThread(layer_tree_host()->root_layer()); 248 PostAddAnimationToMainThread(layer_tree_host()->root_layer());
249 } 249 }
250 250
251 virtual void AnimateLayers( 251 virtual void AnimateLayers(
252 LayerTreeHostImpl* host_impl, 252 LayerTreeHostImpl* host_impl,
253 base::TimeTicks monotonicTime) OVERRIDE { 253 base::TimeTicks monotonic_time) OVERRIDE {
254 LayerAnimationController* controller = 254 LayerAnimationController* controller =
255 layer_tree_host()->root_layer()->layer_animation_controller(); 255 layer_tree_host()->root_layer()->layer_animation_controller();
256 Animation* animation = 256 Animation* animation =
257 controller->GetAnimation(0, Animation::Opacity); 257 controller->GetAnimation(0, Animation::Opacity);
258 if (!animation) 258 if (!animation)
259 return; 259 return;
260 260
261 const FloatAnimationCurve* curve = 261 const FloatAnimationCurve* curve =
262 animation->curve()->ToFloatAnimationCurve(); 262 animation->curve()->ToFloatAnimationCurve();
263 float startOpacity = curve->GetValue(0); 263 float start_opacity = curve->GetValue(0);
264 float endOpacity = curve->GetValue(curve->Duration()); 264 float end_opacity = curve->GetValue(curve->Duration());
265 float linearly_interpolated_opacity = 265 float linearly_interpolated_opacity =
266 0.25 * endOpacity + 0.75 * startOpacity; 266 0.25 * end_opacity + 0.75 * start_opacity;
267 double time = curve->Duration() * 0.25; 267 double time = curve->Duration() * 0.25;
268 // If the linear timing function associated with this animation was not 268 // If the linear timing function associated with this animation was not
269 // picked up, then the linearly interpolated opacity would be different 269 // picked up, then the linearly interpolated opacity would be different
270 // because of the default ease timing function. 270 // because of the default ease timing function.
271 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time)); 271 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->GetValue(time));
272 272
273 LayerAnimationController* controller_impl = 273 LayerAnimationController* controller_impl =
274 host_impl->RootLayer()->layer_animation_controller(); 274 host_impl->RootLayer()->layer_animation_controller();
275 Animation* animation_impl = 275 Animation* animation_impl =
276 controller_impl->GetAnimation(0, Animation::Opacity); 276 controller_impl->GetAnimation(0, Animation::Opacity);
(...skipping 30 matching lines...) Expand all
307 controller->GetAnimation(0, Animation::Opacity); 307 controller->GetAnimation(0, Animation::Opacity);
308 main_start_time_ = animation->start_time(); 308 main_start_time_ = animation->start_time();
309 controller->RemoveAnimation(animation->id()); 309 controller->RemoveAnimation(animation->id());
310 310
311 if (impl_start_time_ > 0) 311 if (impl_start_time_ > 0)
312 EndTest(); 312 EndTest();
313 } 313 }
314 314
315 virtual void UpdateAnimationState( 315 virtual void UpdateAnimationState(
316 LayerTreeHostImpl* impl_host, 316 LayerTreeHostImpl* impl_host,
317 bool hasUnfinishedAnimation) OVERRIDE { 317 bool has_unfinished_animation) OVERRIDE {
318 LayerAnimationController* controller = 318 LayerAnimationController* controller =
319 impl_host->RootLayer()->layer_animation_controller(); 319 impl_host->RootLayer()->layer_animation_controller();
320 Animation* animation = 320 Animation* animation =
321 controller->GetAnimation(0, Animation::Opacity); 321 controller->GetAnimation(0, Animation::Opacity);
322 if (!animation) 322 if (!animation)
323 return; 323 return;
324 324
325 impl_start_time_ = animation->start_time(); 325 impl_start_time_ = animation->start_time();
326 controller->RemoveAnimation(animation->id()); 326 controller->RemoveAnimation(animation->id());
327 327
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 LayerTreeHostAnimationTestLayerAddedWithAnimation) 448 LayerTreeHostAnimationTestLayerAddedWithAnimation)
449 449
450 class LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount : 450 class LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount :
451 public LayerTreeHostAnimationTest { 451 public LayerTreeHostAnimationTest {
452 public: 452 public:
453 LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount() 453 LayerTreeHostAnimationTestCompositeAndReadbackAnimateCount()
454 : animated_commit_(-1) { 454 : animated_commit_(-1) {
455 } 455 }
456 456
457 virtual void Animate(base::TimeTicks) OVERRIDE { 457 virtual void Animate(base::TimeTicks) OVERRIDE {
458 // We shouldn't animate on the compositeAndReadback-forced commit, but we 458 // We shouldn't animate on the CompositeAndReadback-forced commit, but we
459 // should for the setNeedsCommit-triggered commit. 459 // should for the SetNeedsCommit-triggered commit.
460 animated_commit_ = layer_tree_host()->commit_number(); 460 animated_commit_ = layer_tree_host()->commit_number();
461 EXPECT_NE(2, animated_commit_); 461 EXPECT_NE(2, animated_commit_);
462 } 462 }
463 463
464 virtual void BeginTest() OVERRIDE { 464 virtual void BeginTest() OVERRIDE {
465 PostSetNeedsCommitToMainThread(); 465 PostSetNeedsCommitToMainThread();
466 } 466 }
467 467
468 virtual void DidCommit() OVERRIDE { 468 virtual void DidCommit() OVERRIDE {
469 switch (layer_tree_host()->commit_number()) { 469 switch (layer_tree_host()->commit_number()) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 537
538 private: 538 private:
539 int num_commit_complete_; 539 int num_commit_complete_;
540 int num_draw_layers_; 540 int num_draw_layers_;
541 }; 541 };
542 542
543 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate) 543 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate)
544 544
545 } // namespace 545 } // namespace
546 } // namespace cc 546 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698