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
3 // found in the LICENSE file.
5 #include "cc/animation/animation.h"
6 #include "ui/compositor/layer_animation_sequence.h"
7 #include "ui/compositor/test/layer_animator_test_controller.h"
11 LayerAnimatorTestController::LayerAnimatorTestController(
12 scoped_refptr
<LayerAnimator
> animator
)
13 : animator_(animator
) {
16 LayerAnimatorTestController::~LayerAnimatorTestController() {
19 LayerAnimationSequence
* LayerAnimatorTestController::GetRunningSequence(
20 LayerAnimationElement::AnimatableProperty property
) {
21 LayerAnimator::RunningAnimation
* running_animation
=
22 animator_
->GetRunningAnimation(property
);
23 if (running_animation
)
24 return running_animation
->sequence();
29 void LayerAnimatorTestController::StartThreadedAnimationsIfNeeded() {
30 std::vector
<cc::Animation::TargetProperty
> threaded_properties
;
31 threaded_properties
.push_back(cc::Animation::Opacity
);
32 threaded_properties
.push_back(cc::Animation::Transform
);
34 for (size_t i
= 0; i
< threaded_properties
.size(); i
++) {
35 LayerAnimationElement::AnimatableProperty animatable_property
=
36 LayerAnimationElement::ToAnimatableProperty(threaded_properties
[i
]);
37 LayerAnimationSequence
* sequence
= GetRunningSequence(animatable_property
);
41 LayerAnimationElement
* element
= sequence
->CurrentElement();
42 if (element
->properties().find(animatable_property
) ==
43 element
->properties().end())
46 if (!element
->Started() ||
47 element
->effective_start_time() != base::TimeTicks())
50 animator_
->OnThreadedAnimationStarted(cc::AnimationEvent(
51 cc::AnimationEvent::Started
,
53 element
->animation_group_id(),
54 threaded_properties
[i
],
55 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF()));