diff options
-rw-r--r-- | cc/active_animation_unittest.cc | 218 | ||||
-rw-r--r-- | cc/animation.cc (renamed from cc/active_animation.cc) | 38 | ||||
-rw-r--r-- | cc/animation.h (renamed from cc/active_animation.h) | 26 | ||||
-rw-r--r-- | cc/animation_events.h | 6 | ||||
-rw-r--r-- | cc/animation_unittest.cc | 218 | ||||
-rw-r--r-- | cc/cc.gyp | 4 | ||||
-rw-r--r-- | cc/cc_tests.gyp | 2 | ||||
-rw-r--r-- | cc/layer.cc | 8 | ||||
-rw-r--r-- | cc/layer.h | 4 | ||||
-rw-r--r-- | cc/layer_animation_controller.cc | 80 | ||||
-rw-r--r-- | cc/layer_animation_controller.h | 12 | ||||
-rw-r--r-- | cc/layer_animation_controller_unittest.cc | 134 | ||||
-rw-r--r-- | cc/layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest_animation.cc | 26 | ||||
-rw-r--r-- | cc/layer_unittest.cc | 2 | ||||
-rw-r--r-- | cc/test/animation_test_common.cc | 6 | ||||
-rw-r--r-- | cc/test/animation_test_common.h | 2 | ||||
-rw-r--r-- | cc/test/layer_tree_test_common.cc | 2 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_animation_impl.cc | 10 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_animation_impl.h | 6 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_layer_impl.cc | 6 |
21 files changed, 407 insertions, 407 deletions
diff --git a/cc/active_animation_unittest.cc b/cc/active_animation_unittest.cc deleted file mode 100644 index 58961a7..0000000 --- a/cc/active_animation_unittest.cc +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "cc/active_animation.h" - -#include "cc/test/animation_test_common.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace cc { -namespace { - -scoped_ptr<ActiveAnimation> createActiveAnimation(int iterations, double duration) -{ - scoped_ptr<ActiveAnimation> toReturn(ActiveAnimation::create(make_scoped_ptr(new FakeFloatAnimationCurve(duration)).PassAs<AnimationCurve>(), 0, 1, ActiveAnimation::Opacity)); - toReturn->setIterations(iterations); - return toReturn.Pass(); -} - -scoped_ptr<ActiveAnimation> createActiveAnimation(int iterations) -{ - return createActiveAnimation(iterations, 1); -} - -TEST(ActiveAnimationTest, TrimTimeZeroIterations) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(0)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); -} - -TEST(ActiveAnimationTest, TrimTimeOneIteration) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(2)); -} - -TEST(ActiveAnimationTest, TrimTimeInfiniteIterations) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(-1)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1.5)); -} - -TEST(ActiveAnimationTest, TrimTimeAlternating) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(-1)); - anim->setAlternatesDirection(true); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); - EXPECT_EQ(0.75, anim->trimTimeToCurrentIteration(1.25)); -} - -TEST(ActiveAnimationTest, TrimTimeStartTime) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setStartTime(4); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(4.5)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(5)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(6)); -} - -TEST(ActiveAnimationTest, TrimTimeTimeOffset) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setTimeOffset(4); - anim->setStartTime(4); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); -} - -TEST(ActiveAnimationTest, TrimTimePauseResume) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); - anim->setRunState(ActiveAnimation::Paused, 0.5); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); - anim->setRunState(ActiveAnimation::Running, 1024); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5)); -} - -TEST(ActiveAnimationTest, TrimTimeSuspendResume) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); - anim->suspend(0.5); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); - anim->resume(1024); - EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); - EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5)); -} - -TEST(ActiveAnimationTest, TrimTimeZeroDuration) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(0, 0)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); - EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); -} - -TEST(ActiveAnimationTest, IsFinishedAtZeroIterations) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(0)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_FALSE(anim->isFinishedAt(-1)); - EXPECT_TRUE(anim->isFinishedAt(0)); - EXPECT_TRUE(anim->isFinishedAt(1)); -} - -TEST(ActiveAnimationTest, IsFinishedAtOneIteration) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_FALSE(anim->isFinishedAt(-1)); - EXPECT_FALSE(anim->isFinishedAt(0)); - EXPECT_TRUE(anim->isFinishedAt(1)); - EXPECT_TRUE(anim->isFinishedAt(2)); -} - -TEST(ActiveAnimationTest, IsFinishedAtInfiniteIterations) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(-1)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_FALSE(anim->isFinishedAt(0)); - EXPECT_FALSE(anim->isFinishedAt(0.5)); - EXPECT_FALSE(anim->isFinishedAt(1)); - EXPECT_FALSE(anim->isFinishedAt(1.5)); -} - -TEST(ActiveAnimationTest, IsFinishedAtNotRunning) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(0)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_TRUE(anim->isFinishedAt(0)); - anim->setRunState(ActiveAnimation::Paused, 0); - EXPECT_FALSE(anim->isFinishedAt(0)); - anim->setRunState(ActiveAnimation::WaitingForNextTick, 0); - EXPECT_FALSE(anim->isFinishedAt(0)); - anim->setRunState(ActiveAnimation::WaitingForTargetAvailability, 0); - EXPECT_FALSE(anim->isFinishedAt(0)); - anim->setRunState(ActiveAnimation::WaitingForStartTime, 0); - EXPECT_FALSE(anim->isFinishedAt(0)); - anim->setRunState(ActiveAnimation::Finished, 0); - EXPECT_TRUE(anim->isFinishedAt(0)); - anim->setRunState(ActiveAnimation::Aborted, 0); - EXPECT_TRUE(anim->isFinishedAt(0)); -} - -TEST(ActiveAnimationTest, IsFinished) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::Paused, 0); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::WaitingForNextTick, 0); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::WaitingForTargetAvailability, 0); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::WaitingForStartTime, 0); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::Finished, 0); - EXPECT_TRUE(anim->isFinished()); - anim->setRunState(ActiveAnimation::Aborted, 0); - EXPECT_TRUE(anim->isFinished()); -} - -TEST(ActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->setRunState(ActiveAnimation::Running, 2); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::Paused, 2); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::WaitingForNextTick, 2); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::WaitingForTargetAvailability, 2); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::WaitingForStartTime, 2); - EXPECT_FALSE(anim->isFinished()); - anim->setRunState(ActiveAnimation::Finished, 0); - EXPECT_TRUE(anim->isFinished()); - anim->setRunState(ActiveAnimation::Aborted, 0); - EXPECT_TRUE(anim->isFinished()); -} - -TEST(ActiveAnimationTest, RunStateChangesIgnoredWhileSuspended) -{ - scoped_ptr<ActiveAnimation> anim(createActiveAnimation(1)); - anim->suspend(0); - EXPECT_EQ(ActiveAnimation::Paused, anim->runState()); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_EQ(ActiveAnimation::Paused, anim->runState()); - anim->resume(0); - anim->setRunState(ActiveAnimation::Running, 0); - EXPECT_EQ(ActiveAnimation::Running, anim->runState()); -} - -} // namespace -} // namespace cc diff --git a/cc/active_animation.cc b/cc/animation.cc index bdc2c8d..e5279b0 100644 --- a/cc/active_animation.cc +++ b/cc/animation.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "cc/active_animation.h" +#include "cc/animation.h" #include <cmath> @@ -24,7 +24,7 @@ static const char* const s_runStateNames[] = { "Aborted" }; -COMPILE_ASSERT(static_cast<int>(cc::ActiveAnimation::RunStateEnumSize) == arraysize(s_runStateNames), RunState_names_match_enum); +COMPILE_ASSERT(static_cast<int>(cc::Animation::RunStateEnumSize) == arraysize(s_runStateNames), RunState_names_match_enum); // This should match the TargetProperty enum. static const char* const s_targetPropertyNames[] = { @@ -32,18 +32,18 @@ static const char* const s_targetPropertyNames[] = { "Opacity" }; -COMPILE_ASSERT(static_cast<int>(cc::ActiveAnimation::TargetPropertyEnumSize) == arraysize(s_targetPropertyNames), TargetProperty_names_match_enum); +COMPILE_ASSERT(static_cast<int>(cc::Animation::TargetPropertyEnumSize) == arraysize(s_targetPropertyNames), TargetProperty_names_match_enum); } // namespace namespace cc { -scoped_ptr<ActiveAnimation> ActiveAnimation::create(scoped_ptr<AnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) +scoped_ptr<Animation> Animation::create(scoped_ptr<AnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) { - return make_scoped_ptr(new ActiveAnimation(curve.Pass(), animationId, groupId, targetProperty)); + return make_scoped_ptr(new Animation(curve.Pass(), animationId, groupId, targetProperty)); } -ActiveAnimation::ActiveAnimation(scoped_ptr<AnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) +Animation::Animation(scoped_ptr<AnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) : m_curve(curve.Pass()) , m_id(animationId) , m_group(groupId) @@ -61,13 +61,13 @@ ActiveAnimation::ActiveAnimation(scoped_ptr<AnimationCurve> curve, int animation { } -ActiveAnimation::~ActiveAnimation() +Animation::~Animation() { if (m_runState == Running || m_runState == Paused) setRunState(Aborted, 0); } -void ActiveAnimation::setRunState(RunState runState, double monotonicTime) +void Animation::setRunState(RunState runState, double monotonicTime) { if (m_suspended) return; @@ -80,7 +80,7 @@ void ActiveAnimation::setRunState(RunState runState, double monotonicTime) || m_runState == WaitingForStartTime; if (isWaitingToStart && runState == Running) - TRACE_EVENT_ASYNC_BEGIN1("cc", "ActiveAnimation", this, "Name", TRACE_STR_COPY(nameBuffer)); + TRACE_EVENT_ASYNC_BEGIN1("cc", "Animation", this, "Name", TRACE_STR_COPY(nameBuffer)); bool wasFinished = isFinished(); @@ -95,7 +95,7 @@ void ActiveAnimation::setRunState(RunState runState, double monotonicTime) const char* newRunStateName = s_runStateNames[runState]; if (!wasFinished && isFinished()) - TRACE_EVENT_ASYNC_END0("cc", "ActiveAnimation", this); + TRACE_EVENT_ASYNC_END0("cc", "Animation", this); char stateBuffer[256]; base::snprintf(stateBuffer, sizeof(stateBuffer), "%s->%s", oldRunStateName, newRunStateName); @@ -103,19 +103,19 @@ void ActiveAnimation::setRunState(RunState runState, double monotonicTime) TRACE_EVENT_INSTANT2("cc", "LayerAnimationController::setRunState", "Name", TRACE_STR_COPY(nameBuffer), "State", TRACE_STR_COPY(stateBuffer)); } -void ActiveAnimation::suspend(double monotonicTime) +void Animation::suspend(double monotonicTime) { setRunState(Paused, monotonicTime); m_suspended = true; } -void ActiveAnimation::resume(double monotonicTime) +void Animation::resume(double monotonicTime) { m_suspended = false; setRunState(Running, monotonicTime); } -bool ActiveAnimation::isFinishedAt(double monotonicTime) const +bool Animation::isFinishedAt(double monotonicTime) const { if (isFinished()) return true; @@ -128,7 +128,7 @@ bool ActiveAnimation::isFinishedAt(double monotonicTime) const && m_iterations * m_curve->duration() <= monotonicTime - startTime() - m_totalPausedTime; } -double ActiveAnimation::trimTimeToCurrentIteration(double monotonicTime) const +double Animation::trimTimeToCurrentIteration(double monotonicTime) const { double trimmed = monotonicTime + m_timeOffset; @@ -176,14 +176,14 @@ double ActiveAnimation::trimTimeToCurrentIteration(double monotonicTime) const return trimmed; } -scoped_ptr<ActiveAnimation> ActiveAnimation::clone(InstanceType instanceType) const +scoped_ptr<Animation> Animation::clone(InstanceType instanceType) const { return cloneAndInitialize(instanceType, m_runState, m_startTime); } -scoped_ptr<ActiveAnimation> ActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const +scoped_ptr<Animation> Animation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const { - scoped_ptr<ActiveAnimation> toReturn(new ActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty)); + scoped_ptr<Animation> toReturn(new Animation(m_curve->clone(), m_id, m_group, m_targetProperty)); toReturn->m_runState = initialRunState; toReturn->m_iterations = m_iterations; toReturn->m_startTime = startTime; @@ -195,10 +195,10 @@ scoped_ptr<ActiveAnimation> ActiveAnimation::cloneAndInitialize(InstanceType ins return toReturn.Pass(); } -void ActiveAnimation::pushPropertiesTo(ActiveAnimation* other) const +void Animation::pushPropertiesTo(Animation* other) const { // Currently, we only push changes due to pausing and resuming animations on the main thread. - if (m_runState == ActiveAnimation::Paused || other->m_runState == ActiveAnimation::Paused) { + if (m_runState == Animation::Paused || other->m_runState == Animation::Paused) { other->m_runState = m_runState; other->m_pauseTime = m_pauseTime; other->m_totalPausedTime = m_totalPausedTime; diff --git a/cc/active_animation.h b/cc/animation.h index 413e9f2..cd45d4e 100644 --- a/cc/active_animation.h +++ b/cc/animation.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CC_ACTIVE_ANIMATION_H_ -#define CC_ACTIVE_ANIMATION_H_ +#ifndef CC_ANIMATION_H_ +#define CC_ANIMATION_H_ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" @@ -13,10 +13,10 @@ namespace cc { class AnimationCurve; -// An ActiveAnimation, contains all the state required to play an AnimationCurve. +// An Animation, contains all the state required to play an AnimationCurve. // Specifically, the affected property, the run state (paused, finished, etc.), // loop count, last pause time, and the total time spent paused. -class CC_EXPORT ActiveAnimation { +class CC_EXPORT Animation { public: // Animations begin in one of the 'waiting' states. Animations waiting for the next tick // will start the next time the controller animates. Animations waiting for target @@ -47,9 +47,9 @@ public: TargetPropertyEnumSize }; - static scoped_ptr<ActiveAnimation> create(scoped_ptr<AnimationCurve>, int animationId, int groupId, TargetProperty); + static scoped_ptr<Animation> create(scoped_ptr<AnimationCurve>, int animationId, int groupId, TargetProperty); - virtual ~ActiveAnimation(); + virtual ~Animation(); int id() const { return m_id; } int group() const { return m_group; } @@ -100,14 +100,14 @@ public: NonControllingInstance }; - scoped_ptr<ActiveAnimation> clone(InstanceType) const; - scoped_ptr<ActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; + scoped_ptr<Animation> clone(InstanceType) const; + scoped_ptr<Animation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; bool isControllingInstance() const { return m_isControllingInstance; } - void pushPropertiesTo(ActiveAnimation*) const; + void pushPropertiesTo(Animation*) const; private: - ActiveAnimation(scoped_ptr<AnimationCurve>, int animationId, int groupId, TargetProperty); + Animation(scoped_ptr<AnimationCurve>, int animationId, int groupId, TargetProperty); scoped_ptr<AnimationCurve> m_curve; @@ -147,16 +147,16 @@ private: // Animations lead dual lives. An active animation will be conceptually owned by // two controllers, one on the impl thread and one on the main. In reality, there - // will be two separate ActiveAnimation instances for the same animation. They + // will be two separate Animation instances for the same animation. They // will have the same group id and the same target property (these two values // uniquely identify an animation). The instance on the impl thread is the instance // that ultimately controls the values of the animating layer and so we will refer // to it as the 'controlling instance'. bool m_isControllingInstance; - DISALLOW_COPY_AND_ASSIGN(ActiveAnimation); + DISALLOW_COPY_AND_ASSIGN(Animation); }; } // namespace cc -#endif // CC_ACTIVE_ANIMATION_H_ +#endif // CC_ANIMATION_H_ diff --git a/cc/animation_events.h b/cc/animation_events.h index 2658c98..69b44bc 100644 --- a/cc/animation_events.h +++ b/cc/animation_events.h @@ -7,14 +7,14 @@ #include <vector> -#include "cc/active_animation.h" +#include "cc/animation.h" namespace cc { struct AnimationEvent { enum Type { Started, Finished }; - AnimationEvent(Type type, int layerId, int groupId, ActiveAnimation::TargetProperty targetProperty, double monotonicTime) + AnimationEvent(Type type, int layerId, int groupId, Animation::TargetProperty targetProperty, double monotonicTime) : type(type) , layerId(layerId) , groupId(groupId) @@ -26,7 +26,7 @@ struct AnimationEvent { Type type; int layerId; int groupId; - ActiveAnimation::TargetProperty targetProperty; + Animation::TargetProperty targetProperty; double monotonicTime; }; diff --git a/cc/animation_unittest.cc b/cc/animation_unittest.cc new file mode 100644 index 0000000..d767f70 --- /dev/null +++ b/cc/animation_unittest.cc @@ -0,0 +1,218 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/animation.h" + +#include "cc/test/animation_test_common.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace cc { +namespace { + +scoped_ptr<Animation> createAnimation(int iterations, double duration) +{ + scoped_ptr<Animation> toReturn(Animation::create(make_scoped_ptr(new FakeFloatAnimationCurve(duration)).PassAs<AnimationCurve>(), 0, 1, Animation::Opacity)); + toReturn->setIterations(iterations); + return toReturn.Pass(); +} + +scoped_ptr<Animation> createAnimation(int iterations) +{ + return createAnimation(iterations, 1); +} + +TEST(AnimationTest, TrimTimeZeroIterations) +{ + scoped_ptr<Animation> anim(createAnimation(0)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); +} + +TEST(AnimationTest, TrimTimeOneIteration) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(2)); +} + +TEST(AnimationTest, TrimTimeInfiniteIterations) +{ + scoped_ptr<Animation> anim(createAnimation(-1)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1.5)); +} + +TEST(AnimationTest, TrimTimeAlternating) +{ + scoped_ptr<Animation> anim(createAnimation(-1)); + anim->setAlternatesDirection(true); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); + EXPECT_EQ(0.75, anim->trimTimeToCurrentIteration(1.25)); +} + +TEST(AnimationTest, TrimTimeStartTime) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setStartTime(4); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(4.5)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(5)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(6)); +} + +TEST(AnimationTest, TrimTimeTimeOffset) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setTimeOffset(4); + anim->setStartTime(4); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); +} + +TEST(AnimationTest, TrimTimePauseResume) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setRunState(Animation::Running, 0); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + anim->setRunState(Animation::Paused, 0.5); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); + anim->setRunState(Animation::Running, 1024); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5)); +} + +TEST(AnimationTest, TrimTimeSuspendResume) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setRunState(Animation::Running, 0); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); + anim->suspend(0.5); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); + anim->resume(1024); + EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(1024)); + EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5)); +} + +TEST(AnimationTest, TrimTimeZeroDuration) +{ + scoped_ptr<Animation> anim(createAnimation(0, 0)); + anim->setRunState(Animation::Running, 0); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); + EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); +} + +TEST(AnimationTest, IsFinishedAtZeroIterations) +{ + scoped_ptr<Animation> anim(createAnimation(0)); + anim->setRunState(Animation::Running, 0); + EXPECT_FALSE(anim->isFinishedAt(-1)); + EXPECT_TRUE(anim->isFinishedAt(0)); + EXPECT_TRUE(anim->isFinishedAt(1)); +} + +TEST(AnimationTest, IsFinishedAtOneIteration) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setRunState(Animation::Running, 0); + EXPECT_FALSE(anim->isFinishedAt(-1)); + EXPECT_FALSE(anim->isFinishedAt(0)); + EXPECT_TRUE(anim->isFinishedAt(1)); + EXPECT_TRUE(anim->isFinishedAt(2)); +} + +TEST(AnimationTest, IsFinishedAtInfiniteIterations) +{ + scoped_ptr<Animation> anim(createAnimation(-1)); + anim->setRunState(Animation::Running, 0); + EXPECT_FALSE(anim->isFinishedAt(0)); + EXPECT_FALSE(anim->isFinishedAt(0.5)); + EXPECT_FALSE(anim->isFinishedAt(1)); + EXPECT_FALSE(anim->isFinishedAt(1.5)); +} + +TEST(AnimationTest, IsFinishedAtNotRunning) +{ + scoped_ptr<Animation> anim(createAnimation(0)); + anim->setRunState(Animation::Running, 0); + EXPECT_TRUE(anim->isFinishedAt(0)); + anim->setRunState(Animation::Paused, 0); + EXPECT_FALSE(anim->isFinishedAt(0)); + anim->setRunState(Animation::WaitingForNextTick, 0); + EXPECT_FALSE(anim->isFinishedAt(0)); + anim->setRunState(Animation::WaitingForTargetAvailability, 0); + EXPECT_FALSE(anim->isFinishedAt(0)); + anim->setRunState(Animation::WaitingForStartTime, 0); + EXPECT_FALSE(anim->isFinishedAt(0)); + anim->setRunState(Animation::Finished, 0); + EXPECT_TRUE(anim->isFinishedAt(0)); + anim->setRunState(Animation::Aborted, 0); + EXPECT_TRUE(anim->isFinishedAt(0)); +} + +TEST(AnimationTest, IsFinished) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setRunState(Animation::Running, 0); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::Paused, 0); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::WaitingForNextTick, 0); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::WaitingForTargetAvailability, 0); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::WaitingForStartTime, 0); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::Finished, 0); + EXPECT_TRUE(anim->isFinished()); + anim->setRunState(Animation::Aborted, 0); + EXPECT_TRUE(anim->isFinished()); +} + +TEST(AnimationTest, IsFinishedNeedsSynchronizedStartTime) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->setRunState(Animation::Running, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::Paused, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::WaitingForNextTick, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::WaitingForTargetAvailability, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::WaitingForStartTime, 2); + EXPECT_FALSE(anim->isFinished()); + anim->setRunState(Animation::Finished, 0); + EXPECT_TRUE(anim->isFinished()); + anim->setRunState(Animation::Aborted, 0); + EXPECT_TRUE(anim->isFinished()); +} + +TEST(AnimationTest, RunStateChangesIgnoredWhileSuspended) +{ + scoped_ptr<Animation> anim(createAnimation(1)); + anim->suspend(0); + EXPECT_EQ(Animation::Paused, anim->runState()); + anim->setRunState(Animation::Running, 0); + EXPECT_EQ(Animation::Paused, anim->runState()); + anim->resume(0); + anim->setRunState(Animation::Running, 0); + EXPECT_EQ(Animation::Running, anim->runState()); +} + +} // namespace +} // namespace cc @@ -5,8 +5,8 @@ { 'variables': { 'cc_source_files': [ - 'active_animation.cc', - 'active_animation.h', + 'animation.cc', + 'animation.h', 'animation_curve.cc', 'animation_curve.h', 'animation_events.h', diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index c9d944d..5f47150 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -6,7 +6,7 @@ 'variables': { 'chromium_code': 0, 'cc_unit_tests_source_files': [ - 'active_animation_unittest.cc', + 'animation_unittest.cc', 'content_layer_unittest.cc', 'contents_scaling_layer_unittest.cc', 'damage_tracker_unittest.cc', diff --git a/cc/layer.cc b/cc/layer.cc index 943e614..dfc1c91 100644 --- a/cc/layer.cc +++ b/cc/layer.cc @@ -4,7 +4,7 @@ #include "cc/layer.h" -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/animation_events.h" #include "cc/layer_animation_controller.h" #include "cc/layer_impl.h" @@ -386,7 +386,7 @@ float Layer::opacity() const bool Layer::opacityIsAnimating() const { - return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opacity); + return m_layerAnimationController->isAnimatingProperty(Animation::Opacity); } void Layer::setContentsOpaque(bool opaque) @@ -428,7 +428,7 @@ const gfx::Transform& Layer::transform() const bool Layer::transformIsAnimating() const { - return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); + return m_layerAnimationController->isAnimatingProperty(Animation::Transform); } void Layer::setScrollOffset(gfx::Vector2d scrollOffset) @@ -753,7 +753,7 @@ bool Layer::IsActive() const return true; } -bool Layer::addAnimation(scoped_ptr <ActiveAnimation> animation) +bool Layer::addAnimation(scoped_ptr <Animation> animation) { // WebCore currently assumes that accelerated animations will start soon // after the animation is added. However we cannot guarantee that if we do @@ -33,7 +33,7 @@ class WebLayerScrollClient; namespace cc { -class ActiveAnimation; +class Animation; struct AnimationEvent; class LayerAnimationDelegate; class LayerImpl; @@ -257,7 +257,7 @@ public: // Set the priority of all desired textures in this layer. virtual void setTexturePriorities(const PriorityCalculator&) { } - bool addAnimation(scoped_ptr<ActiveAnimation>); + bool addAnimation(scoped_ptr<Animation>); void pauseAnimation(int animationId, double timeOffset); void removeAnimation(int animationId); diff --git a/cc/layer_animation_controller.cc b/cc/layer_animation_controller.cc index 232a5f67..1e7d1c1 100644 --- a/cc/layer_animation_controller.cc +++ b/cc/layer_animation_controller.cc @@ -4,7 +4,7 @@ #include "cc/layer_animation_controller.h" -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/animation_registrar.h" #include "cc/keyframed_animation_curve.h" #include "cc/layer_animation_value_observer.h" @@ -59,7 +59,7 @@ void LayerAnimationController::pauseAnimation(int animationId, double timeOffset { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { if (m_activeAnimations[i]->id() == animationId) - m_activeAnimations[i]->setRunState(ActiveAnimation::Paused, timeOffset + m_activeAnimations[i]->startTime()); + m_activeAnimations[i]->setRunState(Animation::Paused, timeOffset + m_activeAnimations[i]->startTime()); } } @@ -74,7 +74,7 @@ void LayerAnimationController::removeAnimation(int animationId) updateActivation(); } -void LayerAnimationController::removeAnimation(int animationId, ActiveAnimation::TargetProperty targetProperty) +void LayerAnimationController::removeAnimation(int animationId, Animation::TargetProperty targetProperty) { for (size_t i = 0; i < m_activeAnimations.size();) { if (m_activeAnimations[i]->id() == animationId && m_activeAnimations[i]->targetProperty() == targetProperty) @@ -90,7 +90,7 @@ void LayerAnimationController::suspendAnimations(double monotonicTime) { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { if (!m_activeAnimations[i]->isFinished()) - m_activeAnimations[i]->setRunState(ActiveAnimation::Paused, monotonicTime); + m_activeAnimations[i]->setRunState(Animation::Paused, monotonicTime); } } @@ -98,8 +98,8 @@ void LayerAnimationController::suspendAnimations(double monotonicTime) void LayerAnimationController::resumeAnimations(double monotonicTime) { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::Paused) - m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monotonicTime); + if (m_activeAnimations[i]->runState() == Animation::Paused) + m_activeAnimations[i]->setRunState(Animation::Running, monotonicTime); } } @@ -141,13 +141,13 @@ void LayerAnimationController::animate(double monotonicTime, AnimationEventsVect updateActivation(); } -void LayerAnimationController::addAnimation(scoped_ptr<ActiveAnimation> animation) +void LayerAnimationController::addAnimation(scoped_ptr<Animation> animation) { m_activeAnimations.append(animation.Pass()); updateActivation(); } -ActiveAnimation* LayerAnimationController::getActiveAnimation(int groupId, ActiveAnimation::TargetProperty targetProperty) const +Animation* LayerAnimationController::getAnimation(int groupId, Animation::TargetProperty targetProperty) const { for (size_t i = 0; i < m_activeAnimations.size(); ++i) if (m_activeAnimations[i]->group() == groupId && m_activeAnimations[i]->targetProperty() == targetProperty) @@ -155,7 +155,7 @@ ActiveAnimation* LayerAnimationController::getActiveAnimation(int groupId, Activ return 0; } -ActiveAnimation* LayerAnimationController::getActiveAnimation(ActiveAnimation::TargetProperty targetProperty) const +Animation* LayerAnimationController::getAnimation(Animation::TargetProperty targetProperty) const { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { size_t index = m_activeAnimations.size() - i - 1; @@ -174,10 +174,10 @@ bool LayerAnimationController::hasActiveAnimation() const return false; } -bool LayerAnimationController::isAnimatingProperty(ActiveAnimation::TargetProperty targetProperty) const +bool LayerAnimationController::isAnimatingProperty(Animation::TargetProperty targetProperty) const { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() != ActiveAnimation::Finished && m_activeAnimations[i]->runState() != ActiveAnimation::Aborted && m_activeAnimations[i]->targetProperty() == targetProperty) + if (m_activeAnimations[i]->runState() != Animation::Finished && m_activeAnimations[i]->runState() != Animation::Aborted && m_activeAnimations[i]->targetProperty() == targetProperty) return true; } return false; @@ -226,7 +226,7 @@ void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr // Any new animations owned by the main thread's controller are cloned and adde to the impl thread's controller. for (size_t i = 0; i < m_activeAnimations.size(); ++i) { // If the animation is already running on the impl thread, there is no need to copy it over. - if (controllerImpl->getActiveAnimation(m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty())) + if (controllerImpl->getAnimation(m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty())) continue; // If the animation is not running on the impl thread, it does not necessarily mean that it needs @@ -237,9 +237,9 @@ void LayerAnimationController::pushNewAnimationsToImplThread(LayerAnimationContr continue; // The new animation should be set to run as soon as possible. - ActiveAnimation::RunState initialRunState = ActiveAnimation::WaitingForTargetAvailability; + Animation::RunState initialRunState = Animation::WaitingForTargetAvailability; double startTime = 0; - scoped_ptr<ActiveAnimation> toAdd(m_activeAnimations[i]->cloneAndInitialize(ActiveAnimation::ControllingInstance, initialRunState, startTime)); + scoped_ptr<Animation> toAdd(m_activeAnimations[i]->cloneAndInitialize(Animation::ControllingInstance, initialRunState, startTime)); DCHECK(!toAdd->needsSynchronizedStartTime()); controllerImpl->addAnimation(toAdd.Pass()); } @@ -251,7 +251,7 @@ void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimat // Each iteration, controller->m_activeAnimations.size() is decremented or i is incremented // guaranteeing progress towards loop termination. for (size_t i = 0; i < controllerImpl->m_activeAnimations.size();) { - ActiveAnimation* current = getActiveAnimation(controllerImpl->m_activeAnimations[i]->group(), controllerImpl->m_activeAnimations[i]->targetProperty()); + Animation* current = getAnimation(controllerImpl->m_activeAnimations[i]->group(), controllerImpl->m_activeAnimations[i]->targetProperty()); if (!current) controllerImpl->m_activeAnimations.remove(i); else @@ -262,7 +262,7 @@ void LayerAnimationController::removeAnimationsCompletedOnMainThread(LayerAnimat void LayerAnimationController::pushPropertiesToImplThread(LayerAnimationController* controllerImpl) const { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - ActiveAnimation* currentImpl = controllerImpl->getActiveAnimation(m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty()); + Animation* currentImpl = controllerImpl->getAnimation(m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty()); if (currentImpl) m_activeAnimations[i]->pushPropertiesTo(currentImpl); } @@ -271,8 +271,8 @@ void LayerAnimationController::pushPropertiesToImplThread(LayerAnimationControll void LayerAnimationController::startAnimationsWaitingForNextTick(double monotonicTime, AnimationEventsVector* events) { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForNextTick) { - m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monotonicTime); + if (m_activeAnimations[i]->runState() == Animation::WaitingForNextTick) { + m_activeAnimations[i]->setRunState(Animation::Running, monotonicTime); if (!m_activeAnimations[i]->hasSetStartTime()) m_activeAnimations[i]->setStartTime(monotonicTime); if (events) @@ -284,8 +284,8 @@ void LayerAnimationController::startAnimationsWaitingForNextTick(double monotoni void LayerAnimationController::startAnimationsWaitingForStartTime(double monotonicTime, AnimationEventsVector* events) { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForStartTime && m_activeAnimations[i]->startTime() <= monotonicTime) { - m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monotonicTime); + if (m_activeAnimations[i]->runState() == Animation::WaitingForStartTime && m_activeAnimations[i]->startTime() <= monotonicTime) { + m_activeAnimations[i]->setRunState(Animation::Running, monotonicTime); if (events) events->push_back(AnimationEvent(AnimationEvent::Started, m_id, m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); } @@ -297,12 +297,12 @@ void LayerAnimationController::startAnimationsWaitingForTargetAvailability(doubl // First collect running properties. TargetProperties blockedProperties; for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_activeAnimations[i]->runState() == ActiveAnimation::Finished) + if (m_activeAnimations[i]->runState() == Animation::Running || m_activeAnimations[i]->runState() == Animation::Finished) blockedProperties.insert(m_activeAnimations[i]->targetProperty()); } for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForTargetAvailability) { + if (m_activeAnimations[i]->runState() == Animation::WaitingForTargetAvailability) { // Collect all properties for animations with the same group id (they should all also be in the list of animations). TargetProperties enqueuedProperties; enqueuedProperties.insert(m_activeAnimations[i]->targetProperty()); @@ -322,14 +322,14 @@ void LayerAnimationController::startAnimationsWaitingForTargetAvailability(doubl // If the intersection is null, then we are free to start the animations in the group. if (nullIntersection) { - m_activeAnimations[i]->setRunState(ActiveAnimation::Running, monotonicTime); + m_activeAnimations[i]->setRunState(Animation::Running, monotonicTime); if (!m_activeAnimations[i]->hasSetStartTime()) m_activeAnimations[i]->setStartTime(monotonicTime); if (events) events->push_back(AnimationEvent(AnimationEvent::Started, m_id, m_activeAnimations[i]->group(), m_activeAnimations[i]->targetProperty(), monotonicTime)); for (size_t j = i + 1; j < m_activeAnimations.size(); ++j) { if (m_activeAnimations[i]->group() == m_activeAnimations[j]->group()) { - m_activeAnimations[j]->setRunState(ActiveAnimation::Running, monotonicTime); + m_activeAnimations[j]->setRunState(Animation::Running, monotonicTime); if (!m_activeAnimations[j]->hasSetStartTime()) m_activeAnimations[j]->setStartTime(monotonicTime); } @@ -347,13 +347,13 @@ void LayerAnimationController::resolveConflicts(double monotonicTime) // (2) has an equal start time, but was added to the queue earlier, i.e., // has a lower index in m_activeAnimations). for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::Running) { + if (m_activeAnimations[i]->runState() == Animation::Running) { for (size_t j = i + 1; j < m_activeAnimations.size(); ++j) { - if (m_activeAnimations[j]->runState() == ActiveAnimation::Running && m_activeAnimations[i]->targetProperty() == m_activeAnimations[j]->targetProperty()) { + if (m_activeAnimations[j]->runState() == Animation::Running && m_activeAnimations[i]->targetProperty() == m_activeAnimations[j]->targetProperty()) { if (m_activeAnimations[i]->startTime() > m_activeAnimations[j]->startTime()) - m_activeAnimations[j]->setRunState(ActiveAnimation::Aborted, monotonicTime); + m_activeAnimations[j]->setRunState(Animation::Aborted, monotonicTime); else - m_activeAnimations[i]->setRunState(ActiveAnimation::Aborted, monotonicTime); + m_activeAnimations[i]->setRunState(Animation::Aborted, monotonicTime); } } } @@ -383,7 +383,7 @@ void LayerAnimationController::markAnimationsForDeletion(double monotonicTime, A if (groupId == m_activeAnimations[j]->group()) { if (events) events->push_back(AnimationEvent(AnimationEvent::Finished, m_id, m_activeAnimations[j]->group(), m_activeAnimations[j]->targetProperty(), monotonicTime)); - m_activeAnimations[j]->setRunState(ActiveAnimation::WaitingForDeletion, monotonicTime); + m_activeAnimations[j]->setRunState(Animation::WaitingForDeletion, monotonicTime); } } } @@ -393,7 +393,7 @@ void LayerAnimationController::markAnimationsForDeletion(double monotonicTime, A void LayerAnimationController::purgeAnimationsMarkedForDeletion() { for (size_t i = 0; i < m_activeAnimations.size();) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::WaitingForDeletion) + if (m_activeAnimations[i]->runState() == Animation::WaitingForDeletion) m_activeAnimations.remove(i); else i++; @@ -404,15 +404,15 @@ void LayerAnimationController::replaceImplThreadAnimations(LayerAnimationControl { controllerImpl->m_activeAnimations.clear(); for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - scoped_ptr<ActiveAnimation> toAdd; + scoped_ptr<Animation> toAdd; if (m_activeAnimations[i]->needsSynchronizedStartTime()) { // We haven't received an animation started notification yet, so it // is important that we add it in a 'waiting' and not 'running' state. - ActiveAnimation::RunState initialRunState = ActiveAnimation::WaitingForTargetAvailability; + Animation::RunState initialRunState = Animation::WaitingForTargetAvailability; double startTime = 0; - toAdd = m_activeAnimations[i]->cloneAndInitialize(ActiveAnimation::ControllingInstance, initialRunState, startTime).Pass(); + toAdd = m_activeAnimations[i]->cloneAndInitialize(Animation::ControllingInstance, initialRunState, startTime).Pass(); } else - toAdd = m_activeAnimations[i]->clone(ActiveAnimation::ControllingInstance).Pass(); + toAdd = m_activeAnimations[i]->clone(Animation::ControllingInstance).Pass(); controllerImpl->addAnimation(toAdd.Pass()); } @@ -421,7 +421,7 @@ void LayerAnimationController::replaceImplThreadAnimations(LayerAnimationControl void LayerAnimationController::tickAnimations(double monotonicTime) { for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - if (m_activeAnimations[i]->runState() == ActiveAnimation::Running || m_activeAnimations[i]->runState() == ActiveAnimation::Paused) { + if (m_activeAnimations[i]->runState() == Animation::Running || m_activeAnimations[i]->runState() == Animation::Paused) { double trimmed = m_activeAnimations[i]->trimTimeToCurrentIteration(monotonicTime); // Animation assumes its initial value until it gets the synchronized start time @@ -431,28 +431,28 @@ void LayerAnimationController::tickAnimations(double monotonicTime) switch (m_activeAnimations[i]->targetProperty()) { - case ActiveAnimation::Transform: { + case Animation::Transform: { const TransformAnimationCurve* transformAnimationCurve = m_activeAnimations[i]->curve()->toTransformAnimationCurve(); const gfx::Transform transform = convertWebTransformationMatrixToTransform(transformAnimationCurve->getValue(trimmed)); if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) - m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime); + m_activeAnimations[i]->setRunState(Animation::Finished, monotonicTime); notifyObserversTransformAnimated(transform); break; } - case ActiveAnimation::Opacity: { + case Animation::Opacity: { const FloatAnimationCurve* floatAnimationCurve = m_activeAnimations[i]->curve()->toFloatAnimationCurve(); const float opacity = floatAnimationCurve->getValue(trimmed); if (m_activeAnimations[i]->isFinishedAt(monotonicTime)) - m_activeAnimations[i]->setRunState(ActiveAnimation::Finished, monotonicTime); + m_activeAnimations[i]->setRunState(Animation::Finished, monotonicTime); notifyObserversOpacityAnimated(opacity); break; } // Do nothing for sentinel value. - case ActiveAnimation::TargetPropertyEnumSize: + case Animation::TargetPropertyEnumSize: NOTREACHED(); } } diff --git a/cc/layer_animation_controller.h b/cc/layer_animation_controller.h index 9fec0a6..f083218 100644 --- a/cc/layer_animation_controller.h +++ b/cc/layer_animation_controller.h @@ -37,10 +37,10 @@ public: int id() const { return m_id; } // These methods are virtual for testing. - virtual void addAnimation(scoped_ptr<ActiveAnimation>); + virtual void addAnimation(scoped_ptr<Animation>); virtual void pauseAnimation(int animationId, double timeOffset); virtual void removeAnimation(int animationId); - virtual void removeAnimation(int animationId, ActiveAnimation::TargetProperty); + virtual void removeAnimation(int animationId, Animation::TargetProperty); virtual void suspendAnimations(double monotonicTime); virtual void resumeAnimations(double monotonicTime); @@ -52,11 +52,11 @@ public: // Returns the active animation in the given group, animating the given property, if such an // animation exists. - ActiveAnimation* getActiveAnimation(int groupId, ActiveAnimation::TargetProperty) const; + Animation* getAnimation(int groupId, Animation::TargetProperty) const; // Returns the active animation animating the given property that is either running, or is // next to run, if such an animation exists. - ActiveAnimation* getActiveAnimation(ActiveAnimation::TargetProperty) const; + Animation* getAnimation(Animation::TargetProperty) const; // Returns true if there are any animations that have neither finished nor aborted. bool hasActiveAnimation() const; @@ -66,7 +66,7 @@ public: // Returns true if there is an animation currently animating the given property, or // if there is an animation scheduled to animate this property in the future. - bool isAnimatingProperty(ActiveAnimation::TargetProperty) const; + bool isAnimatingProperty(Animation::TargetProperty) const; // This is called in response to an animation being started on the impl thread. This // function updates the corresponding main thread animation's start time. @@ -116,7 +116,7 @@ private: AnimationRegistrar* m_registrar; int m_id; - ScopedPtrVector<ActiveAnimation> m_activeAnimations; + ScopedPtrVector<Animation> m_activeAnimations; // This is used to ensure that we don't spam the registrar. bool m_isActive; diff --git a/cc/layer_animation_controller_unittest.cc b/cc/layer_animation_controller_unittest.cc index f93ea7c..4db652a 100644 --- a/cc/layer_animation_controller_unittest.cc +++ b/cc/layer_animation_controller_unittest.cc @@ -4,7 +4,7 @@ #include "cc/layer_animation_controller.h" -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/animation_curve.h" #include "cc/test/animation_test_common.h" #include "testing/gmock/include/gmock/gmock.h" @@ -19,9 +19,9 @@ void expectTranslateX(double translateX, const gfx::Transform& matrix) EXPECT_FLOAT_EQ(translateX, matrix.matrix().getDouble(0, 3)); } -scoped_ptr<ActiveAnimation> createActiveAnimation(scoped_ptr<AnimationCurve> curve, int id, ActiveAnimation::TargetProperty property) +scoped_ptr<Animation> createAnimation(scoped_ptr<AnimationCurve> curve, int id, Animation::TargetProperty property) { - return ActiveAnimation::create(curve.Pass(), 0, id, property); + return Animation::create(curve.Pass(), 0, id, property); } TEST(LayerAnimationControllerTest, syncNewAnimation) @@ -33,14 +33,14 @@ TEST(LayerAnimationControllerTest, syncNewAnimation) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); + EXPECT_FALSE(controllerImpl->getAnimation(0, Animation::Opacity)); addOpacityTransitionToController(*controller, 1, 0, 1, false); controller->pushAnimationUpdatesTo(controllerImpl.get()); - EXPECT_TRUE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); - EXPECT_EQ(ActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_TRUE(controllerImpl->getAnimation(0, Animation::Opacity)); + EXPECT_EQ(Animation::WaitingForTargetAvailability, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); } // If an animation is started on the impl thread before it is ticked on the main @@ -54,14 +54,14 @@ TEST(LayerAnimationControllerTest, doNotClobberStartTimes) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); + EXPECT_FALSE(controllerImpl->getAnimation(0, Animation::Opacity)); addOpacityTransitionToController(*controller, 1, 0, 1, false); controller->pushAnimationUpdatesTo(controllerImpl.get()); - EXPECT_TRUE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); - EXPECT_EQ(ActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_TRUE(controllerImpl->getAnimation(0, Animation::Opacity)); + EXPECT_EQ(Animation::WaitingForTargetAvailability, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); AnimationEventsVector events; controllerImpl->animate(1, &events); @@ -69,11 +69,11 @@ TEST(LayerAnimationControllerTest, doNotClobberStartTimes) // Synchronize the start times. EXPECT_EQ(1u, events.size()); controller->OnAnimationStarted(events[0]); - EXPECT_EQ(controller->getActiveAnimation(0, ActiveAnimation::Opacity)->startTime(), controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->startTime()); + EXPECT_EQ(controller->getAnimation(0, Animation::Opacity)->startTime(), controllerImpl->getAnimation(0, Animation::Opacity)->startTime()); // Start the animation on the main thread. Should not affect the start time. controller->animate(1.5, 0); - EXPECT_EQ(controller->getActiveAnimation(0, ActiveAnimation::Opacity)->startTime(), controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->startTime()); + EXPECT_EQ(controller->getAnimation(0, Animation::Opacity)->startTime(), controllerImpl->getAnimation(0, Animation::Opacity)->startTime()); } TEST(LayerAnimationControllerTest, syncPauseAndResume) @@ -85,37 +85,37 @@ TEST(LayerAnimationControllerTest, syncPauseAndResume) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); + EXPECT_FALSE(controllerImpl->getAnimation(0, Animation::Opacity)); addOpacityTransitionToController(*controller, 1, 0, 1, false); controller->pushAnimationUpdatesTo(controllerImpl.get()); - EXPECT_TRUE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); - EXPECT_EQ(ActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_TRUE(controllerImpl->getAnimation(0, Animation::Opacity)); + EXPECT_EQ(Animation::WaitingForTargetAvailability, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); // Start the animations on each controller. AnimationEventsVector events; controllerImpl->animate(0, &events); controller->animate(0, 0); - EXPECT_EQ(ActiveAnimation::Running, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); - EXPECT_EQ(ActiveAnimation::Running, controller->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_EQ(Animation::Running, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); + EXPECT_EQ(Animation::Running, controller->getAnimation(0, Animation::Opacity)->runState()); // Pause the main-thread animation. controller->suspendAnimations(1); - EXPECT_EQ(ActiveAnimation::Paused, controller->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_EQ(Animation::Paused, controller->getAnimation(0, Animation::Opacity)->runState()); // The pause run state change should make it to the impl thread controller. controller->pushAnimationUpdatesTo(controllerImpl.get()); - EXPECT_EQ(ActiveAnimation::Paused, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_EQ(Animation::Paused, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); // Resume the main-thread animation. controller->resumeAnimations(2); - EXPECT_EQ(ActiveAnimation::Running, controller->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_EQ(Animation::Running, controller->getAnimation(0, Animation::Opacity)->runState()); // The pause run state change should make it to the impl thread controller. controller->pushAnimationUpdatesTo(controllerImpl.get()); - EXPECT_EQ(ActiveAnimation::Running, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_EQ(Animation::Running, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); } TEST(LayerAnimationControllerTest, doNotSyncFinishedAnimation) @@ -127,28 +127,28 @@ TEST(LayerAnimationControllerTest, doNotSyncFinishedAnimation) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - EXPECT_FALSE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); + EXPECT_FALSE(controllerImpl->getAnimation(0, Animation::Opacity)); int animationId = addOpacityTransitionToController(*controller, 1, 0, 1, false); controller->pushAnimationUpdatesTo(controllerImpl.get()); - EXPECT_TRUE(controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)); - EXPECT_EQ(ActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity)->runState()); + EXPECT_TRUE(controllerImpl->getAnimation(0, Animation::Opacity)); + EXPECT_EQ(Animation::WaitingForTargetAvailability, controllerImpl->getAnimation(0, Animation::Opacity)->runState()); // Notify main thread controller that the animation has started. - AnimationEvent animationStartedEvent(AnimationEvent::Started, 0, 0, ActiveAnimation::Opacity, 0); + AnimationEvent animationStartedEvent(AnimationEvent::Started, 0, 0, Animation::Opacity, 0); controller->OnAnimationStarted(animationStartedEvent); // Force animation to complete on impl thread. controllerImpl->removeAnimation(animationId); - EXPECT_FALSE(controllerImpl->getActiveAnimation(animationId, ActiveAnimation::Opacity)); + EXPECT_FALSE(controllerImpl->getAnimation(animationId, Animation::Opacity)); controller->pushAnimationUpdatesTo(controllerImpl.get()); // Even though the main thread has a 'new' animation, it should not be pushed because the animation has already completed on the impl thread. - EXPECT_FALSE(controllerImpl->getActiveAnimation(animationId, ActiveAnimation::Opacity)); + EXPECT_FALSE(controllerImpl->getAnimation(animationId, Animation::Opacity)); } // Tests that transitioning opacity from 0 to 1 works as expected. @@ -159,7 +159,7 @@ TEST(LayerAnimationControllerTest, TrivialTransition) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); controller->addAnimation(toAdd.Pass()); controller->animate(0, events.get()); @@ -178,7 +178,7 @@ TEST(LayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfThe scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); toAdd->setNeedsSynchronizedStartTime(true); // We should pause at the first keyframe indefinitely waiting for that animation to start. @@ -194,7 +194,7 @@ TEST(LayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfThe EXPECT_EQ(0, dummy.opacity()); // Send the synchronized start time. - controller->OnAnimationStarted(AnimationEvent(AnimationEvent::Started, 0, 1, ActiveAnimation::Opacity, 2)); + controller->OnAnimationStarted(AnimationEvent(AnimationEvent::Started, 0, 1, Animation::Opacity, 2)); controller->animate(5, events.get()); EXPECT_EQ(1, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); @@ -208,8 +208,8 @@ TEST(LayerAnimationControllerTest, TrivialQueuing) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -229,13 +229,13 @@ TEST(LayerAnimationControllerTest, Interrupt) FakeLayerAnimationValueObserver dummy; scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); - toAdd->setRunState(ActiveAnimation::WaitingForNextTick, 0); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); + toAdd->setRunState(Animation::WaitingForNextTick, 0); controller->addAnimation(toAdd.Pass()); // Since the animation was in the WaitingForNextTick state, it should start right in @@ -256,9 +256,9 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), 1, Animation::Transform)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), 2, Animation::Transform)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); controller->animate(0, events.get()); EXPECT_EQ(0, dummy.opacity()); @@ -283,9 +283,9 @@ TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(2)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeTransformTransition(2)).PassAs<AnimationCurve>(), 1, Animation::Transform)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); // Animations with id 1 should both start now. controller->animate(0, events.get()); @@ -313,8 +313,8 @@ TEST(LayerAnimationControllerTest, ScheduleAnimation) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); - toAdd->setRunState(ActiveAnimation::WaitingForStartTime, 0); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); + toAdd->setRunState(Animation::WaitingForStartTime, 0); toAdd->setStartTime(1); controller->addAnimation(toAdd.Pass()); @@ -337,10 +337,10 @@ TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0.5, 0)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); - toAdd->setRunState(ActiveAnimation::WaitingForStartTime, 0); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0.5, 0)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); + toAdd->setRunState(Animation::WaitingForStartTime, 0); toAdd->setStartTime(1); controller->addAnimation(toAdd.Pass()); @@ -368,14 +368,14 @@ TEST(LayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationW scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0.5, 0)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); - toAdd->setRunState(ActiveAnimation::WaitingForStartTime, 0); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0.5, 0)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); + toAdd->setRunState(Animation::WaitingForStartTime, 0); toAdd->setStartTime(1); controller->addAnimation(toAdd.Pass()); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 0.75)).PassAs<AnimationCurve>(), 3, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 0.75)).PassAs<AnimationCurve>(), 3, Animation::Opacity)); // First 2s opacity transition should start immediately. controller->animate(0, events.get()); @@ -404,7 +404,7 @@ TEST(LayerAnimationControllerTest, TrivialLooping) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, ActiveAnimation::Opacity)); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), 1, Animation::Opacity)); toAdd->setIterations(3); controller->addAnimation(toAdd.Pass()); @@ -441,7 +441,7 @@ TEST(LayerAnimationControllerTest, InfiniteLooping) controller->addObserver(&dummy); const int id = 1; - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Opacity)); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), id, Animation::Opacity)); toAdd->setIterations(-1); controller->addAnimation(toAdd.Pass()); @@ -462,8 +462,8 @@ TEST(LayerAnimationControllerTest, InfiniteLooping) EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.75, dummy.opacity()); - EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity)); - controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Aborted, 0.75); + EXPECT_TRUE(controller->getAnimation(id, Animation::Opacity)); + controller->getAnimation(id, Animation::Opacity)->setRunState(Animation::Aborted, 0.75); EXPECT_FALSE(controller->hasActiveAnimation()); EXPECT_EQ(0.75, dummy.opacity()); } @@ -477,7 +477,7 @@ TEST(LayerAnimationControllerTest, PauseResume) controller->addObserver(&dummy); const int id = 1; - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<AnimationCurve>(), id, Animation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -486,15 +486,15 @@ TEST(LayerAnimationControllerTest, PauseResume) EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5, dummy.opacity()); - EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity)); - controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Paused, 0.5); + EXPECT_TRUE(controller->getAnimation(id, Animation::Opacity)); + controller->getAnimation(id, Animation::Opacity)->setRunState(Animation::Paused, 0.5); controller->animate(1024, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5, dummy.opacity()); - EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity)); - controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Running, 1024); + EXPECT_TRUE(controller->getAnimation(id, Animation::Opacity)); + controller->getAnimation(id, Animation::Opacity)->setRunState(Animation::Running, 1024); controller->animate(1024.25, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -512,9 +512,9 @@ TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) controller->addObserver(&dummy); const int id = 1; - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), id, ActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.75)).PassAs<AnimationCurve>(), 2, ActiveAnimation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<AnimationCurve>(), id, Animation::Transform)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), id, Animation::Opacity)); + controller->addAnimation(createAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.75)).PassAs<AnimationCurve>(), 2, Animation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -523,8 +523,8 @@ TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5, dummy.opacity()); - EXPECT_TRUE(controller->getActiveAnimation(id, ActiveAnimation::Opacity)); - controller->getActiveAnimation(id, ActiveAnimation::Opacity)->setRunState(ActiveAnimation::Aborted, 1); + EXPECT_TRUE(controller->getAnimation(id, Animation::Opacity)); + controller->getAnimation(id, Animation::Opacity)->setRunState(Animation::Aborted, 1); controller->animate(1, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); @@ -543,13 +543,13 @@ TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) scoped_refptr<LayerAnimationController> controller(LayerAnimationController::create(0)); controller->addObserver(&dummy); - scoped_ptr<ActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 0, ActiveAnimation::Opacity)); + scoped_ptr<Animation> toAdd(createAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<AnimationCurve>(), 0, Animation::Opacity)); toAdd->setNeedsSynchronizedStartTime(true); controller->addAnimation(toAdd.Pass()); controller->animate(0, 0); EXPECT_TRUE(controller->hasActiveAnimation()); - ActiveAnimation* activeAnimation = controller->getActiveAnimation(0, ActiveAnimation::Opacity); + Animation* activeAnimation = controller->getAnimation(0, Animation::Opacity); EXPECT_TRUE(activeAnimation); EXPECT_TRUE(activeAnimation->needsSynchronizedStartTime()); @@ -557,9 +557,9 @@ TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) controller->pushAnimationUpdatesTo(controllerImpl.get()); - activeAnimation = controllerImpl->getActiveAnimation(0, ActiveAnimation::Opacity); + activeAnimation = controllerImpl->getAnimation(0, Animation::Opacity); EXPECT_TRUE(activeAnimation); - EXPECT_EQ(ActiveAnimation::WaitingForTargetAvailability, activeAnimation->runState()); + EXPECT_EQ(Animation::WaitingForTargetAvailability, activeAnimation->runState()); } } // namespace diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc index 03074a1..d0eafe3 100644 --- a/cc/layer_impl.cc +++ b/cc/layer_impl.cc @@ -637,7 +637,7 @@ float LayerImpl::opacity() const bool LayerImpl::opacityIsAnimating() const { - return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opacity); + return m_layerAnimationController->isAnimatingProperty(Animation::Opacity); } void LayerImpl::setPosition(const gfx::PointF& position) @@ -684,7 +684,7 @@ const gfx::Transform& LayerImpl::transform() const bool LayerImpl::transformIsAnimating() const { - return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Transform); + return m_layerAnimationController->isAnimatingProperty(Animation::Transform); } void LayerImpl::setContentBounds(const gfx::Size& contentBounds) diff --git a/cc/layer_tree_host_unittest_animation.cc b/cc/layer_tree_host_unittest_animation.cc index e58660b..173d73e 100644 --- a/cc/layer_tree_host_unittest_animation.cc +++ b/cc/layer_tree_host_unittest_animation.cc @@ -248,8 +248,8 @@ public: bool hasUnfinishedAnimation) OVERRIDE { LayerAnimationController* controller = m_layerTreeHost->rootLayer()->layerAnimationController(); - ActiveAnimation* animation = - controller->getActiveAnimation(0, ActiveAnimation::Opacity); + Animation* animation = + controller->getAnimation(0, Animation::Opacity); if (!animation) return; @@ -267,8 +267,8 @@ public: LayerAnimationController* controller_impl = host_impl->rootLayer()->layerAnimationController(); - ActiveAnimation* animation_impl = - controller_impl->getActiveAnimation(0, ActiveAnimation::Opacity); + Animation* animation_impl = + controller_impl->getAnimation(0, Animation::Opacity); controller->removeAnimation(animation->id()); controller_impl->removeAnimation(animation_impl->id()); @@ -298,8 +298,8 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes : virtual void notifyAnimationStarted(double time) OVERRIDE { LayerAnimationController* controller = m_layerTreeHost->rootLayer()->layerAnimationController(); - ActiveAnimation* animation = - controller->getActiveAnimation(0, ActiveAnimation::Opacity); + Animation* animation = + controller->getAnimation(0, Animation::Opacity); main_start_time_ = animation->startTime(); controller->removeAnimation(animation->id()); @@ -313,8 +313,8 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes : bool hasUnfinishedAnimation) OVERRIDE { LayerAnimationController* controller = impl_host->rootLayer()->layerAnimationController(); - ActiveAnimation* animation = - controller->getActiveAnimation(0, ActiveAnimation::Opacity); + Animation* animation = + controller->getAnimation(0, Animation::Opacity); if (!animation) return; @@ -349,8 +349,8 @@ class LayerTreeHostAnimationTestAnimationFinishedEvents : virtual void notifyAnimationFinished(double time) OVERRIDE { LayerAnimationController* controller = m_layerTreeHost->rootLayer()->layerAnimationController(); - ActiveAnimation* animation = - controller->getActiveAnimation(0, ActiveAnimation::Opacity); + Animation* animation = + controller->getAnimation(0, Animation::Opacity); controller->removeAnimation(animation->id()); endTest(); } @@ -419,9 +419,9 @@ class LayerTreeHostAnimationTestLayerAddedWithAnimation : // Any valid AnimationCurve will do here. scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create()); - scoped_ptr<ActiveAnimation> animation( - ActiveAnimation::create(curve.Pass(), 1, 1, - ActiveAnimation::Opacity)); + scoped_ptr<Animation> animation( + Animation::create(curve.Pass(), 1, 1, + Animation::Opacity)); layer->layerAnimationController()->addAnimation(animation.Pass()); // We add the animation *before* attaching the layer to the tree. diff --git a/cc/layer_unittest.cc b/cc/layer_unittest.cc index df2e7a0..cfd62cc 100644 --- a/cc/layer_unittest.cc +++ b/cc/layer_unittest.cc @@ -807,7 +807,7 @@ static bool addTestAnimation(Layer* layer) scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve::create()); curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction>())); curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction>())); - scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<AnimationCurve>(), 0, 0, ActiveAnimation::Opacity)); + scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurve>(), 0, 0, Animation::Opacity)); return layer->addAnimation(animation.Pass()); } diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc index 0e62151..6b896b6 100644 --- a/cc/test/animation_test_common.cc +++ b/cc/test/animation_test_common.cc @@ -10,7 +10,7 @@ #include "cc/layer_impl.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperations.h" -using cc::ActiveAnimation; +using cc::Animation; using cc::AnimationCurve; using cc::EaseTimingFunction; using cc::FloatKeyframe; @@ -37,7 +37,7 @@ int addOpacityTransition(Target& target, double duration, float startOpacity, fl int id = nextAnimationId++; - scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<AnimationCurve>(), id, 0, ActiveAnimation::Opacity)); + scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurve>(), id, 0, Animation::Opacity)); animation->setNeedsSynchronizedStartTime(true); target.addAnimation(animation.Pass()); @@ -61,7 +61,7 @@ int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY int id = nextAnimationId++; - scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<AnimationCurve>(), id, 0, ActiveAnimation::Transform)); + scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurve>(), id, 0, Animation::Transform)); animation->setNeedsSynchronizedStartTime(true); target.addAnimation(animation.Pass()); diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h index afba750..4f9c13b 100644 --- a/cc/test/animation_test_common.h +++ b/cc/test/animation_test_common.h @@ -5,7 +5,7 @@ #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_ #define CC_TEST_ANIMATION_TEST_COMMON_H_ -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/animation_curve.h" #include "cc/layer_animation_controller.h" #include "cc/layer_animation_value_observer.h" diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc index 505556f..cfe6861 100644 --- a/cc/test/layer_tree_test_common.cc +++ b/cc/test/layer_tree_test_common.cc @@ -4,7 +4,7 @@ #include "cc/test/layer_tree_test_common.h" -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/animation_registrar.h" #include "cc/content_layer.h" #include "cc/font_atlas.h" diff --git a/webkit/compositor_bindings/web_animation_impl.cc b/webkit/compositor_bindings/web_animation_impl.cc index a258aa2..32d1507 100644 --- a/webkit/compositor_bindings/web_animation_impl.cc +++ b/webkit/compositor_bindings/web_animation_impl.cc @@ -4,7 +4,7 @@ #include "web_animation_impl.h" -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/animation_curve.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimationCurve.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebAnimation.h" @@ -12,7 +12,7 @@ #include "web_float_animation_curve_impl.h" #include "web_transform_animation_curve_impl.h" -using cc::ActiveAnimation; +using cc::Animation; using webkit::WebAnimationIdProvider; namespace WebKit { @@ -38,7 +38,7 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp break; } } - m_animation = ActiveAnimation::create(curve.Pass(), animationId, groupId, static_cast<cc::ActiveAnimation::TargetProperty>(targetProperty)); + m_animation = Animation::create(curve.Pass(), animationId, groupId, static_cast<cc::Animation::TargetProperty>(targetProperty)); } WebAnimationImpl::~WebAnimationImpl() @@ -95,9 +95,9 @@ void WebAnimationImpl::setAlternatesDirection(bool alternates) m_animation->setAlternatesDirection(alternates); } -scoped_ptr<cc::ActiveAnimation> WebAnimationImpl::cloneToAnimation() +scoped_ptr<cc::Animation> WebAnimationImpl::cloneToAnimation() { - scoped_ptr<cc::ActiveAnimation> toReturn(m_animation->clone(cc::ActiveAnimation::NonControllingInstance)); + scoped_ptr<cc::Animation> toReturn(m_animation->clone(cc::Animation::NonControllingInstance)); toReturn->setNeedsSynchronizedStartTime(true); return toReturn.Pass(); } diff --git a/webkit/compositor_bindings/web_animation_impl.h b/webkit/compositor_bindings/web_animation_impl.h index 905edc8..ebeca88 100644 --- a/webkit/compositor_bindings/web_animation_impl.h +++ b/webkit/compositor_bindings/web_animation_impl.h @@ -10,7 +10,7 @@ #include "webkit/compositor_bindings/webkit_compositor_bindings_export.h" namespace cc { -class ActiveAnimation; +class Animation; } namespace WebKit { @@ -33,10 +33,10 @@ public: virtual bool alternatesDirection() const OVERRIDE; virtual void setAlternatesDirection(bool) OVERRIDE; - scoped_ptr<cc::ActiveAnimation> cloneToAnimation(); + scoped_ptr<cc::Animation> cloneToAnimation(); private: - scoped_ptr<cc::ActiveAnimation> m_animation; + scoped_ptr<cc::Animation> m_animation; }; } diff --git a/webkit/compositor_bindings/web_layer_impl.cc b/webkit/compositor_bindings/web_layer_impl.cc index b33436a..d0938f3 100644 --- a/webkit/compositor_bindings/web_layer_impl.cc +++ b/webkit/compositor_bindings/web_layer_impl.cc @@ -9,7 +9,7 @@ #undef LOG #endif #include "base/string_util.h" -#include "cc/active_animation.h" +#include "cc/animation.h" #include "cc/layer.h" #include "cc/region.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" @@ -18,7 +18,7 @@ #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMatrix.h" #include "web_animation_impl.h" -using cc::ActiveAnimation; +using cc::Animation; using cc::Layer; namespace { @@ -289,7 +289,7 @@ void WebLayerImpl::removeAnimation(int animationId) void WebLayerImpl::removeAnimation(int animationId, WebAnimation::TargetProperty targetProperty) { - m_layer->layerAnimationController()->removeAnimation(animationId, static_cast<ActiveAnimation::TargetProperty>(targetProperty)); + m_layer->layerAnimationController()->removeAnimation(animationId, static_cast<Animation::TargetProperty>(targetProperty)); } void WebLayerImpl::pauseAnimation(int animationId, double timeOffset) |