OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/animation.h" |
5 #include "ui/compositor/test/layer_animator_test_controller.h" | 6 #include "ui/compositor/test/layer_animator_test_controller.h" |
6 #include "ui/compositor/layer_animation_sequence.h" | 7 #include "ui/compositor/layer_animation_sequence.h" |
7 | 8 |
8 namespace ui { | 9 namespace ui { |
9 | 10 |
10 LayerAnimatorTestController::LayerAnimatorTestController( | 11 LayerAnimatorTestController::LayerAnimatorTestController( |
11 scoped_refptr<LayerAnimator> animator) | 12 scoped_refptr<LayerAnimator> animator) |
12 : animator_(animator) { | 13 : animator_(animator) { |
13 } | 14 } |
14 | 15 |
15 LayerAnimatorTestController::~LayerAnimatorTestController() { | 16 LayerAnimatorTestController::~LayerAnimatorTestController() { |
16 } | 17 } |
17 | 18 |
18 LayerAnimationSequence* LayerAnimatorTestController::GetRunningSequence( | 19 LayerAnimationSequence* LayerAnimatorTestController::GetRunningSequence( |
19 LayerAnimationElement::AnimatableProperty property) { | 20 LayerAnimationElement::AnimatableProperty property) { |
20 LayerAnimator::RunningAnimation* running_animation = | 21 LayerAnimator::RunningAnimation* running_animation = |
21 animator_->GetRunningAnimation(property); | 22 animator_->GetRunningAnimation(property); |
22 if (running_animation) | 23 if (running_animation) |
23 return running_animation->sequence(); | 24 return running_animation->sequence(); |
24 else | 25 else |
25 return NULL; | 26 return NULL; |
26 } | 27 } |
27 | 28 |
28 void LayerAnimatorTestController::StartThreadedAnimationsIfNeeded() { | 29 void LayerAnimatorTestController::StartThreadedAnimationsIfNeeded() { |
29 LayerAnimationSequence* sequence = | 30 std::vector<cc::Animation::TargetProperty> threaded_properties; |
30 GetRunningSequence(LayerAnimationElement::OPACITY); | 31 threaded_properties.push_back(cc::Animation::Opacity); |
| 32 threaded_properties.push_back(cc::Animation::Transform); |
31 | 33 |
32 if (!sequence) | 34 for (size_t i = 0; i < threaded_properties.size(); i++) { |
33 return; | 35 LayerAnimationElement::AnimatableProperty animatable_property = |
| 36 LayerAnimationElement::ToAnimatableProperty(threaded_properties[i]); |
| 37 LayerAnimationSequence* sequence = GetRunningSequence(animatable_property); |
| 38 if (!sequence) |
| 39 continue; |
34 | 40 |
35 LayerAnimationElement* element = sequence->CurrentElement(); | 41 LayerAnimationElement* element = sequence->CurrentElement(); |
36 if (element->properties().find(LayerAnimationElement::OPACITY) == | 42 if (element->properties().find(animatable_property) == |
37 element->properties().end()) | 43 element->properties().end()) |
38 return; | 44 continue; |
39 | 45 |
40 if (!element->Started() || | 46 if (!element->Started() || |
41 element->effective_start_time() != base::TimeTicks()) | 47 element->effective_start_time() != base::TimeTicks()) |
42 return; | 48 continue; |
43 | 49 |
44 animator_->OnThreadedAnimationStarted(cc::AnimationEvent( | 50 animator_->OnThreadedAnimationStarted(cc::AnimationEvent( |
45 cc::AnimationEvent::Started, | 51 cc::AnimationEvent::Started, |
46 0, | 52 0, |
47 element->animation_group_id(), | 53 element->animation_group_id(), |
48 cc::Animation::Opacity, | 54 threaded_properties[i], |
49 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF())); | 55 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF())); |
| 56 } |
50 } | 57 } |
51 | 58 |
52 } // namespace ui | 59 } // namespace ui |
OLD | NEW |