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

Side by Side Diff: ui/gfx/animation/animation_container.cc

Issue 1143433005: Remove gfx::FrameTime for a single clock source (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handling patch for mac files Created 5 years, 7 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gfx/animation/animation_container.h" 5 #include "ui/gfx/animation/animation_container.h"
6 6
7 #include "ui/gfx/animation/animation_container_element.h" 7 #include "ui/gfx/animation/animation_container_element.h"
8 #include "ui/gfx/animation/animation_container_observer.h" 8 #include "ui/gfx/animation/animation_container_observer.h"
9 #include "ui/gfx/frame_time.h"
10 9
11 using base::TimeDelta; 10 using base::TimeDelta;
12 using base::TimeTicks; 11 using base::TimeTicks;
13 12
14 namespace gfx { 13 namespace gfx {
15 14
16 AnimationContainer::AnimationContainer() 15 AnimationContainer::AnimationContainer()
17 : last_tick_time_(gfx::FrameTime::Now()), 16 : last_tick_time_(base::TimeTicks::Now()), observer_(NULL) {
18 observer_(NULL) {
19 } 17 }
20 18
21 AnimationContainer::~AnimationContainer() { 19 AnimationContainer::~AnimationContainer() {
22 // The animations own us and stop themselves before being deleted. If 20 // The animations own us and stop themselves before being deleted. If
23 // elements_ is not empty, something is wrong. 21 // elements_ is not empty, something is wrong.
24 DCHECK(elements_.empty()); 22 DCHECK(elements_.empty());
25 } 23 }
26 24
27 void AnimationContainer::Start(AnimationContainerElement* element) { 25 void AnimationContainer::Start(AnimationContainerElement* element) {
28 DCHECK(elements_.count(element) == 0); // Start should only be invoked if the 26 DCHECK(elements_.count(element) == 0); // Start should only be invoked if the
29 // element isn't running. 27 // element isn't running.
30 28
31 if (elements_.empty()) { 29 if (elements_.empty()) {
32 last_tick_time_ = gfx::FrameTime::Now(); 30 last_tick_time_ = base::TimeTicks::Now();
33 SetMinTimerInterval(element->GetTimerInterval()); 31 SetMinTimerInterval(element->GetTimerInterval());
34 } else if (element->GetTimerInterval() < min_timer_interval_) { 32 } else if (element->GetTimerInterval() < min_timer_interval_) {
35 SetMinTimerInterval(element->GetTimerInterval()); 33 SetMinTimerInterval(element->GetTimerInterval());
36 } 34 }
37 35
38 element->SetStartTime(last_tick_time_); 36 element->SetStartTime(last_tick_time_);
39 elements_.insert(element); 37 elements_.insert(element);
40 } 38 }
41 39
42 void AnimationContainer::Stop(AnimationContainerElement* element) { 40 void AnimationContainer::Stop(AnimationContainerElement* element) {
(...skipping 12 matching lines...) Expand all
55 } 53 }
56 } 54 }
57 55
58 void AnimationContainer::Run() { 56 void AnimationContainer::Run() {
59 // We notify the observer after updating all the elements. If all the elements 57 // We notify the observer after updating all the elements. If all the elements
60 // are deleted as a result of updating then our ref count would go to zero and 58 // are deleted as a result of updating then our ref count would go to zero and
61 // we would be deleted before we notify our observer. We add a reference to 59 // we would be deleted before we notify our observer. We add a reference to
62 // ourself here to make sure we're still valid after running all the elements. 60 // ourself here to make sure we're still valid after running all the elements.
63 scoped_refptr<AnimationContainer> this_ref(this); 61 scoped_refptr<AnimationContainer> this_ref(this);
64 62
65 TimeTicks current_time = gfx::FrameTime::Now(); 63 TimeTicks current_time = base::TimeTicks::Now();
66 64
67 last_tick_time_ = current_time; 65 last_tick_time_ = current_time;
68 66
69 // Make a copy of the elements to iterate over so that if any elements are 67 // Make a copy of the elements to iterate over so that if any elements are
70 // removed as part of invoking Step there aren't any problems. 68 // removed as part of invoking Step there aren't any problems.
71 Elements elements = elements_; 69 Elements elements = elements_;
72 70
73 for (Elements::const_iterator i = elements.begin(); 71 for (Elements::const_iterator i = elements.begin();
74 i != elements.end(); ++i) { 72 i != elements.end(); ++i) {
75 // Make sure the element is still valid. 73 // Make sure the element is still valid.
(...skipping 20 matching lines...) Expand all
96 Elements::const_iterator i = elements_.begin(); 94 Elements::const_iterator i = elements_.begin();
97 min = (*i)->GetTimerInterval(); 95 min = (*i)->GetTimerInterval();
98 for (++i; i != elements_.end(); ++i) { 96 for (++i; i != elements_.end(); ++i) {
99 if ((*i)->GetTimerInterval() < min) 97 if ((*i)->GetTimerInterval() < min)
100 min = (*i)->GetTimerInterval(); 98 min = (*i)->GetTimerInterval();
101 } 99 }
102 return min; 100 return min;
103 } 101 }
104 102
105 } // namespace gfx 103 } // namespace gfx
OLDNEW
« cc/scheduler/begin_frame_source.cc ('K') | « ui/gfx/BUILD.gn ('k') | ui/gfx/frame_time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698