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

Unified Diff: cc/animation/animation.cc

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_curve.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation.cc
diff --git a/cc/animation/animation.cc b/cc/animation/animation.cc
index 96cb40ae712fbb5855723646424ec0f36e1aad61..48ebc74b757bac51088aa3c8c9e0cef89ed9e5bf 100644
--- a/cc/animation/animation.cc
+++ b/cc/animation/animation.cc
@@ -14,28 +14,32 @@
namespace {
// This should match the RunState enum.
-static const char* const s_runStateNames[] = {"WAITING_FOR_TARGET_AVAILABILITY",
- "WAITING_FOR_DELETION",
- "STARTING",
- "RUNNING",
- "PAUSED",
- "FINISHED",
- "ABORTED"};
-
-static_assert(static_cast<int>(cc::Animation::LAST_RUN_STATE) + 1 ==
- arraysize(s_runStateNames),
+static const char* const s_runStateNames[] = {
+ "WaitingForTargetAvailability",
+ "WaitingForDeletion",
+ "Starting",
+ "Running",
+ "Paused",
+ "Finished",
+ "Aborted"
+};
+
+static_assert(static_cast<int>(cc::Animation::RunStateEnumSize) ==
+ arraysize(s_runStateNames),
"RunStateEnumSize should equal the number of elements in "
"s_runStateNames");
// This should match the TargetProperty enum.
-static const char* const s_targetPropertyNames[] = {"TRANSFORM",
- "OPACITY",
- "FILTER",
- "SCROLL_OFFSET",
- "BACKGROUND_COLOR"};
-
-static_assert(static_cast<int>(cc::Animation::LAST_TARGET_PROPERTY) + 1 ==
- arraysize(s_targetPropertyNames),
+static const char* const s_targetPropertyNames[] = {
+ "Transform",
+ "Opacity",
+ "Filter",
+ "ScrollOffset",
+ "BackgroundColor"
+};
+
+static_assert(static_cast<int>(cc::Animation::TargetPropertyEnumSize) ==
+ arraysize(s_targetPropertyNames),
"TargetPropertyEnumSize should equal the number of elements in "
"s_targetPropertyNames");
@@ -61,12 +65,12 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve,
id_(animation_id),
group_(group_id),
target_property_(target_property),
- run_state_(WAITING_FOR_TARGET_AVAILABILITY),
+ run_state_(WaitingForTargetAvailability),
iterations_(1),
iteration_start_(0),
- direction_(DIRECTION_NORMAL),
+ direction_(Normal),
playback_rate_(1),
- fill_mode_(FILL_MODE_BOTH),
+ fill_mode_(FillModeBoth),
needs_synchronized_start_time_(false),
received_finished_event_(false),
suspended_(false),
@@ -77,8 +81,8 @@ Animation::Animation(scoped_ptr<AnimationCurve> curve,
}
Animation::~Animation() {
- if (run_state_ == RUNNING || run_state_ == PAUSED)
- SetRunState(ABORTED, base::TimeTicks());
+ if (run_state_ == Running || run_state_ == Paused)
+ SetRunState(Aborted, base::TimeTicks());
}
void Animation::SetRunState(RunState run_state,
@@ -93,10 +97,10 @@ void Animation::SetRunState(RunState run_state,
s_targetPropertyNames[target_property_],
group_);
- bool is_waiting_to_start =
- run_state_ == WAITING_FOR_TARGET_AVAILABILITY || run_state_ == STARTING;
+ bool is_waiting_to_start = run_state_ == WaitingForTargetAvailability ||
+ run_state_ == Starting;
- if (is_controlling_instance_ && is_waiting_to_start && run_state == RUNNING) {
+ if (is_controlling_instance_ && is_waiting_to_start && run_state == Running) {
TRACE_EVENT_ASYNC_BEGIN1(
"cc", "Animation", this, "Name", TRACE_STR_COPY(name_buffer));
}
@@ -105,9 +109,9 @@ void Animation::SetRunState(RunState run_state,
const char* old_run_state_name = s_runStateNames[run_state_];
- if (run_state == RUNNING && run_state_ == PAUSED)
+ if (run_state == Running && run_state_ == Paused)
total_paused_time_ += (monotonic_time - pause_time_);
- else if (run_state == PAUSED)
+ else if (run_state == Paused)
pause_time_ = monotonic_time;
run_state_ = run_state;
@@ -133,13 +137,13 @@ void Animation::SetRunState(RunState run_state,
}
void Animation::Suspend(base::TimeTicks monotonic_time) {
- SetRunState(PAUSED, monotonic_time);
+ SetRunState(Paused, monotonic_time);
suspended_ = true;
}
void Animation::Resume(base::TimeTicks monotonic_time) {
suspended_ = false;
- SetRunState(RUNNING, monotonic_time);
+ SetRunState(Running, monotonic_time);
}
bool Animation::IsFinishedAt(base::TimeTicks monotonic_time) const {
@@ -152,7 +156,7 @@ bool Animation::IsFinishedAt(base::TimeTicks monotonic_time) const {
if (playback_rate_ == 0)
return false;
- return run_state_ == RUNNING && iterations_ >= 0 &&
+ return run_state_ == Running && iterations_ >= 0 &&
TimeUtil::Scale(curve_->Duration(),
iterations_ / std::abs(playback_rate_)) <=
(monotonic_time + time_offset_ - start_time_ - total_paused_time_);
@@ -160,7 +164,7 @@ bool Animation::IsFinishedAt(base::TimeTicks monotonic_time) const {
bool Animation::InEffect(base::TimeTicks monotonic_time) const {
return ConvertToActiveTime(monotonic_time) >= base::TimeDelta() ||
- (fill_mode_ == FILL_MODE_BOTH || fill_mode_ == FILL_MODE_BACKWARDS);
+ (fill_mode_ == FillModeBoth || fill_mode_ == FillModeBackwards);
}
base::TimeDelta Animation::ConvertToActiveTime(
@@ -168,7 +172,7 @@ base::TimeDelta Animation::ConvertToActiveTime(
base::TimeTicks trimmed = monotonic_time + time_offset_;
// If we're paused, time is 'stuck' at the pause time.
- if (run_state_ == PAUSED)
+ if (run_state_ == Paused)
trimmed = pause_time_;
// Returned time should always be relative to the start time and should
@@ -177,7 +181,7 @@ base::TimeDelta Animation::ConvertToActiveTime(
// If we're just starting or we're waiting on receiving a start time,
// time is 'stuck' at the initial state.
- if ((run_state_ == STARTING && !has_set_start_time()) ||
+ if ((run_state_ == Starting && !has_set_start_time()) ||
needs_synchronized_start_time())
trimmed = base::TimeTicks() + time_offset_;
@@ -243,10 +247,9 @@ base::TimeDelta Animation::TrimTimeToCurrentIteration(
// Check if we are running the animation in reverse direction for the current
// iteration
- bool reverse =
- (direction_ == DIRECTION_REVERSE) ||
- (direction_ == DIRECTION_ALTERNATE && iteration % 2 == 1) ||
- (direction_ == DIRECTION_ALTERNATE_REVERSE && iteration % 2 == 0);
+ bool reverse = (direction_ == Reverse) ||
+ (direction_ == Alternate && iteration % 2 == 1) ||
+ (direction_ == AlternateReverse && iteration % 2 == 0);
// If we are running the animation in reverse direction, reverse the result
if (reverse)
@@ -277,8 +280,8 @@ scoped_ptr<Animation> Animation::CloneAndInitialize(
void Animation::PushPropertiesTo(Animation* other) const {
// Currently, we only push changes due to pausing and resuming animations on
// the main thread.
- if (run_state_ == Animation::PAUSED ||
- other->run_state_ == Animation::PAUSED) {
+ if (run_state_ == Animation::Paused ||
+ other->run_state_ == Animation::Paused) {
other->run_state_ = run_state_;
other->pause_time_ = pause_time_;
other->total_paused_time_ = total_paused_time_;
« no previous file with comments | « cc/animation/animation.h ('k') | cc/animation/animation_curve.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698