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 "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" |
| 11 #include "base/string_util.h" |
11 #include <cmath> | 12 #include <cmath> |
12 #include <wtf/Assertions.h> | 13 #include <wtf/Assertions.h> |
13 #include <wtf/StdLibExtras.h> | 14 #include <wtf/StdLibExtras.h> |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // This should match the RunState enum. | 18 // This should match the RunState enum. |
18 static const char* const s_runStateNames[] = { | 19 static const char* const s_runStateNames[] = { |
19 "WaitingForNextTick", | 20 "WaitingForNextTick", |
20 "WaitingForTargetAvailability", | 21 "WaitingForTargetAvailability", |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 if (m_runState == Running || m_runState == Paused) | 69 if (m_runState == Running || m_runState == Paused) |
69 setRunState(Aborted, 0); | 70 setRunState(Aborted, 0); |
70 } | 71 } |
71 | 72 |
72 void CCActiveAnimation::setRunState(RunState runState, double monotonicTime) | 73 void CCActiveAnimation::setRunState(RunState runState, double monotonicTime) |
73 { | 74 { |
74 if (m_suspended) | 75 if (m_suspended) |
75 return; | 76 return; |
76 | 77 |
77 char nameBuffer[256]; | 78 char nameBuffer[256]; |
78 snprintf(nameBuffer, sizeof(nameBuffer), "%s-%d%s", s_targetPropertyNames[m_
targetProperty], m_group, m_isControllingInstance ? "(impl)" : ""); | 79 base::snprintf(nameBuffer, sizeof(nameBuffer), "%s-%d%s", s_targetPropertyNa
mes[m_targetProperty], m_group, m_isControllingInstance ? "(impl)" : ""); |
79 | 80 |
80 bool isWaitingToStart = m_runState == WaitingForNextTick | 81 bool isWaitingToStart = m_runState == WaitingForNextTick |
81 || m_runState == WaitingForTargetAvailability | 82 || m_runState == WaitingForTargetAvailability |
82 || m_runState == WaitingForStartTime; | 83 || m_runState == WaitingForStartTime; |
83 | 84 |
84 if (isWaitingToStart && runState == Running) | 85 if (isWaitingToStart && runState == Running) |
85 TRACE_EVENT_ASYNC_BEGIN1("cc", "CCActiveAnimation", this, "Name", TRACE_
STR_COPY(nameBuffer)); | 86 TRACE_EVENT_ASYNC_BEGIN1("cc", "CCActiveAnimation", this, "Name", TRACE_
STR_COPY(nameBuffer)); |
86 | 87 |
87 bool wasFinished = isFinished(); | 88 bool wasFinished = isFinished(); |
88 | 89 |
89 const char* oldRunStateName = s_runStateNames[m_runState]; | 90 const char* oldRunStateName = s_runStateNames[m_runState]; |
90 | 91 |
91 if (runState == Running && m_runState == Paused) | 92 if (runState == Running && m_runState == Paused) |
92 m_totalPausedTime += monotonicTime - m_pauseTime; | 93 m_totalPausedTime += monotonicTime - m_pauseTime; |
93 else if (runState == Paused) | 94 else if (runState == Paused) |
94 m_pauseTime = monotonicTime; | 95 m_pauseTime = monotonicTime; |
95 m_runState = runState; | 96 m_runState = runState; |
96 | 97 |
97 const char* newRunStateName = s_runStateNames[runState]; | 98 const char* newRunStateName = s_runStateNames[runState]; |
98 | 99 |
99 if (!wasFinished && isFinished()) | 100 if (!wasFinished && isFinished()) |
100 TRACE_EVENT_ASYNC_END0("cc", "CCActiveAnimation", this); | 101 TRACE_EVENT_ASYNC_END0("cc", "CCActiveAnimation", this); |
101 | 102 |
102 char stateBuffer[256]; | 103 char stateBuffer[256]; |
103 snprintf(stateBuffer, sizeof(stateBuffer), "%s->%s", oldRunStateName, newRun
StateName); | 104 base::snprintf(stateBuffer, sizeof(stateBuffer), "%s->%s", oldRunStateName,
newRunStateName); |
104 | 105 |
105 TRACE_EVENT_INSTANT2("cc", "CCLayerAnimationController::setRunState", "Name"
, TRACE_STR_COPY(nameBuffer), "State", TRACE_STR_COPY(stateBuffer)); | 106 TRACE_EVENT_INSTANT2("cc", "CCLayerAnimationController::setRunState", "Name"
, TRACE_STR_COPY(nameBuffer), "State", TRACE_STR_COPY(stateBuffer)); |
106 } | 107 } |
107 | 108 |
108 void CCActiveAnimation::suspend(double monotonicTime) | 109 void CCActiveAnimation::suspend(double monotonicTime) |
109 { | 110 { |
110 setRunState(Paused, monotonicTime); | 111 setRunState(Paused, monotonicTime); |
111 m_suspended = true; | 112 m_suspended = true; |
112 } | 113 } |
113 | 114 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 { | 198 { |
198 // Currently, we only push changes due to pausing and resuming animations on
the main thread. | 199 // Currently, we only push changes due to pausing and resuming animations on
the main thread. |
199 if (m_runState == CCActiveAnimation::Paused || other->m_runState == CCActive
Animation::Paused) { | 200 if (m_runState == CCActiveAnimation::Paused || other->m_runState == CCActive
Animation::Paused) { |
200 other->m_runState = m_runState; | 201 other->m_runState = m_runState; |
201 other->m_pauseTime = m_pauseTime; | 202 other->m_pauseTime = m_pauseTime; |
202 other->m_totalPausedTime = m_totalPausedTime; | 203 other->m_totalPausedTime = m_totalPausedTime; |
203 } | 204 } |
204 } | 205 } |
205 | 206 |
206 } // namespace WebCore | 207 } // namespace WebCore |
OLD | NEW |