OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer_animator.h" | 5 #include "ui/compositor/layer_animator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/animation/animation_id_provider.h" | 10 #include "cc/animation/animation_id_provider.h" |
11 #include "cc/output/begin_frame_args.h" | 11 #include "cc/output/begin_frame_args.h" |
12 #include "ui/compositor/compositor.h" | 12 #include "ui/compositor/compositor.h" |
13 #include "ui/compositor/layer.h" | 13 #include "ui/compositor/layer.h" |
14 #include "ui/compositor/layer_animation_delegate.h" | 14 #include "ui/compositor/layer_animation_delegate.h" |
15 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
16 #include "ui/compositor/layer_animation_sequence.h" | 16 #include "ui/compositor/layer_animation_sequence.h" |
17 #include "ui/compositor/layer_animator_collection.h" | 17 #include "ui/compositor/layer_animator_collection.h" |
18 #include "ui/gfx/frame_time.h" | |
19 | 18 |
20 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ | 19 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ |
21 if (running_anim.is_sequence_alive()) \ | 20 if (running_anim.is_sequence_alive()) \ |
22 function(running_anim.sequence(), ##__VA_ARGS__) | 21 function(running_anim.sequence(), ##__VA_ARGS__) |
23 #define SAFE_INVOKE_BOOL(function, running_anim) \ | 22 #define SAFE_INVOKE_BOOL(function, running_anim) \ |
24 ((running_anim.is_sequence_alive()) \ | 23 ((running_anim.is_sequence_alive()) \ |
25 ? function(running_anim.sequence()) \ | 24 ? function(running_anim.sequence()) \ |
26 : false) | 25 : false) |
27 #define SAFE_INVOKE_PTR(function, running_anim) \ | 26 #define SAFE_INVOKE_PTR(function, running_anim) \ |
28 ((running_anim.is_sequence_alive()) \ | 27 ((running_anim.is_sequence_alive()) \ |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 174 } |
176 return; | 175 return; |
177 } | 176 } |
178 | 177 |
179 adding_animations_ = true; | 178 adding_animations_ = true; |
180 if (!is_animating()) { | 179 if (!is_animating()) { |
181 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); | 180 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); |
182 if (collection && collection->HasActiveAnimators()) | 181 if (collection && collection->HasActiveAnimators()) |
183 last_step_time_ = collection->last_tick_time(); | 182 last_step_time_ = collection->last_tick_time(); |
184 else | 183 else |
185 last_step_time_ = gfx::FrameTime::Now(); | 184 last_step_time_ = base::TimeTicks::Now(); |
186 } | 185 } |
187 | 186 |
188 // Collect all the affected properties. | 187 // Collect all the affected properties. |
189 LayerAnimationElement::AnimatableProperties animated_properties = | 188 LayerAnimationElement::AnimatableProperties animated_properties = |
190 LayerAnimationElement::UNKNOWN; | 189 LayerAnimationElement::UNKNOWN; |
191 | 190 |
192 std::vector<LayerAnimationSequence*>::const_iterator iter; | 191 std::vector<LayerAnimationSequence*>::const_iterator iter; |
193 for (iter = animations.begin(); iter != animations.end(); ++iter) | 192 for (iter = animations.begin(); iter != animations.end(); ++iter) |
194 animated_properties |= (*iter)->properties(); | 193 animated_properties |= (*iter)->properties(); |
195 | 194 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 // All LayerAnimators share the same LayerAnimatorCollection. Use the | 762 // All LayerAnimators share the same LayerAnimatorCollection. Use the |
764 // last_tick_time() from there to ensure animations started during the same | 763 // last_tick_time() from there to ensure animations started during the same |
765 // event complete at the same time. | 764 // event complete at the same time. |
766 base::TimeTicks start_time; | 765 base::TimeTicks start_time; |
767 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); | 766 LayerAnimatorCollection* collection = GetLayerAnimatorCollection(); |
768 if (is_animating() || adding_animations_) | 767 if (is_animating() || adding_animations_) |
769 start_time = last_step_time_; | 768 start_time = last_step_time_; |
770 else if (collection && collection->HasActiveAnimators()) | 769 else if (collection && collection->HasActiveAnimators()) |
771 start_time = collection->last_tick_time(); | 770 start_time = collection->last_tick_time(); |
772 else | 771 else |
773 start_time = gfx::FrameTime::Now(); | 772 start_time = base::TimeTicks::Now(); |
774 | 773 |
775 if (!sequence->animation_group_id()) | 774 if (!sequence->animation_group_id()) |
776 sequence->set_animation_group_id(cc::AnimationIdProvider::NextGroupId()); | 775 sequence->set_animation_group_id(cc::AnimationIdProvider::NextGroupId()); |
777 if (!sequence->waiting_for_group_start() || | 776 if (!sequence->waiting_for_group_start() || |
778 sequence->IsFirstElementThreaded()) { | 777 sequence->IsFirstElementThreaded()) { |
779 sequence->set_start_time(start_time); | 778 sequence->set_start_time(start_time); |
780 sequence->Start(delegate()); | 779 sequence->Start(delegate()); |
781 } | 780 } |
782 running_animations_.push_back( | 781 running_animations_.push_back( |
783 RunningAnimation(sequence->AsWeakPtr())); | 782 RunningAnimation(sequence->AsWeakPtr())); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 } | 851 } |
853 | 852 |
854 LayerAnimator::RunningAnimation::RunningAnimation( | 853 LayerAnimator::RunningAnimation::RunningAnimation( |
855 const base::WeakPtr<LayerAnimationSequence>& sequence) | 854 const base::WeakPtr<LayerAnimationSequence>& sequence) |
856 : sequence_(sequence) { | 855 : sequence_(sequence) { |
857 } | 856 } |
858 | 857 |
859 LayerAnimator::RunningAnimation::~RunningAnimation() { } | 858 LayerAnimator::RunningAnimation::~RunningAnimation() { } |
860 | 859 |
861 } // namespace ui | 860 } // namespace ui |
OLD | NEW |