| 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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 Animation::~Animation() { | 76 Animation::~Animation() { |
| 77 if (run_state_ == Running || run_state_ == Paused) | 77 if (run_state_ == Running || run_state_ == Paused) |
| 78 SetRunState(Aborted, 0); | 78 SetRunState(Aborted, 0); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void Animation::SetRunState(RunState run_state, double monotonic_time) { | 81 void Animation::SetRunState(RunState run_state, double monotonic_time) { |
| 82 if (suspended_) | 82 if (suspended_) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 char nameBuffer[256]; | 85 char name_buffer[256]; |
| 86 base::snprintf(nameBuffer, | 86 base::snprintf(name_buffer, |
| 87 sizeof(nameBuffer), | 87 sizeof(name_buffer), |
| 88 "%s-%d%s", | 88 "%s-%d%s", |
| 89 s_targetPropertyNames[target_property_], | 89 s_targetPropertyNames[target_property_], |
| 90 group_, | 90 group_, |
| 91 is_controlling_instance_ ? "(impl)" : ""); | 91 is_controlling_instance_ ? "(impl)" : ""); |
| 92 | 92 |
| 93 bool is_waiting_to_start = run_state_ == WaitingForNextTick || | 93 bool is_waiting_to_start = run_state_ == WaitingForNextTick || |
| 94 run_state_ == WaitingForTargetAvailability || | 94 run_state_ == WaitingForTargetAvailability || |
| 95 run_state_ == WaitingForStartTime || | 95 run_state_ == WaitingForStartTime || |
| 96 run_state_ == Starting; | 96 run_state_ == Starting; |
| 97 | 97 |
| 98 if (is_waiting_to_start && run_state == Running) { | 98 if (is_waiting_to_start && run_state == Running) { |
| 99 TRACE_EVENT_ASYNC_BEGIN1( | 99 TRACE_EVENT_ASYNC_BEGIN1( |
| 100 "cc", "Animation", this, "Name", TRACE_STR_COPY(nameBuffer)); | 100 "cc", "Animation", this, "Name", TRACE_STR_COPY(name_buffer)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool was_finished = is_finished(); | 103 bool was_finished = is_finished(); |
| 104 | 104 |
| 105 const char* old_run_state_name = s_runStateNames[run_state_]; | 105 const char* old_run_state_name = s_runStateNames[run_state_]; |
| 106 | 106 |
| 107 if (run_state == Running && run_state_ == Paused) | 107 if (run_state == Running && run_state_ == Paused) |
| 108 total_paused_time_ += monotonic_time - pause_time_; | 108 total_paused_time_ += monotonic_time - pause_time_; |
| 109 else if (run_state == Paused) | 109 else if (run_state == Paused) |
| 110 pause_time_ = monotonic_time; | 110 pause_time_ = monotonic_time; |
| 111 run_state_ = run_state; | 111 run_state_ = run_state; |
| 112 | 112 |
| 113 const char* new_run_state_name = s_runStateNames[run_state]; | 113 const char* new_run_state_name = s_runStateNames[run_state]; |
| 114 | 114 |
| 115 if (!was_finished && is_finished()) | 115 if (!was_finished && is_finished()) |
| 116 TRACE_EVENT_ASYNC_END0("cc", "Animation", this); | 116 TRACE_EVENT_ASYNC_END0("cc", "Animation", this); |
| 117 | 117 |
| 118 char stateBuffer[256]; | 118 char state_buffer[256]; |
| 119 base::snprintf(stateBuffer, | 119 base::snprintf(state_buffer, |
| 120 sizeof(stateBuffer), | 120 sizeof(state_buffer), |
| 121 "%s->%s", | 121 "%s->%s", |
| 122 old_run_state_name, | 122 old_run_state_name, |
| 123 new_run_state_name); | 123 new_run_state_name); |
| 124 | 124 |
| 125 TRACE_EVENT_INSTANT2("cc", | 125 TRACE_EVENT_INSTANT2("cc", |
| 126 "LayerAnimationController::setRunState", | 126 "LayerAnimationController::SetRunState", |
| 127 "Name", | 127 "Name", |
| 128 TRACE_STR_COPY(nameBuffer), | 128 TRACE_STR_COPY(name_buffer), |
| 129 "State", | 129 "State", |
| 130 TRACE_STR_COPY(stateBuffer)); | 130 TRACE_STR_COPY(state_buffer)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void Animation::Suspend(double monotonic_time) { | 133 void Animation::Suspend(double monotonic_time) { |
| 134 SetRunState(Paused, monotonic_time); | 134 SetRunState(Paused, monotonic_time); |
| 135 suspended_ = true; | 135 suspended_ = true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void Animation::Resume(double monotonic_time) { | 138 void Animation::Resume(double monotonic_time) { |
| 139 suspended_ = false; | 139 suspended_ = false; |
| 140 SetRunState(Running, monotonic_time); | 140 SetRunState(Running, monotonic_time); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // the main thread. | 227 // the main thread. |
| 228 if (run_state_ == Animation::Paused || | 228 if (run_state_ == Animation::Paused || |
| 229 other->run_state_ == Animation::Paused) { | 229 other->run_state_ == Animation::Paused) { |
| 230 other->run_state_ = run_state_; | 230 other->run_state_ = run_state_; |
| 231 other->pause_time_ = pause_time_; | 231 other->pause_time_ = pause_time_; |
| 232 other->total_paused_time_ = total_paused_time_; | 232 other->total_paused_time_ = total_paused_time_; |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace cc | 236 } // namespace cc |
| OLD | NEW |