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"
8 #include "ui/gfx/geometry/rect.h"
12 LayerAnimatorTestController::LayerAnimatorTestController(
13 scoped_refptr
<LayerAnimator
> animator
)
14 : animator_(animator
) {
17 LayerAnimatorTestController::~LayerAnimatorTestController() {
20 LayerAnimationSequence
* LayerAnimatorTestController::GetRunningSequence(
21 LayerAnimationElement::AnimatableProperty property
) {
22 LayerAnimator::RunningAnimation
* running_animation
=
23 animator_
->GetRunningAnimation(property
);
24 if (running_animation
)
25 return running_animation
->sequence();
30 void LayerAnimatorTestController::StartThreadedAnimationsIfNeeded() {
31 std::vector
<cc::Animation::TargetProperty
> threaded_properties
;
32 threaded_properties
.push_back(cc::Animation::OPACITY
);
33 threaded_properties
.push_back(cc::Animation::TRANSFORM
);
35 for (size_t i
= 0; i
< threaded_properties
.size(); i
++) {
36 LayerAnimationElement::AnimatableProperty animatable_property
=
37 LayerAnimationElement::ToAnimatableProperty(threaded_properties
[i
]);
38 LayerAnimationSequence
* sequence
= GetRunningSequence(animatable_property
);
42 LayerAnimationElement
* element
= sequence
->CurrentElement();
43 if (!(element
->properties() & animatable_property
))
46 if (!element
->Started() ||
47 element
->effective_start_time() != base::TimeTicks())
50 animator_
->OnThreadedAnimationStarted(cc::AnimationEvent(
51 cc::AnimationEvent::STARTED
, 0, element
->animation_group_id(),
52 threaded_properties
[i
], base::TimeTicks::Now()));