Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: ui/compositor/layer_animator.cc

Issue 27710005: cc: Use HighResNow as timebase if it is fast and reliable (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix DCHECK Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/compositor/compositor.cc ('k') | ui/compositor/layer_animator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.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 "ui/compositor/compositor.h" 12 #include "ui/compositor/compositor.h"
12 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer.h"
13 #include "ui/compositor/layer_animation_delegate.h" 14 #include "ui/compositor/layer_animation_delegate.h"
14 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
15 #include "ui/compositor/layer_animation_sequence.h" 16 #include "ui/compositor/layer_animation_sequence.h"
16 #include "ui/gfx/animation/animation_container.h" 17 #include "ui/gfx/animation/animation_container.h"
18 #include "ui/gfx/frame_time.h"
17 19
18 #define SAFE_INVOKE_VOID(function, running_anim, ...) \ 20 #define SAFE_INVOKE_VOID(function, running_anim, ...) \
19 if (running_anim.is_sequence_alive()) \ 21 if (running_anim.is_sequence_alive()) \
20 function(running_anim.sequence(), ##__VA_ARGS__) 22 function(running_anim.sequence(), ##__VA_ARGS__)
21 #define SAFE_INVOKE_BOOL(function, running_anim) \ 23 #define SAFE_INVOKE_BOOL(function, running_anim) \
22 ((running_anim.is_sequence_alive()) \ 24 ((running_anim.is_sequence_alive()) \
23 ? function(running_anim.sequence()) \ 25 ? function(running_anim.sequence()) \
24 : false) 26 : false)
25 #define SAFE_INVOKE_PTR(function, running_anim) \ 27 #define SAFE_INVOKE_PTR(function, running_anim) \
26 ((running_anim.is_sequence_alive()) \ 28 ((running_anim.is_sequence_alive()) \
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 StartAnimation(*iter); 172 StartAnimation(*iter);
171 } 173 }
172 return; 174 return;
173 } 175 }
174 176
175 adding_animations_ = true; 177 adding_animations_ = true;
176 if (!is_animating()) { 178 if (!is_animating()) {
177 if (GetAnimationContainer()->is_running()) 179 if (GetAnimationContainer()->is_running())
178 last_step_time_ = GetAnimationContainer()->last_tick_time(); 180 last_step_time_ = GetAnimationContainer()->last_tick_time();
179 else 181 else
180 last_step_time_ = base::TimeTicks::Now(); 182 last_step_time_ = gfx::FrameTime::Now();
181 } 183 }
182 184
183 // Collect all the affected properties. 185 // Collect all the affected properties.
184 LayerAnimationElement::AnimatableProperties animated_properties; 186 LayerAnimationElement::AnimatableProperties animated_properties;
185 std::vector<LayerAnimationSequence*>::const_iterator iter; 187 std::vector<LayerAnimationSequence*>::const_iterator iter;
186 for (iter = animations.begin(); iter != animations.end(); ++iter) { 188 for (iter = animations.begin(); iter != animations.end(); ++iter) {
187 animated_properties.insert((*iter)->properties().begin(), 189 animated_properties.insert((*iter)->properties().begin(),
188 (*iter)->properties().end()); 190 (*iter)->properties().end());
189 } 191 }
190 192
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 // internally). 763 // internally).
762 // All LayerAnimators share the same AnimationContainer. Use the 764 // All LayerAnimators share the same AnimationContainer. Use the
763 // last_tick_time() from there to ensure animations started during the same 765 // last_tick_time() from there to ensure animations started during the same
764 // event complete at the same time. 766 // event complete at the same time.
765 base::TimeTicks start_time; 767 base::TimeTicks start_time;
766 if (is_animating() || adding_animations_) 768 if (is_animating() || adding_animations_)
767 start_time = last_step_time_; 769 start_time = last_step_time_;
768 else if (GetAnimationContainer()->is_running()) 770 else if (GetAnimationContainer()->is_running())
769 start_time = GetAnimationContainer()->last_tick_time(); 771 start_time = GetAnimationContainer()->last_tick_time();
770 else 772 else
771 start_time = base::TimeTicks::Now(); 773 start_time = gfx::FrameTime::Now();
772 774
773 if (!sequence->animation_group_id()) 775 if (!sequence->animation_group_id())
774 sequence->set_animation_group_id(cc::AnimationIdProvider::NextGroupId()); 776 sequence->set_animation_group_id(cc::AnimationIdProvider::NextGroupId());
775 if (!sequence->waiting_for_group_start() || 777 if (!sequence->waiting_for_group_start() ||
776 sequence->IsFirstElementThreaded()) { 778 sequence->IsFirstElementThreaded()) {
777 sequence->set_start_time(start_time); 779 sequence->set_start_time(start_time);
778 sequence->Start(delegate()); 780 sequence->Start(delegate());
779 } 781 }
780 running_animations_.push_back( 782 running_animations_.push_back(
781 RunningAnimation(sequence->AsWeakPtr())); 783 RunningAnimation(sequence->AsWeakPtr()));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 } 846 }
845 847
846 LayerAnimator::RunningAnimation::RunningAnimation( 848 LayerAnimator::RunningAnimation::RunningAnimation(
847 const base::WeakPtr<LayerAnimationSequence>& sequence) 849 const base::WeakPtr<LayerAnimationSequence>& sequence)
848 : sequence_(sequence) { 850 : sequence_(sequence) {
849 } 851 }
850 852
851 LayerAnimator::RunningAnimation::~RunningAnimation() { } 853 LayerAnimator::RunningAnimation::~RunningAnimation() { }
852 854
853 } // namespace ui 855 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.cc ('k') | ui/compositor/layer_animator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698