OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 80 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
81 } | 81 } |
82 | 82 |
83 void UpdateAnimationState(LayerTreeHostImpl* host_impl, | 83 void UpdateAnimationState(LayerTreeHostImpl* host_impl, |
84 bool has_unfinished_animation) override { | 84 bool has_unfinished_animation) override { |
85 EXPECT_FALSE(has_unfinished_animation); | 85 EXPECT_FALSE(has_unfinished_animation); |
86 update_animation_state_was_called_ = true; | 86 update_animation_state_was_called_ = true; |
87 } | 87 } |
88 | 88 |
89 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 89 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
90 Animation::TargetProperty target_property, | 90 AnimationTargetProperty target_property, |
91 int group) override { | 91 int group) override { |
92 EXPECT_LT(base::TimeTicks(), monotonic_time); | 92 EXPECT_LT(base::TimeTicks(), monotonic_time); |
93 | 93 |
94 LayerAnimationController* controller = | 94 LayerAnimationController* controller = |
95 player_->element_animations()->layer_animation_controller(); | 95 player_->element_animations()->layer_animation_controller(); |
96 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 96 Animation* animation = |
| 97 controller->GetAnimation(AnimationTargetProperty::OPACITY); |
97 if (animation) | 98 if (animation) |
98 player_->RemoveAnimation(animation->id()); | 99 player_->RemoveAnimation(animation->id()); |
99 | 100 |
100 EndTest(); | 101 EndTest(); |
101 } | 102 } |
102 | 103 |
103 void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); } | 104 void AfterTest() override { EXPECT_TRUE(update_animation_state_was_called_); } |
104 | 105 |
105 private: | 106 private: |
106 bool update_animation_state_was_called_; | 107 bool update_animation_state_was_called_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (!started_animating_ && have_animations) { | 172 if (!started_animating_ && have_animations) { |
172 started_animating_ = true; | 173 started_animating_ = true; |
173 return; | 174 return; |
174 } | 175 } |
175 | 176 |
176 if (started_animating_ && !have_animations) | 177 if (started_animating_ && !have_animations) |
177 EndTest(); | 178 EndTest(); |
178 } | 179 } |
179 | 180 |
180 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 181 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
181 Animation::TargetProperty target_property, | 182 AnimationTargetProperty target_property, |
182 int group) override { | 183 int group) override { |
183 // Animations on the impl-side controller only get deleted during a commit, | 184 // Animations on the impl-side controller only get deleted during a commit, |
184 // so we need to schedule a commit. | 185 // so we need to schedule a commit. |
185 layer_tree_host()->SetNeedsCommit(); | 186 layer_tree_host()->SetNeedsCommit(); |
186 } | 187 } |
187 | 188 |
188 void AfterTest() override {} | 189 void AfterTest() override {} |
189 | 190 |
190 private: | 191 private: |
191 bool started_animating_; | 192 bool started_animating_; |
(...skipping 29 matching lines...) Expand all Loading... |
221 if (host_impl->sync_tree()->source_frame_number() != 0) | 222 if (host_impl->sync_tree()->source_frame_number() != 0) |
222 return; | 223 return; |
223 | 224 |
224 scoped_refptr<AnimationTimeline> timeline_impl = | 225 scoped_refptr<AnimationTimeline> timeline_impl = |
225 host_impl->animation_host()->GetTimelineById(timeline_id_); | 226 host_impl->animation_host()->GetTimelineById(timeline_id_); |
226 scoped_refptr<AnimationPlayer> player_child_impl = | 227 scoped_refptr<AnimationPlayer> player_child_impl = |
227 timeline_impl->GetPlayerById(player_child_id_); | 228 timeline_impl->GetPlayerById(player_child_id_); |
228 | 229 |
229 LayerAnimationController* controller_impl = | 230 LayerAnimationController* controller_impl = |
230 player_child_impl->element_animations()->layer_animation_controller(); | 231 player_child_impl->element_animations()->layer_animation_controller(); |
231 Animation* animation = controller_impl->GetAnimation(Animation::OPACITY); | 232 Animation* animation = |
| 233 controller_impl->GetAnimation(AnimationTargetProperty::OPACITY); |
232 | 234 |
233 const FloatAnimationCurve* curve = | 235 const FloatAnimationCurve* curve = |
234 animation->curve()->ToFloatAnimationCurve(); | 236 animation->curve()->ToFloatAnimationCurve(); |
235 float start_opacity = curve->GetValue(base::TimeDelta()); | 237 float start_opacity = curve->GetValue(base::TimeDelta()); |
236 float end_opacity = curve->GetValue(curve->Duration()); | 238 float end_opacity = curve->GetValue(curve->Duration()); |
237 float linearly_interpolated_opacity = | 239 float linearly_interpolated_opacity = |
238 0.25f * end_opacity + 0.75f * start_opacity; | 240 0.25f * end_opacity + 0.75f * start_opacity; |
239 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); | 241 base::TimeDelta time = TimeUtil::Scale(curve->Duration(), 0.25f); |
240 // If the linear timing function associated with this animation was not | 242 // If the linear timing function associated with this animation was not |
241 // picked up, then the linearly interpolated opacity would be different | 243 // picked up, then the linearly interpolated opacity would be different |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 AttachPlayersToTimeline(); | 275 AttachPlayersToTimeline(); |
274 player_child_->set_layer_animation_delegate(this); | 276 player_child_->set_layer_animation_delegate(this); |
275 player_child_->AttachLayer(picture_->id()); | 277 player_child_->AttachLayer(picture_->id()); |
276 } | 278 } |
277 | 279 |
278 void BeginTest() override { | 280 void BeginTest() override { |
279 PostAddAnimationToMainThreadPlayer(player_child_.get()); | 281 PostAddAnimationToMainThreadPlayer(player_child_.get()); |
280 } | 282 } |
281 | 283 |
282 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 284 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
283 Animation::TargetProperty target_property, | 285 AnimationTargetProperty target_property, |
284 int group) override { | 286 int group) override { |
285 LayerAnimationController* controller = | 287 LayerAnimationController* controller = |
286 player_child_->element_animations()->layer_animation_controller(); | 288 player_child_->element_animations()->layer_animation_controller(); |
287 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 289 Animation* animation = |
| 290 controller->GetAnimation(AnimationTargetProperty::OPACITY); |
288 main_start_time_ = animation->start_time(); | 291 main_start_time_ = animation->start_time(); |
289 controller->RemoveAnimation(animation->id()); | 292 controller->RemoveAnimation(animation->id()); |
290 EndTest(); | 293 EndTest(); |
291 } | 294 } |
292 | 295 |
293 void UpdateAnimationState(LayerTreeHostImpl* impl_host, | 296 void UpdateAnimationState(LayerTreeHostImpl* impl_host, |
294 bool has_unfinished_animation) override { | 297 bool has_unfinished_animation) override { |
295 scoped_refptr<AnimationTimeline> timeline_impl = | 298 scoped_refptr<AnimationTimeline> timeline_impl = |
296 impl_host->animation_host()->GetTimelineById(timeline_id_); | 299 impl_host->animation_host()->GetTimelineById(timeline_id_); |
297 scoped_refptr<AnimationPlayer> player_child_impl = | 300 scoped_refptr<AnimationPlayer> player_child_impl = |
298 timeline_impl->GetPlayerById(player_child_id_); | 301 timeline_impl->GetPlayerById(player_child_id_); |
299 | 302 |
300 LayerAnimationController* controller = | 303 LayerAnimationController* controller = |
301 player_child_impl->element_animations()->layer_animation_controller(); | 304 player_child_impl->element_animations()->layer_animation_controller(); |
302 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 305 Animation* animation = |
| 306 controller->GetAnimation(AnimationTargetProperty::OPACITY); |
303 if (!animation) | 307 if (!animation) |
304 return; | 308 return; |
305 | 309 |
306 impl_start_time_ = animation->start_time(); | 310 impl_start_time_ = animation->start_time(); |
307 } | 311 } |
308 | 312 |
309 void AfterTest() override { | 313 void AfterTest() override { |
310 EXPECT_EQ(impl_start_time_, main_start_time_); | 314 EXPECT_EQ(impl_start_time_, main_start_time_); |
311 EXPECT_LT(base::TimeTicks(), impl_start_time_); | 315 EXPECT_LT(base::TimeTicks(), impl_start_time_); |
312 } | 316 } |
(...skipping 15 matching lines...) Expand all Loading... |
328 public: | 332 public: |
329 LayerTreeHostTimelinesTestAnimationFinishedEvents() {} | 333 LayerTreeHostTimelinesTestAnimationFinishedEvents() {} |
330 | 334 |
331 void BeginTest() override { | 335 void BeginTest() override { |
332 AttachPlayersToTimeline(); | 336 AttachPlayersToTimeline(); |
333 player_->AttachLayer(layer_tree_host()->root_layer()->id()); | 337 player_->AttachLayer(layer_tree_host()->root_layer()->id()); |
334 PostAddInstantAnimationToMainThreadPlayer(player_.get()); | 338 PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
335 } | 339 } |
336 | 340 |
337 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 341 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
338 Animation::TargetProperty target_property, | 342 AnimationTargetProperty target_property, |
339 int group) override { | 343 int group) override { |
340 LayerAnimationController* controller = | 344 LayerAnimationController* controller = |
341 player_->element_animations()->layer_animation_controller(); | 345 player_->element_animations()->layer_animation_controller(); |
342 Animation* animation = controller->GetAnimation(Animation::OPACITY); | 346 Animation* animation = |
| 347 controller->GetAnimation(AnimationTargetProperty::OPACITY); |
343 if (animation) | 348 if (animation) |
344 controller->RemoveAnimation(animation->id()); | 349 controller->RemoveAnimation(animation->id()); |
345 EndTest(); | 350 EndTest(); |
346 } | 351 } |
347 | 352 |
348 void AfterTest() override {} | 353 void AfterTest() override {} |
349 }; | 354 }; |
350 | 355 |
351 SINGLE_AND_MULTI_THREAD_TEST_F( | 356 SINGLE_AND_MULTI_THREAD_TEST_F( |
352 LayerTreeHostTimelinesTestAnimationFinishedEvents); | 357 LayerTreeHostTimelinesTestAnimationFinishedEvents); |
(...skipping 24 matching lines...) Expand all Loading... |
377 | 382 |
378 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 383 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
379 scoped_refptr<AnimationTimeline> timeline_impl = | 384 scoped_refptr<AnimationTimeline> timeline_impl = |
380 host_impl->animation_host()->GetTimelineById(timeline_id_); | 385 host_impl->animation_host()->GetTimelineById(timeline_id_); |
381 scoped_refptr<AnimationPlayer> player_impl = | 386 scoped_refptr<AnimationPlayer> player_impl = |
382 timeline_impl->GetPlayerById(player_id_); | 387 timeline_impl->GetPlayerById(player_id_); |
383 | 388 |
384 LayerAnimationController* controller_impl = | 389 LayerAnimationController* controller_impl = |
385 player_impl->element_animations()->layer_animation_controller(); | 390 player_impl->element_animations()->layer_animation_controller(); |
386 Animation* animation_impl = | 391 Animation* animation_impl = |
387 controller_impl->GetAnimation(Animation::OPACITY); | 392 controller_impl->GetAnimation(AnimationTargetProperty::OPACITY); |
388 controller_impl->RemoveAnimation(animation_impl->id()); | 393 controller_impl->RemoveAnimation(animation_impl->id()); |
389 EndTest(); | 394 EndTest(); |
390 } | 395 } |
391 | 396 |
392 void AfterTest() override { | 397 void AfterTest() override { |
393 // Update() should have been called once, proving that the layer was not | 398 // Update() should have been called once, proving that the layer was not |
394 // skipped. | 399 // skipped. |
395 EXPECT_EQ(1, update_check_layer_->update_count()); | 400 EXPECT_EQ(1, update_check_layer_->update_count()); |
396 | 401 |
397 // clear update_check_layer_ so LayerTreeHost dies. | 402 // clear update_check_layer_ so LayerTreeHost dies. |
(...skipping 21 matching lines...) Expand all Loading... |
419 void DidCommit() override { | 424 void DidCommit() override { |
420 if (layer_tree_host()->source_frame_number() == 1) { | 425 if (layer_tree_host()->source_frame_number() == 1) { |
421 AttachPlayersToTimeline(); | 426 AttachPlayersToTimeline(); |
422 | 427 |
423 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); | 428 scoped_refptr<Layer> layer = Layer::Create(layer_settings()); |
424 player_->AttachLayer(layer->id()); | 429 player_->AttachLayer(layer->id()); |
425 player_->set_layer_animation_delegate(this); | 430 player_->set_layer_animation_delegate(this); |
426 | 431 |
427 // Any valid AnimationCurve will do here. | 432 // Any valid AnimationCurve will do here. |
428 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); | 433 scoped_ptr<AnimationCurve> curve(new FakeFloatAnimationCurve()); |
429 scoped_ptr<Animation> animation( | 434 scoped_ptr<Animation> animation(Animation::Create( |
430 Animation::Create(std::move(curve), 1, 1, Animation::OPACITY)); | 435 std::move(curve), 1, 1, AnimationTargetProperty::OPACITY)); |
431 player_->AddAnimation(std::move(animation)); | 436 player_->AddAnimation(std::move(animation)); |
432 | 437 |
433 // We add the animation *before* attaching the layer to the tree. | 438 // We add the animation *before* attaching the layer to the tree. |
434 layer_tree_host()->root_layer()->AddChild(layer); | 439 layer_tree_host()->root_layer()->AddChild(layer); |
435 } | 440 } |
436 } | 441 } |
437 | 442 |
438 void AnimateLayers(LayerTreeHostImpl* impl_host, | 443 void AnimateLayers(LayerTreeHostImpl* impl_host, |
439 base::TimeTicks monotonic_time) override { | 444 base::TimeTicks monotonic_time) override { |
440 EndTest(); | 445 EndTest(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 false); | 505 false); |
501 break; | 506 break; |
502 case 2: | 507 case 2: |
503 // This second animation will not be drawn so it should not start. | 508 // This second animation will not be drawn so it should not start. |
504 AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5); | 509 AddAnimatedTransformToPlayer(player_child_.get(), 0.1, 5, 5); |
505 break; | 510 break; |
506 } | 511 } |
507 } | 512 } |
508 | 513 |
509 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 514 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
510 Animation::TargetProperty target_property, | 515 AnimationTargetProperty target_property, |
511 int group) override { | 516 int group) override { |
512 if (TestEnded()) | 517 if (TestEnded()) |
513 return; | 518 return; |
514 started_times_++; | 519 started_times_++; |
515 } | 520 } |
516 | 521 |
517 void AfterTest() override { | 522 void AfterTest() override { |
518 // Make sure we tried to draw the second animation but failed. | 523 // Make sure we tried to draw the second animation but failed. |
519 EXPECT_LT(0, prevented_draw_); | 524 EXPECT_LT(0, prevented_draw_); |
520 // The first animation should be started, but the second should not because | 525 // The first animation should be started, but the second should not because |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 562 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
558 | 563 |
559 void DidCommit() override { | 564 void DidCommit() override { |
560 switch (layer_tree_host()->source_frame_number()) { | 565 switch (layer_tree_host()->source_frame_number()) { |
561 case 1: { | 566 case 1: { |
562 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 567 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
563 ScrollOffsetAnimationCurve::Create( | 568 ScrollOffsetAnimationCurve::Create( |
564 gfx::ScrollOffset(500.f, 550.f), | 569 gfx::ScrollOffset(500.f, 550.f), |
565 EaseInOutTimingFunction::Create())); | 570 EaseInOutTimingFunction::Create())); |
566 scoped_ptr<Animation> animation(Animation::Create( | 571 scoped_ptr<Animation> animation(Animation::Create( |
567 std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 572 std::move(curve), 1, 0, AnimationTargetProperty::SCROLL_OFFSET)); |
568 animation->set_needs_synchronized_start_time(true); | 573 animation->set_needs_synchronized_start_time(true); |
569 bool impl_scrolling_supported = | 574 bool impl_scrolling_supported = |
570 layer_tree_host()->proxy()->SupportsImplScrolling(); | 575 layer_tree_host()->proxy()->SupportsImplScrolling(); |
571 if (impl_scrolling_supported) | 576 if (impl_scrolling_supported) |
572 player_child_->AddAnimation(std::move(animation)); | 577 player_child_->AddAnimation(std::move(animation)); |
573 else | 578 else |
574 EndTest(); | 579 EndTest(); |
575 break; | 580 break; |
576 } | 581 } |
577 default: | 582 default: |
(...skipping 30 matching lines...) Expand all Loading... |
608 scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 613 scroll_layer_ = FakePictureLayer::Create(layer_settings(), &client_); |
609 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); | 614 scroll_layer_->SetScrollClipLayerId(layer_tree_host()->root_layer()->id()); |
610 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); | 615 scroll_layer_->SetBounds(gfx::Size(10000, 10000)); |
611 client_.set_bounds(scroll_layer_->bounds()); | 616 client_.set_bounds(scroll_layer_->bounds()); |
612 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); | 617 scroll_layer_->SetScrollOffset(gfx::ScrollOffset(100.0, 200.0)); |
613 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 618 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
614 | 619 |
615 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 620 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
616 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), | 621 ScrollOffsetAnimationCurve::Create(gfx::ScrollOffset(6500.f, 7500.f), |
617 EaseInOutTimingFunction::Create())); | 622 EaseInOutTimingFunction::Create())); |
618 scoped_ptr<Animation> animation( | 623 scoped_ptr<Animation> animation(Animation::Create( |
619 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 624 std::move(curve), 1, 0, AnimationTargetProperty::SCROLL_OFFSET)); |
620 animation->set_needs_synchronized_start_time(true); | 625 animation->set_needs_synchronized_start_time(true); |
621 | 626 |
622 AttachPlayersToTimeline(); | 627 AttachPlayersToTimeline(); |
623 player_child_->AttachLayer(scroll_layer_->id()); | 628 player_child_->AttachLayer(scroll_layer_->id()); |
624 player_child_->AddAnimation(std::move(animation)); | 629 player_child_->AddAnimation(std::move(animation)); |
625 } | 630 } |
626 | 631 |
627 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 632 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
628 | 633 |
629 void BeginMainFrame(const BeginFrameArgs& args) override { | 634 void BeginMainFrame(const BeginFrameArgs& args) override { |
630 switch (layer_tree_host()->source_frame_number()) { | 635 switch (layer_tree_host()->source_frame_number()) { |
631 case 0: | 636 case 0: |
632 break; | 637 break; |
633 case 1: { | 638 case 1: { |
634 Animation* animation = player_child_->element_animations() | 639 Animation* animation = |
635 ->layer_animation_controller() | 640 player_child_->element_animations() |
636 ->GetAnimation(Animation::SCROLL_OFFSET); | 641 ->layer_animation_controller() |
| 642 ->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET); |
637 player_child_->RemoveAnimation(animation->id()); | 643 player_child_->RemoveAnimation(animation->id()); |
638 scroll_layer_->SetScrollOffset(final_postion_); | 644 scroll_layer_->SetScrollOffset(final_postion_); |
639 break; | 645 break; |
640 } | 646 } |
641 default: | 647 default: |
642 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); | 648 EXPECT_EQ(final_postion_, scroll_layer_->scroll_offset()); |
643 } | 649 } |
644 } | 650 } |
645 | 651 |
646 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { | 652 void BeginCommitOnThread(LayerTreeHostImpl* host_impl) override { |
(...skipping 10 matching lines...) Expand all Loading... |
657 return; | 663 return; |
658 } | 664 } |
659 | 665 |
660 scoped_refptr<AnimationTimeline> timeline_impl = | 666 scoped_refptr<AnimationTimeline> timeline_impl = |
661 host_impl->animation_host()->GetTimelineById(timeline_id_); | 667 host_impl->animation_host()->GetTimelineById(timeline_id_); |
662 scoped_refptr<AnimationPlayer> player_impl = | 668 scoped_refptr<AnimationPlayer> player_impl = |
663 timeline_impl->GetPlayerById(player_child_id_); | 669 timeline_impl->GetPlayerById(player_child_id_); |
664 | 670 |
665 LayerImpl* scroll_layer_impl = | 671 LayerImpl* scroll_layer_impl = |
666 host_impl->active_tree()->root_layer()->children()[0].get(); | 672 host_impl->active_tree()->root_layer()->children()[0].get(); |
667 Animation* animation = player_impl->element_animations() | 673 Animation* animation = |
668 ->layer_animation_controller() | 674 player_impl->element_animations() |
669 ->GetAnimation(Animation::SCROLL_OFFSET); | 675 ->layer_animation_controller() |
| 676 ->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET); |
670 | 677 |
671 if (!animation || animation->run_state() != Animation::RUNNING) { | 678 if (!animation || animation->run_state() != Animation::RUNNING) { |
672 host_impl->BlockNotifyReadyToActivateForTesting(false); | 679 host_impl->BlockNotifyReadyToActivateForTesting(false); |
673 return; | 680 return; |
674 } | 681 } |
675 | 682 |
676 // Block activation until the running animation has a chance to produce a | 683 // Block activation until the running animation has a chance to produce a |
677 // scroll delta. | 684 // scroll delta. |
678 gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta(); | 685 gfx::Vector2dF scroll_delta = scroll_layer_impl->ScrollDelta(); |
679 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) | 686 if (scroll_delta.x() < 1.f || scroll_delta.y() < 1.f) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 scoped_refptr<AnimationPlayer> player_child_impl = | 785 scoped_refptr<AnimationPlayer> player_child_impl = |
779 timeline_impl->GetPlayerById(player_child_id_); | 786 timeline_impl->GetPlayerById(player_child_id_); |
780 | 787 |
781 // wait for tree activation. | 788 // wait for tree activation. |
782 if (!player_impl->element_animations()) | 789 if (!player_impl->element_animations()) |
783 return; | 790 return; |
784 | 791 |
785 LayerAnimationController* root_controller_impl = | 792 LayerAnimationController* root_controller_impl = |
786 player_impl->element_animations()->layer_animation_controller(); | 793 player_impl->element_animations()->layer_animation_controller(); |
787 Animation* root_animation = | 794 Animation* root_animation = |
788 root_controller_impl->GetAnimation(Animation::OPACITY); | 795 root_controller_impl->GetAnimation(AnimationTargetProperty::OPACITY); |
789 if (!root_animation || root_animation->run_state() != Animation::RUNNING) | 796 if (!root_animation || root_animation->run_state() != Animation::RUNNING) |
790 return; | 797 return; |
791 | 798 |
792 LayerAnimationController* child_controller_impl = | 799 LayerAnimationController* child_controller_impl = |
793 player_child_impl->element_animations()->layer_animation_controller(); | 800 player_child_impl->element_animations()->layer_animation_controller(); |
794 Animation* child_animation = | 801 Animation* child_animation = |
795 child_controller_impl->GetAnimation(Animation::OPACITY); | 802 child_controller_impl->GetAnimation(AnimationTargetProperty::OPACITY); |
796 EXPECT_EQ(Animation::RUNNING, child_animation->run_state()); | 803 EXPECT_EQ(Animation::RUNNING, child_animation->run_state()); |
797 EXPECT_EQ(root_animation->start_time(), child_animation->start_time()); | 804 EXPECT_EQ(root_animation->start_time(), child_animation->start_time()); |
798 root_controller_impl->AbortAnimations(Animation::OPACITY); | 805 root_controller_impl->AbortAnimations(AnimationTargetProperty::OPACITY); |
799 root_controller_impl->AbortAnimations(Animation::TRANSFORM); | 806 root_controller_impl->AbortAnimations(AnimationTargetProperty::TRANSFORM); |
800 child_controller_impl->AbortAnimations(Animation::OPACITY); | 807 child_controller_impl->AbortAnimations(AnimationTargetProperty::OPACITY); |
801 EndTest(); | 808 EndTest(); |
802 } | 809 } |
803 | 810 |
804 void AfterTest() override {} | 811 void AfterTest() override {} |
805 | 812 |
806 private: | 813 private: |
807 int frame_count_with_pending_tree_; | 814 int frame_count_with_pending_tree_; |
808 }; | 815 }; |
809 | 816 |
810 // This test blocks activation which is not supported for single thread mode. | 817 // This test blocks activation which is not supported for single thread mode. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 if (host_impl->active_tree()->source_frame_number() < 2) | 856 if (host_impl->active_tree()->source_frame_number() < 2) |
850 return; | 857 return; |
851 AnimationRegistrar::AnimationControllerMap controllers_copy = | 858 AnimationRegistrar::AnimationControllerMap controllers_copy = |
852 host_impl->animation_host() | 859 host_impl->animation_host() |
853 ->animation_registrar() | 860 ->animation_registrar() |
854 ->active_animation_controllers_for_testing(); | 861 ->active_animation_controllers_for_testing(); |
855 EXPECT_EQ(2u, controllers_copy.size()); | 862 EXPECT_EQ(2u, controllers_copy.size()); |
856 for (auto& it : controllers_copy) { | 863 for (auto& it : controllers_copy) { |
857 int id = it.first; | 864 int id = it.first; |
858 if (id == host_impl->RootLayer()->id()) { | 865 if (id == host_impl->RootLayer()->id()) { |
859 Animation* anim = it.second->GetAnimation(Animation::TRANSFORM); | 866 Animation* anim = |
| 867 it.second->GetAnimation(AnimationTargetProperty::TRANSFORM); |
860 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 868 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
861 } else if (id == host_impl->RootLayer()->children()[0]->id()) { | 869 } else if (id == host_impl->RootLayer()->children()[0]->id()) { |
862 Animation* anim = it.second->GetAnimation(Animation::OPACITY); | 870 Animation* anim = |
| 871 it.second->GetAnimation(AnimationTargetProperty::OPACITY); |
863 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); | 872 EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
864 } | 873 } |
865 EndTest(); | 874 EndTest(); |
866 } | 875 } |
867 } | 876 } |
868 | 877 |
869 void AfterTest() override {} | 878 void AfterTest() override {} |
870 | 879 |
871 private: | 880 private: |
872 scoped_refptr<Layer> content_; | 881 scoped_refptr<Layer> content_; |
(...skipping 21 matching lines...) Expand all Loading... |
894 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 903 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
895 | 904 |
896 void DidCommit() override { | 905 void DidCommit() override { |
897 switch (layer_tree_host()->source_frame_number()) { | 906 switch (layer_tree_host()->source_frame_number()) { |
898 case 1: | 907 case 1: |
899 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); | 908 AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5); |
900 break; | 909 break; |
901 case 2: | 910 case 2: |
902 LayerAnimationController* controller = | 911 LayerAnimationController* controller = |
903 player_child_->element_animations()->layer_animation_controller(); | 912 player_child_->element_animations()->layer_animation_controller(); |
904 Animation* animation = controller->GetAnimation(Animation::TRANSFORM); | 913 Animation* animation = |
| 914 controller->GetAnimation(AnimationTargetProperty::TRANSFORM); |
905 player_child_->RemoveAnimation(animation->id()); | 915 player_child_->RemoveAnimation(animation->id()); |
906 gfx::Transform transform; | 916 gfx::Transform transform; |
907 transform.Translate(10.f, 10.f); | 917 transform.Translate(10.f, 10.f); |
908 layer_->SetTransform(transform); | 918 layer_->SetTransform(transform); |
909 | 919 |
910 // Do something that causes property trees to get rebuilt. | 920 // Do something that causes property trees to get rebuilt. |
911 layer_->AddChild(Layer::Create(layer_settings())); | 921 layer_->AddChild(Layer::Create(layer_settings())); |
912 break; | 922 break; |
913 } | 923 } |
914 } | 924 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 private: | 1140 private: |
1131 scoped_refptr<Layer> layer_; | 1141 scoped_refptr<Layer> layer_; |
1132 FakeContentLayerClient client_; | 1142 FakeContentLayerClient client_; |
1133 }; | 1143 }; |
1134 | 1144 |
1135 MULTI_THREAD_TEST_F( | 1145 MULTI_THREAD_TEST_F( |
1136 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); | 1146 LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit); |
1137 | 1147 |
1138 } // namespace | 1148 } // namespace |
1139 } // namespace cc | 1149 } // namespace cc |
OLD | NEW |