Fix build break
[chromium-blink-merge.git] / ui / compositor / test / layer_animator_test_controller.cc
blob2b686cc6c2bea67d43012a1bf00a59952e250b60
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"
9 namespace ui {
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();
25 else
26 return NULL;
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);
38 if (!sequence)
39 continue;
41 LayerAnimationElement* element = sequence->CurrentElement();
42 if (element->properties().find(animatable_property) ==
43 element->properties().end())
44 continue;
46 if (!element->Started() ||
47 element->effective_start_time() != base::TimeTicks())
48 continue;
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()));
59 } // namespace ui