OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/animation/animation.h" | 5 #include "cc/animation/animation.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 double trimmed = monotonic_time + time_offset_; | 160 double trimmed = monotonic_time + time_offset_; |
161 | 161 |
162 // If we're paused, time is 'stuck' at the pause time. | 162 // If we're paused, time is 'stuck' at the pause time. |
163 if (run_state_ == Paused) | 163 if (run_state_ == Paused) |
164 trimmed = pause_time_; | 164 trimmed = pause_time_; |
165 | 165 |
166 // Returned time should always be relative to the start time and should | 166 // Returned time should always be relative to the start time and should |
167 // subtract all time spent paused. | 167 // subtract all time spent paused. |
168 trimmed -= start_time_ + total_paused_time_; | 168 trimmed -= start_time_ + total_paused_time_; |
169 | 169 |
| 170 // If we're just starting or we're waiting on receiving a start time, |
| 171 // time is 'stuck' at the initial state. |
| 172 if ((run_state_ == Starting && !has_set_start_time()) || |
| 173 needs_synchronized_start_time()) |
| 174 trimmed = time_offset_; |
| 175 |
170 // Zero is always the start of the animation. | 176 // Zero is always the start of the animation. |
171 if (trimmed <= 0) | 177 if (trimmed <= 0) |
172 return 0; | 178 return 0; |
173 | 179 |
174 // Always return zero if we have no iterations. | 180 // Always return zero if we have no iterations. |
175 if (!iterations_) | 181 if (!iterations_) |
176 return 0; | 182 return 0; |
177 | 183 |
178 // Don't attempt to trim if we have no duration. | 184 // Don't attempt to trim if we have no duration. |
179 if (curve_->Duration() <= 0) | 185 if (curve_->Duration() <= 0) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // the main thread. | 235 // the main thread. |
230 if (run_state_ == Animation::Paused || | 236 if (run_state_ == Animation::Paused || |
231 other->run_state_ == Animation::Paused) { | 237 other->run_state_ == Animation::Paused) { |
232 other->run_state_ = run_state_; | 238 other->run_state_ = run_state_; |
233 other->pause_time_ = pause_time_; | 239 other->pause_time_ = pause_time_; |
234 other->total_paused_time_ = total_paused_time_; | 240 other->total_paused_time_ = total_paused_time_; |
235 } | 241 } |
236 } | 242 } |
237 | 243 |
238 } // namespace cc | 244 } // namespace cc |
OLD | NEW |