| 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/test/animation_test_common.h" | 5 #include "cc/test/animation_test_common.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_host.h" | 7 #include "cc/animation/animation_host.h" |
| 8 #include "cc/animation/animation_id_provider.h" | 8 #include "cc/animation/animation_id_provider.h" |
| 9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
| 10 #include "cc/animation/keyframed_animation_curve.h" | 10 #include "cc/animation/keyframed_animation_curve.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 if (duration > 0.0) | 40 if (duration > 0.0) |
| 41 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), start_opacity, | 41 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), start_opacity, |
| 42 std::move(func))); | 42 std::move(func))); |
| 43 curve->AddKeyframe(FloatKeyframe::Create( | 43 curve->AddKeyframe(FloatKeyframe::Create( |
| 44 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); | 44 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); |
| 45 | 45 |
| 46 int id = AnimationIdProvider::NextAnimationId(); | 46 int id = AnimationIdProvider::NextAnimationId(); |
| 47 | 47 |
| 48 scoped_ptr<Animation> animation(Animation::Create( | 48 scoped_ptr<Animation> animation(Animation::Create( |
| 49 std::move(curve), id, AnimationIdProvider::NextGroupId(), | 49 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
| 50 Animation::OPACITY)); | 50 AnimationTargetProperty::OPACITY)); |
| 51 animation->set_needs_synchronized_start_time(true); | 51 animation->set_needs_synchronized_start_time(true); |
| 52 | 52 |
| 53 target->AddAnimation(std::move(animation)); | 53 target->AddAnimation(std::move(animation)); |
| 54 return id; | 54 return id; |
| 55 } | 55 } |
| 56 | 56 |
| 57 template <class Target> | 57 template <class Target> |
| 58 int AddAnimatedTransform(Target* target, | 58 int AddAnimatedTransform(Target* target, |
| 59 double duration, | 59 double duration, |
| 60 TransformOperations start_operations, | 60 TransformOperations start_operations, |
| 61 TransformOperations operations) { | 61 TransformOperations operations) { |
| 62 scoped_ptr<KeyframedTransformAnimationCurve> | 62 scoped_ptr<KeyframedTransformAnimationCurve> |
| 63 curve(KeyframedTransformAnimationCurve::Create()); | 63 curve(KeyframedTransformAnimationCurve::Create()); |
| 64 | 64 |
| 65 if (duration > 0.0) { | 65 if (duration > 0.0) { |
| 66 curve->AddKeyframe(TransformKeyframe::Create(base::TimeDelta(), | 66 curve->AddKeyframe(TransformKeyframe::Create(base::TimeDelta(), |
| 67 start_operations, nullptr)); | 67 start_operations, nullptr)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 curve->AddKeyframe(TransformKeyframe::Create( | 70 curve->AddKeyframe(TransformKeyframe::Create( |
| 71 base::TimeDelta::FromSecondsD(duration), operations, nullptr)); | 71 base::TimeDelta::FromSecondsD(duration), operations, nullptr)); |
| 72 | 72 |
| 73 int id = AnimationIdProvider::NextAnimationId(); | 73 int id = AnimationIdProvider::NextAnimationId(); |
| 74 | 74 |
| 75 scoped_ptr<Animation> animation(Animation::Create( | 75 scoped_ptr<Animation> animation(Animation::Create( |
| 76 std::move(curve), id, AnimationIdProvider::NextGroupId(), | 76 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
| 77 Animation::TRANSFORM)); | 77 AnimationTargetProperty::TRANSFORM)); |
| 78 animation->set_needs_synchronized_start_time(true); | 78 animation->set_needs_synchronized_start_time(true); |
| 79 | 79 |
| 80 target->AddAnimation(std::move(animation)); | 80 target->AddAnimation(std::move(animation)); |
| 81 return id; | 81 return id; |
| 82 } | 82 } |
| 83 | 83 |
| 84 template <class Target> | 84 template <class Target> |
| 85 int AddAnimatedTransform(Target* target, | 85 int AddAnimatedTransform(Target* target, |
| 86 double duration, | 86 double duration, |
| 87 int delta_x, | 87 int delta_x, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 112 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 112 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 FilterOperations filters; | 115 FilterOperations filters; |
| 116 filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); | 116 filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); |
| 117 curve->AddKeyframe(FilterKeyframe::Create( | 117 curve->AddKeyframe(FilterKeyframe::Create( |
| 118 base::TimeDelta::FromSecondsD(duration), filters, nullptr)); | 118 base::TimeDelta::FromSecondsD(duration), filters, nullptr)); |
| 119 | 119 |
| 120 int id = AnimationIdProvider::NextAnimationId(); | 120 int id = AnimationIdProvider::NextAnimationId(); |
| 121 | 121 |
| 122 scoped_ptr<Animation> animation( | 122 scoped_ptr<Animation> animation(Animation::Create( |
| 123 Animation::Create(std::move(curve), id, | 123 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
| 124 AnimationIdProvider::NextGroupId(), Animation::FILTER)); | 124 AnimationTargetProperty::FILTER)); |
| 125 animation->set_needs_synchronized_start_time(true); | 125 animation->set_needs_synchronized_start_time(true); |
| 126 | 126 |
| 127 target->AddAnimation(std::move(animation)); | 127 target->AddAnimation(std::move(animation)); |
| 128 return id; | 128 return id; |
| 129 } | 129 } |
| 130 | 130 |
| 131 FakeFloatAnimationCurve::FakeFloatAnimationCurve() | 131 FakeFloatAnimationCurve::FakeFloatAnimationCurve() |
| 132 : duration_(base::TimeDelta::FromSecondsD(1.0)) { | 132 : duration_(base::TimeDelta::FromSecondsD(1.0)) { |
| 133 } | 133 } |
| 134 | 134 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 if (duration > 0.0) | 410 if (duration > 0.0) |
| 411 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), start_opacity, | 411 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), start_opacity, |
| 412 std::move(func))); | 412 std::move(func))); |
| 413 curve->AddKeyframe(FloatKeyframe::Create( | 413 curve->AddKeyframe(FloatKeyframe::Create( |
| 414 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); | 414 base::TimeDelta::FromSecondsD(duration), end_opacity, nullptr)); |
| 415 | 415 |
| 416 int id = AnimationIdProvider::NextAnimationId(); | 416 int id = AnimationIdProvider::NextAnimationId(); |
| 417 | 417 |
| 418 scoped_ptr<Animation> animation(Animation::Create( | 418 scoped_ptr<Animation> animation(Animation::Create( |
| 419 std::move(curve), id, AnimationIdProvider::NextGroupId(), | 419 std::move(curve), id, AnimationIdProvider::NextGroupId(), |
| 420 Animation::OPACITY)); | 420 AnimationTargetProperty::OPACITY)); |
| 421 animation->set_needs_synchronized_start_time(true); | 421 animation->set_needs_synchronized_start_time(true); |
| 422 | 422 |
| 423 target->AddAnimation(std::move(animation)); | 423 target->AddAnimation(std::move(animation)); |
| 424 return id; | 424 return id; |
| 425 } | 425 } |
| 426 | 426 |
| 427 void AddAnimationToLayerWithPlayer(int layer_id, | 427 void AddAnimationToLayerWithPlayer(int layer_id, |
| 428 scoped_refptr<AnimationTimeline> timeline, | 428 scoped_refptr<AnimationTimeline> timeline, |
| 429 scoped_ptr<Animation> animation) { | 429 scoped_ptr<Animation> animation) { |
| 430 scoped_refptr<AnimationPlayer> player = | 430 scoped_refptr<AnimationPlayer> player = |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 bool use_timing_function) { | 518 bool use_timing_function) { |
| 519 scoped_refptr<AnimationPlayer> player = | 519 scoped_refptr<AnimationPlayer> player = |
| 520 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 520 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 521 timeline->AttachPlayer(player); | 521 timeline->AttachPlayer(player); |
| 522 player->AttachLayer(layer_id); | 522 player->AttachLayer(layer_id); |
| 523 DCHECK(player->element_animations()); | 523 DCHECK(player->element_animations()); |
| 524 return AddOpacityTransitionToPlayer(player.get(), duration, start_opacity, | 524 return AddOpacityTransitionToPlayer(player.get(), duration, start_opacity, |
| 525 end_opacity, use_timing_function); | 525 end_opacity, use_timing_function); |
| 526 } | 526 } |
| 527 | 527 |
| 528 void AbortAnimationsOnLayerWithPlayer( | 528 void AbortAnimationsOnLayerWithPlayer(int layer_id, |
| 529 int layer_id, | 529 scoped_refptr<AnimationTimeline> timeline, |
| 530 scoped_refptr<AnimationTimeline> timeline, | 530 AnimationTargetProperty target_property) { |
| 531 Animation::TargetProperty target_property) { | |
| 532 LayerAnimationController* controller = | 531 LayerAnimationController* controller = |
| 533 timeline->animation_host()->GetControllerForLayerId(layer_id); | 532 timeline->animation_host()->GetControllerForLayerId(layer_id); |
| 534 DCHECK(controller); | 533 DCHECK(controller); |
| 535 controller->AbortAnimations(target_property); | 534 controller->AbortAnimations(target_property); |
| 536 } | 535 } |
| 537 | 536 |
| 538 } // namespace cc | 537 } // namespace cc |
| OLD | NEW |