| OLD | NEW |
| 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" | 9 #include "ui/gfx/frame_time.h" |
| 10 | 10 |
| 11 using base::TimeDelta; | 11 using base::TimeDelta; |
| 12 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_(gfx::FrameTime::Now()), |
| 18 observer_(NULL) { | 17 observer_(NULL) { |
| 19 } | 18 } |
| 20 | 19 |
| 21 AnimationContainer::~AnimationContainer() { | 20 AnimationContainer::~AnimationContainer() { |
| 22 // The animations own us and stop themselves before being deleted. If | 21 // The animations own us and stop themselves before being deleted. If |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 54 } |
| 56 } | 55 } |
| 57 | 56 |
| 58 void AnimationContainer::Run() { | 57 void AnimationContainer::Run() { |
| 59 // We notify the observer after updating all the elements. If all the elements | 58 // 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 | 59 // 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 | 60 // 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. | 61 // ourself here to make sure we're still valid after running all the elements. |
| 63 scoped_refptr<AnimationContainer> this_ref(this); | 62 scoped_refptr<AnimationContainer> this_ref(this); |
| 64 | 63 |
| 65 TimeTicks current_time = gfx::FrameTime::Now(); | 64 gfx::FrameTime current_time = gfx::FrameTime::Now(); |
| 66 | 65 |
| 67 last_tick_time_ = current_time; | 66 last_tick_time_ = current_time; |
| 68 | 67 |
| 69 // Make a copy of the elements to iterate over so that if any elements are | 68 // 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. | 69 // removed as part of invoking Step there aren't any problems. |
| 71 Elements elements = elements_; | 70 Elements elements = elements_; |
| 72 | 71 |
| 73 for (Elements::const_iterator i = elements.begin(); | 72 for (Elements::const_iterator i = elements.begin(); |
| 74 i != elements.end(); ++i) { | 73 i != elements.end(); ++i) { |
| 75 // Make sure the element is still valid. | 74 // Make sure the element is still valid. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 96 Elements::const_iterator i = elements_.begin(); | 95 Elements::const_iterator i = elements_.begin(); |
| 97 min = (*i)->GetTimerInterval(); | 96 min = (*i)->GetTimerInterval(); |
| 98 for (++i; i != elements_.end(); ++i) { | 97 for (++i; i != elements_.end(); ++i) { |
| 99 if ((*i)->GetTimerInterval() < min) | 98 if ((*i)->GetTimerInterval() < min) |
| 100 min = (*i)->GetTimerInterval(); | 99 min = (*i)->GetTimerInterval(); |
| 101 } | 100 } |
| 102 return min; | 101 return min; |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace gfx | 104 } // namespace gfx |
| OLD | NEW |