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