OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/multi_animation.h" | 5 #include "app/multi_animation.h" |
6 | 6 |
7 #include "app/animation_delegate.h" | 7 #include "app/animation_delegate.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 // Default interval, in ms. | 10 // Default interval, in ms. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 static_cast<double>(part.end_time_ms); | 48 static_cast<double>(part.end_time_ms); |
49 DCHECK(percent <= 1); | 49 DCHECK(percent <= 1); |
50 current_value_ = Tween::CalculateValue(part.type, percent); | 50 current_value_ = Tween::CalculateValue(part.type, percent); |
51 | 51 |
52 if ((current_value_ != last_value || current_part_index_ != last_index) && | 52 if ((current_value_ != last_value || current_part_index_ != last_index) && |
53 delegate()) { | 53 delegate()) { |
54 delegate()->AnimationProgressed(this); | 54 delegate()->AnimationProgressed(this); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
| 58 void MultiAnimation::SetStartTime(base::TimeTicks start_time) { |
| 59 Animation::SetStartTime(start_time); |
| 60 current_value_ = 0; |
| 61 current_part_index_ = 0; |
| 62 } |
| 63 |
58 const MultiAnimation::Part& MultiAnimation::GetPart(int* time_ms, | 64 const MultiAnimation::Part& MultiAnimation::GetPart(int* time_ms, |
59 size_t* part_index) { | 65 size_t* part_index) { |
60 DCHECK(*time_ms < cycle_time_ms_); | 66 DCHECK(*time_ms < cycle_time_ms_); |
61 | 67 |
62 for (size_t i = 0; i < parts_.size(); ++i) { | 68 for (size_t i = 0; i < parts_.size(); ++i) { |
63 if (*time_ms < parts_[i].time_ms) { | 69 if (*time_ms < parts_[i].time_ms) { |
64 *part_index = i; | 70 *part_index = i; |
65 return parts_[i]; | 71 return parts_[i]; |
66 } | 72 } |
67 | 73 |
68 *time_ms -= parts_[i].time_ms; | 74 *time_ms -= parts_[i].time_ms; |
69 } | 75 } |
70 NOTREACHED(); | 76 NOTREACHED(); |
71 *time_ms = 0; | 77 *time_ms = 0; |
72 *part_index = 0; | 78 *part_index = 0; |
73 return parts_[0]; | 79 return parts_[0]; |
74 } | 80 } |
OLD | NEW |