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

Side by Side Diff: cc/CCActiveAnimation.cpp

Issue 10961036: Gracefully handle zero duration curves in CCActiveAnimation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/CCActiveAnimationTest.cpp » ('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 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 "config.h" 5 #include "config.h"
6 6
7 #include "CCActiveAnimation.h" 7 #include "CCActiveAnimation.h"
8 8
9 #include "CCAnimationCurve.h" 9 #include "CCAnimationCurve.h"
10 #include "TraceEvent.h" 10 #include "TraceEvent.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 trimmed -= m_startTime + m_totalPausedTime; 147 trimmed -= m_startTime + m_totalPausedTime;
148 148
149 // Zero is always the start of the animation. 149 // Zero is always the start of the animation.
150 if (trimmed <= 0) 150 if (trimmed <= 0)
151 return 0; 151 return 0;
152 152
153 // Always return zero if we have no iterations. 153 // Always return zero if we have no iterations.
154 if (!m_iterations) 154 if (!m_iterations)
155 return 0; 155 return 0;
156 156
157 // Don't attempt to trim if we have no duration.
158 if (m_curve->duration() <= 0)
159 return 0;
160
157 // If less than an iteration duration, just return trimmed. 161 // If less than an iteration duration, just return trimmed.
158 if (trimmed < m_curve->duration()) 162 if (trimmed < m_curve->duration())
159 return trimmed; 163 return trimmed;
160 164
161 // If greater than or equal to the total duration, return iteration duration . 165 // If greater than or equal to the total duration, return iteration duration .
162 if (m_iterations >= 0 && trimmed >= m_curve->duration() * m_iterations) { 166 if (m_iterations >= 0 && trimmed >= m_curve->duration() * m_iterations) {
163 if (m_alternatesDirection && !(m_iterations % 2)) 167 if (m_alternatesDirection && !(m_iterations % 2))
164 return 0; 168 return 0;
165 return m_curve->duration(); 169 return m_curve->duration();
166 } 170 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 { 205 {
202 // Currently, we only push changes due to pausing and resuming animations on the main thread. 206 // Currently, we only push changes due to pausing and resuming animations on the main thread.
203 if (m_runState == CCActiveAnimation::Paused || other->m_runState == CCActive Animation::Paused) { 207 if (m_runState == CCActiveAnimation::Paused || other->m_runState == CCActive Animation::Paused) {
204 other->m_runState = m_runState; 208 other->m_runState = m_runState;
205 other->m_pauseTime = m_pauseTime; 209 other->m_pauseTime = m_pauseTime;
206 other->m_totalPausedTime = m_totalPausedTime; 210 other->m_totalPausedTime = m_totalPausedTime;
207 } 211 }
208 } 212 }
209 213
210 } // namespace cc 214 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/CCActiveAnimationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698