diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-08 05:54:11 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-08 05:54:11 +0000 |
commit | a9c7b2e76a331dbbe53ca102df2d86be1e8b53cd (patch) | |
tree | 48031bf37c94612084be25bc15c86a3bb00e064d /cc | |
parent | 362591a2da8a5abe42ee51dfea08d1b355c56fc8 (diff) | |
download | chromium_src-a9c7b2e76a331dbbe53ca102df2d86be1e8b53cd.zip chromium_src-a9c7b2e76a331dbbe53ca102df2d86be1e8b53cd.tar.gz chromium_src-a9c7b2e76a331dbbe53ca102df2d86be1e8b53cd.tar.bz2 |
[cc] Use base ptr types for cc's CSS animation classes
BUG=154451
Review URL: https://chromiumcodereview.appspot.com/11078009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160630 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/CCActiveAnimation.cpp | 16 | ||||
-rw-r--r-- | cc/CCActiveAnimation.h | 13 | ||||
-rw-r--r-- | cc/CCActiveAnimationTest.cpp | 40 | ||||
-rw-r--r-- | cc/CCAnimationCurve.h | 4 | ||||
-rw-r--r-- | cc/CCKeyframedAnimationCurve.cpp | 73 | ||||
-rw-r--r-- | cc/CCKeyframedAnimationCurve.h | 36 | ||||
-rw-r--r-- | cc/CCKeyframedAnimationCurveTest.cpp | 71 | ||||
-rw-r--r-- | cc/CCLayerAnimationController.cpp | 20 | ||||
-rw-r--r-- | cc/CCLayerAnimationController.h | 11 | ||||
-rw-r--r-- | cc/CCLayerAnimationControllerTest.cpp | 146 | ||||
-rw-r--r-- | cc/CCLayerImpl.h | 2 | ||||
-rw-r--r-- | cc/CCLayerTreeHostTest.cpp | 6 | ||||
-rw-r--r-- | cc/CCTimingFunction.cpp | 26 | ||||
-rw-r--r-- | cc/CCTimingFunction.h | 13 | ||||
-rw-r--r-- | cc/LayerChromium.cpp | 16 | ||||
-rw-r--r-- | cc/LayerChromium.h | 12 | ||||
-rw-r--r-- | cc/LayerChromiumTest.cpp | 10 | ||||
-rw-r--r-- | cc/TreeSynchronizerTest.cpp | 6 | ||||
-rw-r--r-- | cc/test/CCAnimationTestCommon.cpp | 32 | ||||
-rw-r--r-- | cc/test/CCAnimationTestCommon.h | 8 |
20 files changed, 273 insertions, 288 deletions
diff --git a/cc/CCActiveAnimation.cpp b/cc/CCActiveAnimation.cpp index e99bd42..b1817d1 100644 --- a/cc/CCActiveAnimation.cpp +++ b/cc/CCActiveAnimation.cpp @@ -42,13 +42,13 @@ COMPILE_ASSERT(static_cast<int>(cc::CCActiveAnimation::TargetPropertyEnumSize) = namespace cc { -PassOwnPtr<CCActiveAnimation> CCActiveAnimation::create(PassOwnPtr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) +scoped_ptr<CCActiveAnimation> CCActiveAnimation::create(scoped_ptr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) { - return adoptPtr(new CCActiveAnimation(curve, animationId, groupId, targetProperty)); + return make_scoped_ptr(new CCActiveAnimation(curve.Pass(), animationId, groupId, targetProperty)); } -CCActiveAnimation::CCActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) - : m_curve(curve) +CCActiveAnimation::CCActiveAnimation(scoped_ptr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty) + : m_curve(curve.Pass()) , m_id(animationId) , m_group(groupId) , m_targetProperty(targetProperty) @@ -180,14 +180,14 @@ double CCActiveAnimation::trimTimeToCurrentIteration(double monotonicTime) const return trimmed; } -PassOwnPtr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const +scoped_ptr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const { return cloneAndInitialize(instanceType, m_runState, m_startTime); } -PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const +scoped_ptr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const { - OwnPtr<CCActiveAnimation> toReturn(adoptPtr(new CCActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty))); + scoped_ptr<CCActiveAnimation> toReturn(new CCActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty)); toReturn->m_runState = initialRunState; toReturn->m_iterations = m_iterations; toReturn->m_startTime = startTime; @@ -196,7 +196,7 @@ PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType toReturn->m_timeOffset = m_timeOffset; toReturn->m_alternatesDirection = m_alternatesDirection; toReturn->m_isControllingInstance = instanceType == ControllingInstance; - return toReturn.release(); + return toReturn.Pass(); } void CCActiveAnimation::pushPropertiesTo(CCActiveAnimation* other) const diff --git a/cc/CCActiveAnimation.h b/cc/CCActiveAnimation.h index 213b510..b8d3607 100644 --- a/cc/CCActiveAnimation.h +++ b/cc/CCActiveAnimation.h @@ -6,8 +6,7 @@ #define CCActiveAnimation_h #include "base/basictypes.h" -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> +#include "base/memory/scoped_ptr.h" namespace cc { @@ -47,7 +46,7 @@ public: TargetPropertyEnumSize }; - static PassOwnPtr<CCActiveAnimation> create(PassOwnPtr<CCAnimationCurve>, int animationId, int groupId, TargetProperty); + static scoped_ptr<CCActiveAnimation> create(scoped_ptr<CCAnimationCurve>, int animationId, int groupId, TargetProperty); virtual ~CCActiveAnimation(); @@ -100,16 +99,16 @@ public: NonControllingInstance }; - PassOwnPtr<CCActiveAnimation> clone(InstanceType) const; - PassOwnPtr<CCActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; + scoped_ptr<CCActiveAnimation> clone(InstanceType) const; + scoped_ptr<CCActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; bool isControllingInstance() const { return m_isControllingInstance; } void pushPropertiesTo(CCActiveAnimation*) const; private: - CCActiveAnimation(PassOwnPtr<CCAnimationCurve>, int animationId, int groupId, TargetProperty); + CCActiveAnimation(scoped_ptr<CCAnimationCurve>, int animationId, int groupId, TargetProperty); - OwnPtr<CCAnimationCurve> m_curve; + scoped_ptr<CCAnimationCurve> m_curve; // IDs are not necessarily unique. int m_id; diff --git a/cc/CCActiveAnimationTest.cpp b/cc/CCActiveAnimationTest.cpp index bac66c7..c3076c9 100644 --- a/cc/CCActiveAnimationTest.cpp +++ b/cc/CCActiveAnimationTest.cpp @@ -15,21 +15,21 @@ using namespace cc; namespace { -PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations, double duration) +scoped_ptr<CCActiveAnimation> createActiveAnimation(int iterations, double duration) { - OwnPtr<CCActiveAnimation> toReturn(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve(duration)), 0, 1, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toReturn(CCActiveAnimation::create(make_scoped_ptr(new FakeFloatAnimationCurve(duration)).PassAs<CCAnimationCurve>(), 0, 1, CCActiveAnimation::Opacity)); toReturn->setIterations(iterations); - return toReturn.release(); + return toReturn.Pass(); } -PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations) +scoped_ptr<CCActiveAnimation> createActiveAnimation(int iterations) { return createActiveAnimation(iterations, 1); } TEST(CCActiveAnimationTest, TrimTimeZeroIterations) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); @@ -37,7 +37,7 @@ TEST(CCActiveAnimationTest, TrimTimeZeroIterations) TEST(CCActiveAnimationTest, TrimTimeOneIteration) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); @@ -46,7 +46,7 @@ TEST(CCActiveAnimationTest, TrimTimeOneIteration) TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(-1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); @@ -55,7 +55,7 @@ TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations) TEST(CCActiveAnimationTest, TrimTimeAlternating) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(-1)); anim->setAlternatesDirection(true); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); @@ -65,7 +65,7 @@ TEST(CCActiveAnimationTest, TrimTimeAlternating) TEST(CCActiveAnimationTest, TrimTimeStartTime) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setStartTime(4); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4)); @@ -76,7 +76,7 @@ TEST(CCActiveAnimationTest, TrimTimeStartTime) TEST(CCActiveAnimationTest, TrimTimeTimeOffset) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setTimeOffset(4); anim->setStartTime(4); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); @@ -87,7 +87,7 @@ TEST(CCActiveAnimationTest, TrimTimeTimeOffset) TEST(CCActiveAnimationTest, TrimTimePauseResume) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); @@ -100,7 +100,7 @@ TEST(CCActiveAnimationTest, TrimTimePauseResume) TEST(CCActiveAnimationTest, TrimTimeSuspendResume) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); @@ -113,7 +113,7 @@ TEST(CCActiveAnimationTest, TrimTimeSuspendResume) TEST(CCActiveAnimationTest, TrimTimeZeroDuration) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0, 0)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0, 0)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); @@ -122,7 +122,7 @@ TEST(CCActiveAnimationTest, TrimTimeZeroDuration) TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_FALSE(anim->isFinishedAt(-1)); EXPECT_TRUE(anim->isFinishedAt(0)); @@ -131,7 +131,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations) TEST(CCActiveAnimationTest, IsFinishedAtOneIteration) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_FALSE(anim->isFinishedAt(-1)); EXPECT_FALSE(anim->isFinishedAt(0)); @@ -141,7 +141,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtOneIteration) TEST(CCActiveAnimationTest, IsFinishedAtInfiniteIterations) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(-1)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_FALSE(anim->isFinishedAt(0)); EXPECT_FALSE(anim->isFinishedAt(0.5)); @@ -151,7 +151,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtInfiniteIterations) TEST(CCActiveAnimationTest, IsFinishedAtNotRunning) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_TRUE(anim->isFinishedAt(0)); anim->setRunState(CCActiveAnimation::Paused, 0); @@ -170,7 +170,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtNotRunning) TEST(CCActiveAnimationTest, IsFinished) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setRunState(CCActiveAnimation::Running, 0); EXPECT_FALSE(anim->isFinished()); anim->setRunState(CCActiveAnimation::Paused, 0); @@ -189,7 +189,7 @@ TEST(CCActiveAnimationTest, IsFinished) TEST(CCActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->setRunState(CCActiveAnimation::Running, 2); EXPECT_FALSE(anim->isFinished()); anim->setRunState(CCActiveAnimation::Paused, 2); @@ -208,7 +208,7 @@ TEST(CCActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime) TEST(CCActiveAnimationTest, RunStateChangesIgnoredWhileSuspended) { - OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); + scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1)); anim->suspend(0); EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); anim->setRunState(CCActiveAnimation::Running, 0); diff --git a/cc/CCAnimationCurve.h b/cc/CCAnimationCurve.h index c177d23..7ed6e7a 100644 --- a/cc/CCAnimationCurve.h +++ b/cc/CCAnimationCurve.h @@ -5,8 +5,8 @@ #ifndef CCAnimationCurve_h #define CCAnimationCurve_h +#include "base/memory/scoped_ptr.h" #include <public/WebTransformationMatrix.h> -#include <wtf/PassOwnPtr.h> namespace cc { @@ -25,7 +25,7 @@ public: virtual double duration() const = 0; virtual Type type() const = 0; - virtual PassOwnPtr<CCAnimationCurve> clone() const = 0; + virtual scoped_ptr<CCAnimationCurve> clone() const = 0; const CCFloatAnimationCurve* toFloatAnimationCurve() const; const CCTransformAnimationCurve* toTransformAnimationCurve() const; diff --git a/cc/CCKeyframedAnimationCurve.cpp b/cc/CCKeyframedAnimationCurve.cpp index 5357976..b60e66d 100644 --- a/cc/CCKeyframedAnimationCurve.cpp +++ b/cc/CCKeyframedAnimationCurve.cpp @@ -6,8 +6,6 @@ #include "CCKeyframedAnimationCurve.h" -#include <wtf/OwnPtr.h> - using WebKit::WebTransformationMatrix; namespace cc { @@ -15,36 +13,34 @@ namespace cc { namespace { template <class Keyframe> -void insertKeyframe(PassOwnPtr<Keyframe> popKeyframe, OwnPtrVector<Keyframe>& keyframes) +void insertKeyframe(scoped_ptr<Keyframe> keyframe, ScopedPtrVector<Keyframe>& keyframes) { - OwnPtr<Keyframe> keyframe = popKeyframe; - // Usually, the keyframes will be added in order, so this loop would be unnecessary and // we should skip it if possible. if (!keyframes.isEmpty() && keyframe->time() < keyframes.last()->time()) { for (size_t i = 0; i < keyframes.size(); ++i) { if (keyframe->time() < keyframes[i]->time()) { - keyframes.insert(i, keyframe.release()); + keyframes.insert(i, keyframe.Pass()); return; } } } - keyframes.append(keyframe.release()); + keyframes.append(keyframe.Pass()); } -PassOwnPtr<CCTimingFunction> cloneTimingFunction(const CCTimingFunction* timingFunction) +scoped_ptr<CCTimingFunction> cloneTimingFunction(const CCTimingFunction* timingFunction) { ASSERT(timingFunction); - OwnPtr<CCAnimationCurve> curve(timingFunction->clone()); - return adoptPtr(static_cast<CCTimingFunction*>(curve.leakPtr())); + scoped_ptr<CCAnimationCurve> curve(timingFunction->clone()); + return scoped_ptr<CCTimingFunction>(static_cast<CCTimingFunction*>(curve.release())); } } // namespace -CCKeyframe::CCKeyframe(double time, PassOwnPtr<CCTimingFunction> timingFunction) +CCKeyframe::CCKeyframe(double time, scoped_ptr<CCTimingFunction> timingFunction) : m_time(time) - , m_timingFunction(timingFunction) + , m_timingFunction(timingFunction.Pass()) { } @@ -62,13 +58,13 @@ const CCTimingFunction* CCKeyframe::timingFunction() const return m_timingFunction.get(); } -PassOwnPtr<CCFloatKeyframe> CCFloatKeyframe::create(double time, float value, PassOwnPtr<CCTimingFunction> timingFunction) +scoped_ptr<CCFloatKeyframe> CCFloatKeyframe::create(double time, float value, scoped_ptr<CCTimingFunction> timingFunction) { - return adoptPtr(new CCFloatKeyframe(time, value, timingFunction)); + return make_scoped_ptr(new CCFloatKeyframe(time, value, timingFunction.Pass())); } -CCFloatKeyframe::CCFloatKeyframe(double time, float value, PassOwnPtr<CCTimingFunction> timingFunction) - : CCKeyframe(time, timingFunction) +CCFloatKeyframe::CCFloatKeyframe(double time, float value, scoped_ptr<CCTimingFunction> timingFunction) + : CCKeyframe(time, timingFunction.Pass()) , m_value(value) { } @@ -82,18 +78,17 @@ float CCFloatKeyframe::value() const return m_value; } -PassOwnPtr<CCFloatKeyframe> CCFloatKeyframe::clone() const +scoped_ptr<CCFloatKeyframe> CCFloatKeyframe::clone() const { - return CCFloatKeyframe::create(time(), value(), timingFunction() ? cloneTimingFunction(timingFunction()) : nullptr); -} + return CCFloatKeyframe::create(time(), value(), timingFunction() ? cloneTimingFunction(timingFunction()) : scoped_ptr<CCTimingFunction>()); } -PassOwnPtr<CCTransformKeyframe> CCTransformKeyframe::create(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction> timingFunction) +scoped_ptr<CCTransformKeyframe> CCTransformKeyframe::create(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction> timingFunction) { - return adoptPtr(new CCTransformKeyframe(time, value, timingFunction)); + return make_scoped_ptr(new CCTransformKeyframe(time, value, timingFunction.Pass())); } -CCTransformKeyframe::CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction> timingFunction) - : CCKeyframe(time, timingFunction) +CCTransformKeyframe::CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction> timingFunction) + : CCKeyframe(time, timingFunction.Pass()) , m_value(value) { } @@ -107,14 +102,14 @@ const WebKit::WebTransformOperations& CCTransformKeyframe::value() const return m_value; } -PassOwnPtr<CCTransformKeyframe> CCTransformKeyframe::clone() const +scoped_ptr<CCTransformKeyframe> CCTransformKeyframe::clone() const { - return CCTransformKeyframe::create(time(), value(), timingFunction() ? cloneTimingFunction(timingFunction()) : nullptr); + return CCTransformKeyframe::create(time(), value(), timingFunction() ? cloneTimingFunction(timingFunction()) : scoped_ptr<CCTimingFunction>()); } -PassOwnPtr<CCKeyframedFloatAnimationCurve> CCKeyframedFloatAnimationCurve::create() +scoped_ptr<CCKeyframedFloatAnimationCurve> CCKeyframedFloatAnimationCurve::create() { - return adoptPtr(new CCKeyframedFloatAnimationCurve); + return make_scoped_ptr(new CCKeyframedFloatAnimationCurve); } CCKeyframedFloatAnimationCurve::CCKeyframedFloatAnimationCurve() @@ -125,9 +120,9 @@ CCKeyframedFloatAnimationCurve::~CCKeyframedFloatAnimationCurve() { } -void CCKeyframedFloatAnimationCurve::addKeyframe(PassOwnPtr<CCFloatKeyframe> keyframe) +void CCKeyframedFloatAnimationCurve::addKeyframe(scoped_ptr<CCFloatKeyframe> keyframe) { - insertKeyframe(keyframe, m_keyframes); + insertKeyframe(keyframe.Pass(), m_keyframes); } double CCKeyframedFloatAnimationCurve::duration() const @@ -135,12 +130,12 @@ double CCKeyframedFloatAnimationCurve::duration() const return m_keyframes.last()->time() - m_keyframes.first()->time(); } -PassOwnPtr<CCAnimationCurve> CCKeyframedFloatAnimationCurve::clone() const +scoped_ptr<CCAnimationCurve> CCKeyframedFloatAnimationCurve::clone() const { - OwnPtr<CCKeyframedFloatAnimationCurve> toReturn(CCKeyframedFloatAnimationCurve::create()); + scoped_ptr<CCKeyframedFloatAnimationCurve> toReturn(CCKeyframedFloatAnimationCurve::create()); for (size_t i = 0; i < m_keyframes.size(); ++i) toReturn->addKeyframe(m_keyframes[i]->clone()); - return toReturn.release(); + return toReturn.PassAs<CCAnimationCurve>(); } float CCKeyframedFloatAnimationCurve::getValue(double t) const @@ -165,9 +160,9 @@ float CCKeyframedFloatAnimationCurve::getValue(double t) const return m_keyframes[i]->value() + (m_keyframes[i+1]->value() - m_keyframes[i]->value()) * progress; } -PassOwnPtr<CCKeyframedTransformAnimationCurve> CCKeyframedTransformAnimationCurve::create() +scoped_ptr<CCKeyframedTransformAnimationCurve> CCKeyframedTransformAnimationCurve::create() { - return adoptPtr(new CCKeyframedTransformAnimationCurve); + return make_scoped_ptr(new CCKeyframedTransformAnimationCurve); } CCKeyframedTransformAnimationCurve::CCKeyframedTransformAnimationCurve() @@ -178,9 +173,9 @@ CCKeyframedTransformAnimationCurve::~CCKeyframedTransformAnimationCurve() { } -void CCKeyframedTransformAnimationCurve::addKeyframe(PassOwnPtr<CCTransformKeyframe> keyframe) +void CCKeyframedTransformAnimationCurve::addKeyframe(scoped_ptr<CCTransformKeyframe> keyframe) { - insertKeyframe(keyframe, m_keyframes); + insertKeyframe(keyframe.Pass(), m_keyframes); } double CCKeyframedTransformAnimationCurve::duration() const @@ -188,12 +183,12 @@ double CCKeyframedTransformAnimationCurve::duration() const return m_keyframes.last()->time() - m_keyframes.first()->time(); } -PassOwnPtr<CCAnimationCurve> CCKeyframedTransformAnimationCurve::clone() const +scoped_ptr<CCAnimationCurve> CCKeyframedTransformAnimationCurve::clone() const { - OwnPtr<CCKeyframedTransformAnimationCurve> toReturn(CCKeyframedTransformAnimationCurve::create()); + scoped_ptr<CCKeyframedTransformAnimationCurve> toReturn(CCKeyframedTransformAnimationCurve::create()); for (size_t i = 0; i < m_keyframes.size(); ++i) toReturn->addKeyframe(m_keyframes[i]->clone()); - return toReturn.release(); + return toReturn.PassAs<CCAnimationCurve>(); } WebTransformationMatrix CCKeyframedTransformAnimationCurve::getValue(double t) const diff --git a/cc/CCKeyframedAnimationCurve.h b/cc/CCKeyframedAnimationCurve.h index 33cee77..066e5c6 100644 --- a/cc/CCKeyframedAnimationCurve.h +++ b/cc/CCKeyframedAnimationCurve.h @@ -7,10 +7,8 @@ #include "CCAnimationCurve.h" #include "CCTimingFunction.h" -#include "cc/own_ptr_vector.h" +#include "scoped_ptr_vector.h" #include <public/WebTransformOperations.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> namespace cc { @@ -20,40 +18,40 @@ public: const CCTimingFunction* timingFunction() const; protected: - CCKeyframe(double time, PassOwnPtr<CCTimingFunction>); + CCKeyframe(double time, scoped_ptr<CCTimingFunction>); virtual ~CCKeyframe(); private: double m_time; - OwnPtr<CCTimingFunction> m_timingFunction; + scoped_ptr<CCTimingFunction> m_timingFunction; }; class CCFloatKeyframe : public CCKeyframe { public: - static PassOwnPtr<CCFloatKeyframe> create(double time, float value, PassOwnPtr<CCTimingFunction>); + static scoped_ptr<CCFloatKeyframe> create(double time, float value, scoped_ptr<CCTimingFunction>); virtual ~CCFloatKeyframe(); float value() const; - PassOwnPtr<CCFloatKeyframe> clone() const; + scoped_ptr<CCFloatKeyframe> clone() const; private: - CCFloatKeyframe(double time, float value, PassOwnPtr<CCTimingFunction>); + CCFloatKeyframe(double time, float value, scoped_ptr<CCTimingFunction>); float m_value; }; class CCTransformKeyframe : public CCKeyframe { public: - static PassOwnPtr<CCTransformKeyframe> create(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction>); + static scoped_ptr<CCTransformKeyframe> create(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction>); virtual ~CCTransformKeyframe(); const WebKit::WebTransformOperations& value() const; - PassOwnPtr<CCTransformKeyframe> clone() const; + scoped_ptr<CCTransformKeyframe> clone() const; private: - CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction>); + CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction>); WebKit::WebTransformOperations m_value; }; @@ -61,15 +59,15 @@ private: class CCKeyframedFloatAnimationCurve : public CCFloatAnimationCurve { public: // It is required that the keyframes be sorted by time. - static PassOwnPtr<CCKeyframedFloatAnimationCurve> create(); + static scoped_ptr<CCKeyframedFloatAnimationCurve> create(); virtual ~CCKeyframedFloatAnimationCurve(); - void addKeyframe(PassOwnPtr<CCFloatKeyframe>); + void addKeyframe(scoped_ptr<CCFloatKeyframe>); // CCAnimationCurve implementation virtual double duration() const OVERRIDE; - virtual PassOwnPtr<CCAnimationCurve> clone() const OVERRIDE; + virtual scoped_ptr<CCAnimationCurve> clone() const OVERRIDE; // CCFloatAnimationCurve implementation virtual float getValue(double t) const OVERRIDE; @@ -79,21 +77,21 @@ private: // Always sorted in order of increasing time. No two keyframes have the // same time. - OwnPtrVector<CCFloatKeyframe> m_keyframes; + ScopedPtrVector<CCFloatKeyframe> m_keyframes; }; class CCKeyframedTransformAnimationCurve : public CCTransformAnimationCurve { public: // It is required that the keyframes be sorted by time. - static PassOwnPtr<CCKeyframedTransformAnimationCurve> create(); + static scoped_ptr<CCKeyframedTransformAnimationCurve> create(); virtual ~CCKeyframedTransformAnimationCurve(); - void addKeyframe(PassOwnPtr<CCTransformKeyframe>); + void addKeyframe(scoped_ptr<CCTransformKeyframe>); // CCAnimationCurve implementation virtual double duration() const OVERRIDE; - virtual PassOwnPtr<CCAnimationCurve> clone() const OVERRIDE; + virtual scoped_ptr<CCAnimationCurve> clone() const OVERRIDE; // CCTransformAnimationCurve implementation virtual WebKit::WebTransformationMatrix getValue(double t) const OVERRIDE; @@ -103,7 +101,7 @@ private: // Always sorted in order of increasing time. No two keyframes have the // same time. - OwnPtrVector<CCTransformKeyframe> m_keyframes; + ScopedPtrVector<CCTransformKeyframe> m_keyframes; }; } // namespace cc diff --git a/cc/CCKeyframedAnimationCurveTest.cpp b/cc/CCKeyframedAnimationCurveTest.cpp index 21353ed..9dca26a 100644 --- a/cc/CCKeyframedAnimationCurveTest.cpp +++ b/cc/CCKeyframedAnimationCurveTest.cpp @@ -10,7 +10,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include <public/WebTransformOperations.h> #include <public/WebTransformationMatrix.h> -#include <wtf/OwnPtr.h> using namespace cc; using WebKit::WebTransformationMatrix; @@ -25,8 +24,8 @@ void expectTranslateX(double translateX, const WebTransformationMatrix& matrix) // Tests that a float animation with one keyframe works as expected. TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>())); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); @@ -37,9 +36,9 @@ TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) // Tests that a float animation with two keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>())); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -50,10 +49,10 @@ TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) // Tests that a float animation with three keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction>())); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -66,11 +65,11 @@ TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) // Tests that a float animation with multiple keys at a given time works sanely. TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 4, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(1, 6, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(2, 6, nullptr)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 4, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 6, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(2, 6, scoped_ptr<CCTimingFunction>())); EXPECT_FLOAT_EQ(4, curve->getValue(-1)); EXPECT_FLOAT_EQ(4, curve->getValue(0)); @@ -89,10 +88,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) // Tests that a transform animation with one keyframe works as expected. TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) { - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); + scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); WebKit::WebTransformOperations operations; operations.appendTranslate(2, 0, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, operations, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations, scoped_ptr<CCTimingFunction>())); expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(0)); @@ -104,14 +103,14 @@ TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) // Tests that a transform animation with two keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) { - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); + scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); WebKit::WebTransformOperations operations1; operations1.appendTranslate(2, 0, 0); WebKit::WebTransformOperations operations2; operations2.appendTranslate(4, 0, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); - curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>())); expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(0)); expectTranslateX(3, curve->getValue(0.5)); @@ -122,16 +121,16 @@ TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) // Tests that a transform animation with three keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) { - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); + scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); WebKit::WebTransformOperations operations1; operations1.appendTranslate(2, 0, 0); WebKit::WebTransformOperations operations2; operations2.appendTranslate(4, 0, 0); WebKit::WebTransformOperations operations3; operations3.appendTranslate(8, 0, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); - curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); - curve->addKeyframe(CCTransformKeyframe::create(2, operations3, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCTransformKeyframe::create(2, operations3, scoped_ptr<CCTimingFunction>())); expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(0)); expectTranslateX(3, curve->getValue(0.5)); @@ -144,7 +143,7 @@ TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) // Tests that a transform animation with multiple keys at a given time works sanely. TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) { - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); + scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); // A step function. WebKit::WebTransformOperations operations1; operations1.appendTranslate(4, 0, 0); @@ -154,10 +153,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) operations3.appendTranslate(6, 0, 0); WebKit::WebTransformOperations operations4; operations4.appendTranslate(6, 0, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); - curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); - curve->addKeyframe(CCTransformKeyframe::create(1, operations3, nullptr)); - curve->addKeyframe(CCTransformKeyframe::create(2, operations4, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCTransformKeyframe::create(1, operations3, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCTransformKeyframe::create(2, operations4, scoped_ptr<CCTimingFunction>())); expectTranslateX(4, curve->getValue(-1)); expectTranslateX(4, curve->getValue(0)); @@ -175,10 +174,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) // Tests that the keyframes may be added out of order. TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>())); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -191,9 +190,9 @@ TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) // Tests that a cubic bezier timing function works as expected. TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1))); - curve->addKeyframe(CCFloatKeyframe::create(1, 1, nullptr)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1).PassAs<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 1, scoped_ptr<CCTimingFunction>())); EXPECT_FLOAT_EQ(0, curve->getValue(0)); EXPECT_LT(0, curve->getValue(0.25)); diff --git a/cc/CCLayerAnimationController.cpp b/cc/CCLayerAnimationController.cpp index 6c64ac78..5039294 100644 --- a/cc/CCLayerAnimationController.cpp +++ b/cc/CCLayerAnimationController.cpp @@ -26,9 +26,9 @@ CCLayerAnimationController::~CCLayerAnimationController() { } -PassOwnPtr<CCLayerAnimationController> CCLayerAnimationController::create(CCLayerAnimationControllerClient* client) +scoped_ptr<CCLayerAnimationController> CCLayerAnimationController::create(CCLayerAnimationControllerClient* client) { - return adoptPtr(new CCLayerAnimationController(client)); + return make_scoped_ptr(new CCLayerAnimationController(client)); } void CCLayerAnimationController::pauseAnimation(int animationId, double timeOffset) @@ -108,9 +108,9 @@ void CCLayerAnimationController::animate(double monotonicTime, CCAnimationEvents startAnimationsWaitingForTargetAvailability(monotonicTime, events); } -void CCLayerAnimationController::addAnimation(PassOwnPtr<CCActiveAnimation> animation) +void CCLayerAnimationController::addAnimation(scoped_ptr<CCActiveAnimation> animation) { - m_activeAnimations.append(animation); + m_activeAnimations.append(animation.Pass()); } CCActiveAnimation* CCLayerAnimationController::getActiveAnimation(int groupId, CCActiveAnimation::TargetProperty targetProperty) const @@ -183,9 +183,9 @@ void CCLayerAnimationController::pushNewAnimationsToImplThread(CCLayerAnimationC // The new animation should be set to run as soon as possible. CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability; double startTime = 0; - OwnPtr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime)); + scoped_ptr<CCActiveAnimation> toAdd(m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime)); ASSERT(!toAdd->needsSynchronizedStartTime()); - controllerImpl->addAnimation(toAdd.release()); + controllerImpl->addAnimation(toAdd.Pass()); } } @@ -348,17 +348,17 @@ void CCLayerAnimationController::replaceImplThreadAnimations(CCLayerAnimationCon { controllerImpl->m_activeAnimations.clear(); for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - OwnPtr<CCActiveAnimation> toAdd; + scoped_ptr<CCActiveAnimation> 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. CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability; double startTime = 0; - toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime); + toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime).Pass(); } else - toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance); + toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance).Pass(); - controllerImpl->addAnimation(toAdd.release()); + controllerImpl->addAnimation(toAdd.Pass()); } } diff --git a/cc/CCLayerAnimationController.h b/cc/CCLayerAnimationController.h index 2b6ae64..8b4856e 100644 --- a/cc/CCLayerAnimationController.h +++ b/cc/CCLayerAnimationController.h @@ -8,10 +8,9 @@ #include "CCAnimationEvents.h" #include "base/basictypes.h" -#include "cc/own_ptr_vector.h" +#include "base/memory/scoped_ptr.h" +#include "cc/scoped_ptr_vector.h" #include <wtf/HashSet.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassOwnPtr.h> namespace WebKit { class WebTransformationMatrix; @@ -36,12 +35,12 @@ public: class CCLayerAnimationController { public: - static PassOwnPtr<CCLayerAnimationController> create(CCLayerAnimationControllerClient*); + static scoped_ptr<CCLayerAnimationController> create(CCLayerAnimationControllerClient*); virtual ~CCLayerAnimationController(); // These methods are virtual for testing. - virtual void addAnimation(PassOwnPtr<CCActiveAnimation>); + virtual void addAnimation(scoped_ptr<CCActiveAnimation>); virtual void pauseAnimation(int animationId, double timeOffset); virtual void removeAnimation(int animationId); virtual void removeAnimation(int animationId, CCActiveAnimation::TargetProperty); @@ -103,7 +102,7 @@ private: bool m_forceSync; CCLayerAnimationControllerClient* m_client; - OwnPtrVector<CCActiveAnimation> m_activeAnimations; + ScopedPtrVector<CCActiveAnimation> m_activeAnimations; DISALLOW_COPY_AND_ASSIGN(CCLayerAnimationController); }; diff --git a/cc/CCLayerAnimationControllerTest.cpp b/cc/CCLayerAnimationControllerTest.cpp index b6004a0..4d9e575 100644 --- a/cc/CCLayerAnimationControllerTest.cpp +++ b/cc/CCLayerAnimationControllerTest.cpp @@ -24,17 +24,17 @@ void expectTranslateX(double translateX, const WebTransformationMatrix& matrix) EXPECT_FLOAT_EQ(translateX, matrix.m41()); } -PassOwnPtr<CCActiveAnimation> createActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int id, CCActiveAnimation::TargetProperty property) +scoped_ptr<CCActiveAnimation> createActiveAnimation(scoped_ptr<CCAnimationCurve> curve, int id, CCActiveAnimation::TargetProperty property) { - return CCActiveAnimation::create(curve, 0, id, property); + return CCActiveAnimation::create(curve.Pass(), 0, id, property); } TEST(CCLayerAnimationControllerTest, syncNewAnimation) { FakeLayerAnimationControllerClient dummyImpl; - OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); + scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -51,9 +51,9 @@ TEST(CCLayerAnimationControllerTest, syncNewAnimation) TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes) { FakeLayerAnimationControllerClient dummyImpl; - OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); + scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -80,9 +80,9 @@ TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes) TEST(CCLayerAnimationControllerTest, syncPauseAndResume) { FakeLayerAnimationControllerClient dummyImpl; - OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); + scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -120,9 +120,9 @@ TEST(CCLayerAnimationControllerTest, syncPauseAndResume) TEST(CCLayerAnimationControllerTest, doNotSyncFinishedAnimation) { FakeLayerAnimationControllerClient dummyImpl; - OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); + scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -151,14 +151,14 @@ TEST(CCLayerAnimationControllerTest, doNotSyncFinishedAnimation) // Tests that transitioning opacity from 0 to 1 works as expected. TEST(CCLayerAnimationControllerTest, TrivialTransition) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); @@ -170,16 +170,16 @@ TEST(CCLayerAnimationControllerTest, TrivialTransition) // Tests animations that are waiting for a synchronized start time do not finish. TEST(CCLayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDuration) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); toAdd->setNeedsSynchronizedStartTime(true); // We should pause at the first keyframe indefinitely waiting for that animation to start. - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); @@ -200,13 +200,13 @@ TEST(CCLayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfT // Tests that two queued animations affecting the same property run in sequence. TEST(CCLayerAnimationControllerTest, TrivialQueuing) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5)), 2, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -222,18 +222,18 @@ TEST(CCLayerAnimationControllerTest, TrivialQueuing) // Tests interrupting a transition with another transition. TEST(CCLayerAnimationControllerTest, Interrupt) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5)), 2, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForNextTick, 0); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); // Since the animation was in the WaitingForNextTick state, it should start right in // this call to animate. @@ -248,14 +248,14 @@ TEST(CCLayerAnimationControllerTest, Interrupt) // Tests scheduling two animations to run together when only one property is free. TEST(CCLayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), 1, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), 2, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 2, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Transform)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Transform)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_EQ(0, dummy.opacity()); @@ -275,14 +275,14 @@ TEST(CCLayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) // for both to finish). TEST(CCLayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(2)), 1, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5)), 2, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(2)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Transform)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); // Animations with id 1 should both start now. controller->animate(0, events.get()); @@ -305,15 +305,15 @@ TEST(CCLayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) // Tests scheduling an animation to start in the future. TEST(CCLayerAnimationControllerTest, ScheduleAnimation) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -329,17 +329,17 @@ TEST(CCLayerAnimationControllerTest, ScheduleAnimation) // Tests scheduling an animation to start in the future that's interrupting a running animation. TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0.5, 0)), 2, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0.5, 0)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); // First 2s opacity transition should start immediately. controller->animate(0, events.get()); @@ -360,19 +360,19 @@ TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimatio // and there is yet another animation queued to start later. TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0.5, 0)), 2, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0.5, 0)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 0.75)), 3, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 0.75)).PassAs<CCAnimationCurve>(), 3, CCActiveAnimation::Opacity)); // First 2s opacity transition should start immediately. controller->animate(0, events.get()); @@ -396,14 +396,14 @@ TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimatio // Test that a looping animation loops and for the correct number of iterations. TEST(CCLayerAnimationControllerTest, TrivialLooping) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Opacity)); toAdd->setIterations(3); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -432,15 +432,15 @@ TEST(CCLayerAnimationControllerTest, TrivialLooping) // Test that an infinitely looping animation does indeed go until aborted. TEST(CCLayerAnimationControllerTest, InfiniteLooping) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); const int id = 1; - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), id, CCActiveAnimation::Opacity)); toAdd->setIterations(-1); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -468,13 +468,13 @@ TEST(CCLayerAnimationControllerTest, InfiniteLooping) // Test that pausing and resuming work as expected. TEST(CCLayerAnimationControllerTest, PauseResume) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); const int id = 1; - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), id, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -503,15 +503,15 @@ TEST(CCLayerAnimationControllerTest, PauseResume) TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation) { - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); const int id = 1; - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), id, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), id, CCActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.75)), 2, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<CCAnimationCurve>(), id, CCActiveAnimation::Transform)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<CCAnimationCurve>(), id, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.75)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -533,15 +533,15 @@ TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation) TEST(CCLayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) { FakeLayerAnimationControllerClient dummyImpl; - OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); - OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - OwnPtr<CCLayerAnimationController> controller( + scoped_ptr<CCLayerAnimationController> controller( CCLayerAnimationController::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 0, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<CCAnimationCurve>(), 0, CCActiveAnimation::Opacity)); toAdd->setNeedsSynchronizedStartTime(true); - controller->addAnimation(toAdd.release()); + controller->addAnimation(toAdd.Pass()); controller->animate(0, 0); EXPECT_TRUE(controller->hasActiveAnimation()); diff --git a/cc/CCLayerImpl.h b/cc/CCLayerImpl.h index 92cfbb2..1c3c368 100644 --- a/cc/CCLayerImpl.h +++ b/cc/CCLayerImpl.h @@ -386,7 +386,7 @@ private: FloatRect m_updateRect; // Manages animations for this layer. - OwnPtr<CCLayerAnimationController> m_layerAnimationController; + scoped_ptr<CCLayerAnimationController> m_layerAnimationController; // Manages scrollbars for this layer OwnPtr<CCScrollbarAnimationController> m_scrollbarAnimationController; diff --git a/cc/CCLayerTreeHostTest.cpp b/cc/CCLayerTreeHostTest.cpp index 0a79ea2..2e3d88d 100644 --- a/cc/CCLayerTreeHostTest.cpp +++ b/cc/CCLayerTreeHostTest.cpp @@ -2188,9 +2188,9 @@ public: layer->setLayerAnimationDelegate(this); // Any valid CCAnimationCurve will do here. - OwnPtr<CCAnimationCurve> curve(CCEaseTimingFunction::create()); - OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), 1, 1, CCActiveAnimation::Opacity)); - layer->layerAnimationController()->addAnimation(animation.release()); + scoped_ptr<CCAnimationCurve> curve(CCEaseTimingFunction::create()); + scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.Pass(), 1, 1, CCActiveAnimation::Opacity)); + layer->layerAnimationController()->addAnimation(animation.Pass()); // We add the animation *before* attaching the layer to the tree. m_layerTreeHost->rootLayer()->addChild(layer); diff --git a/cc/CCTimingFunction.cpp b/cc/CCTimingFunction.cpp index 224a0ba..3a4ecd4 100644 --- a/cc/CCTimingFunction.cpp +++ b/cc/CCTimingFunction.cpp @@ -6,8 +6,6 @@ #include "CCTimingFunction.h" -#include <wtf/OwnPtr.h> - namespace { const double epsilon = 1e-6; } // namespace @@ -27,9 +25,9 @@ double CCTimingFunction::duration() const return 1.0; } -PassOwnPtr<CCCubicBezierTimingFunction> CCCubicBezierTimingFunction::create(double x1, double y1, double x2, double y2) +scoped_ptr<CCCubicBezierTimingFunction> CCCubicBezierTimingFunction::create(double x1, double y1, double x2, double y2) { - return adoptPtr(new CCCubicBezierTimingFunction(x1, y1, x2, y2)); + return make_scoped_ptr(new CCCubicBezierTimingFunction(x1, y1, x2, y2)); } CCCubicBezierTimingFunction::CCCubicBezierTimingFunction(double x1, double y1, double x2, double y2) @@ -47,30 +45,30 @@ float CCCubicBezierTimingFunction::getValue(double x) const return static_cast<float>(temp.solve(x, epsilon)); } -PassOwnPtr<CCAnimationCurve> CCCubicBezierTimingFunction::clone() const +scoped_ptr<CCAnimationCurve> CCCubicBezierTimingFunction::clone() const { - return adoptPtr(new CCCubicBezierTimingFunction(*this)); + return make_scoped_ptr(new CCCubicBezierTimingFunction(*this)).PassAs<CCAnimationCurve>(); } // These numbers come from http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag. -PassOwnPtr<CCTimingFunction> CCEaseTimingFunction::create() +scoped_ptr<CCTimingFunction> CCEaseTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0.25, 0.1, 0.25, 1); + return CCCubicBezierTimingFunction::create(0.25, 0.1, 0.25, 1).PassAs<CCTimingFunction>(); } -PassOwnPtr<CCTimingFunction> CCEaseInTimingFunction::create() +scoped_ptr<CCTimingFunction> CCEaseInTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0.42, 0, 1.0, 1); + return CCCubicBezierTimingFunction::create(0.42, 0, 1.0, 1).PassAs<CCTimingFunction>(); } -PassOwnPtr<CCTimingFunction> CCEaseOutTimingFunction::create() +scoped_ptr<CCTimingFunction> CCEaseOutTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0, 0, 0.58, 1); + return CCCubicBezierTimingFunction::create(0, 0, 0.58, 1).PassAs<CCTimingFunction>(); } -PassOwnPtr<CCTimingFunction> CCEaseInOutTimingFunction::create() +scoped_ptr<CCTimingFunction> CCEaseInOutTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0.42, 0, 0.58, 1); + return CCCubicBezierTimingFunction::create(0.42, 0, 0.58, 1).PassAs<CCTimingFunction>(); } } // namespace cc diff --git a/cc/CCTimingFunction.h b/cc/CCTimingFunction.h index 990403a..993ab87 100644 --- a/cc/CCTimingFunction.h +++ b/cc/CCTimingFunction.h @@ -7,7 +7,6 @@ #include "CCAnimationCurve.h" #include "UnitBezier.h" -#include <wtf/PassOwnPtr.h> namespace cc { @@ -25,12 +24,12 @@ protected: class CCCubicBezierTimingFunction : public CCTimingFunction { public: - static PassOwnPtr<CCCubicBezierTimingFunction> create(double x1, double y1, double x2, double y2); + static scoped_ptr<CCCubicBezierTimingFunction> create(double x1, double y1, double x2, double y2); virtual ~CCCubicBezierTimingFunction(); // Partial implementation of CCFloatAnimationCurve. virtual float getValue(double time) const OVERRIDE; - virtual PassOwnPtr<CCAnimationCurve> clone() const OVERRIDE; + virtual scoped_ptr<CCAnimationCurve> clone() const OVERRIDE; protected: CCCubicBezierTimingFunction(double x1, double y1, double x2, double y2); @@ -40,22 +39,22 @@ protected: class CCEaseTimingFunction { public: - static PassOwnPtr<CCTimingFunction> create(); + static scoped_ptr<CCTimingFunction> create(); }; class CCEaseInTimingFunction { public: - static PassOwnPtr<CCTimingFunction> create(); + static scoped_ptr<CCTimingFunction> create(); }; class CCEaseOutTimingFunction { public: - static PassOwnPtr<CCTimingFunction> create(); + static scoped_ptr<CCTimingFunction> create(); }; class CCEaseInOutTimingFunction { public: - static PassOwnPtr<CCTimingFunction> create(); + static scoped_ptr<CCTimingFunction> create(); }; } // namespace cc diff --git a/cc/LayerChromium.cpp b/cc/LayerChromium.cpp index 9d1fda6..1f1551a 100644 --- a/cc/LayerChromium.cpp +++ b/cc/LayerChromium.cpp @@ -648,7 +648,7 @@ void LayerChromium::setBoundsContainPageScale(bool boundsContainPageScale) void LayerChromium::createRenderSurface() { ASSERT(!m_renderSurface); - m_renderSurface = adoptPtr(new RenderSurfaceChromium(this)); + m_renderSurface = make_scoped_ptr(new RenderSurfaceChromium(this)); setRenderTarget(this); } @@ -692,7 +692,7 @@ void LayerChromium::setTransformFromAnimation(const WebTransformationMatrix& tra m_transform = transform; } -bool LayerChromium::addAnimation(PassOwnPtr<CCActiveAnimation> animation) +bool LayerChromium::addAnimation(scoped_ptr <CCActiveAnimation> animation) { // WebCore currently assumes that accelerated animations will start soon // after the animation is added. However we cannot guarantee that if we do @@ -703,7 +703,7 @@ bool LayerChromium::addAnimation(PassOwnPtr<CCActiveAnimation> animation) if (!CCSettings::acceleratedAnimationEnabled()) return false; - m_layerAnimationController->addAnimation(animation); + m_layerAnimationController->addAnimation(animation.Pass()); if (m_layerTreeHost) { m_layerTreeHost->didAddAnimation(); setNeedsCommit(); @@ -735,9 +735,9 @@ void LayerChromium::resumeAnimations(double monotonicTime) setNeedsCommit(); } -void LayerChromium::setLayerAnimationController(PassOwnPtr<CCLayerAnimationController> layerAnimationController) +void LayerChromium::setLayerAnimationController(scoped_ptr<CCLayerAnimationController> layerAnimationController) { - m_layerAnimationController = layerAnimationController; + m_layerAnimationController = layerAnimationController.Pass(); if (m_layerAnimationController) { m_layerAnimationController->setClient(this); m_layerAnimationController->setForceSync(); @@ -745,11 +745,11 @@ void LayerChromium::setLayerAnimationController(PassOwnPtr<CCLayerAnimationContr setNeedsCommit(); } -PassOwnPtr<CCLayerAnimationController> LayerChromium::releaseLayerAnimationController() +scoped_ptr<CCLayerAnimationController> LayerChromium::releaseLayerAnimationController() { - OwnPtr<CCLayerAnimationController> toReturn = m_layerAnimationController.release(); + scoped_ptr<CCLayerAnimationController> toReturn = m_layerAnimationController.Pass(); m_layerAnimationController = CCLayerAnimationController::create(this); - return toReturn.release(); + return toReturn.Pass(); } bool LayerChromium::hasActiveAnimation() const diff --git a/cc/LayerChromium.h b/cc/LayerChromium.h index 0c98304..b09984b 100644 --- a/cc/LayerChromium.h +++ b/cc/LayerChromium.h @@ -196,7 +196,7 @@ public: virtual void pushPropertiesTo(CCLayerImpl*); - void clearRenderSurface() { m_renderSurface.clear(); } + void clearRenderSurface() { m_renderSurface.reset(); } RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); } void createRenderSurface(); @@ -243,7 +243,7 @@ public: // Set the priority of all desired textures in this layer. virtual void setTexturePriorities(const CCPriorityCalculator&) { } - bool addAnimation(PassOwnPtr<CCActiveAnimation>); + bool addAnimation(scoped_ptr<CCActiveAnimation>); void pauseAnimation(int animationId, double timeOffset); void removeAnimation(int animationId); @@ -251,8 +251,8 @@ public: void resumeAnimations(double monotonicTime); CCLayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); } - void setLayerAnimationController(PassOwnPtr<CCLayerAnimationController>); - PassOwnPtr<CCLayerAnimationController> releaseLayerAnimationController(); + void setLayerAnimationController(scoped_ptr<CCLayerAnimationController>); + scoped_ptr<CCLayerAnimationController> releaseLayerAnimationController(); void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationDelegate) { m_layerAnimationDelegate = layerAnimationDelegate; } @@ -317,7 +317,7 @@ private: // updated via setLayerTreeHost() if a layer moves between trees. CCLayerTreeHost* m_layerTreeHost; - OwnPtr<CCLayerAnimationController> m_layerAnimationController; + scoped_ptr<CCLayerAnimationController> m_layerAnimationController; // Layer properties. IntSize m_bounds; @@ -361,7 +361,7 @@ private: scoped_refptr<LayerChromium> m_replicaLayer; // Transient properties. - OwnPtr<RenderSurfaceChromium> m_renderSurface; + scoped_ptr<RenderSurfaceChromium> m_renderSurface; float m_drawOpacity; bool m_drawOpacityIsAnimating; diff --git a/cc/LayerChromiumTest.cpp b/cc/LayerChromiumTest.cpp index 867e4db..b1ca80e 100644 --- a/cc/LayerChromiumTest.cpp +++ b/cc/LayerChromiumTest.cpp @@ -791,12 +791,12 @@ TEST(LayerChromiumLayerTreeHostTest, destroyHostWithNonNullRootLayer) static bool addTestAnimation(LayerChromium* layer) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, nullptr)); - curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, nullptr)); - OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), 0, 0, CCActiveAnimation::Opacity)); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, scoped_ptr<CCTimingFunction>())); + curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, scoped_ptr<CCTimingFunction>())); + scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.PassAs<CCAnimationCurve>(), 0, 0, CCActiveAnimation::Opacity)); - return layer->addAnimation(animation.release()); + return layer->addAnimation(animation.Pass()); } TEST(LayerChromiumLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) diff --git a/cc/TreeSynchronizerTest.cpp b/cc/TreeSynchronizerTest.cpp index e1c811b8..abc38e6 100644 --- a/cc/TreeSynchronizerTest.cpp +++ b/cc/TreeSynchronizerTest.cpp @@ -77,9 +77,9 @@ private: class FakeLayerAnimationController : public CCLayerAnimationController { public: - static PassOwnPtr<FakeLayerAnimationController> create(CCLayerAnimationControllerClient* client) + static scoped_ptr<FakeLayerAnimationController> create(CCLayerAnimationControllerClient* client) { - return adoptPtr(new FakeLayerAnimationController(client)); + return make_scoped_ptr(new FakeLayerAnimationController(client)); } bool synchronizedAnimations() const { return m_synchronizedAnimations; } @@ -392,7 +392,7 @@ TEST(TreeSynchronizerTest, synchronizeAnimations) scoped_refptr<LayerChromium> layerTreeRoot = LayerChromium::create(); FakeLayerAnimationControllerClient dummy; - layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create(&dummy)); + layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create(&dummy).PassAs<CCLayerAnimationController>()); EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); diff --git a/cc/test/CCAnimationTestCommon.cpp b/cc/test/CCAnimationTestCommon.cpp index 6b7801c..884b9fe 100644 --- a/cc/test/CCAnimationTestCommon.cpp +++ b/cc/test/CCAnimationTestCommon.cpp @@ -19,38 +19,38 @@ namespace { template <class Target> void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity, bool useTimingFunction) { - OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); + scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); if (duration > 0) - curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFunction ? nullptr : CCEaseTimingFunction::create())); - curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFunction ? scoped_ptr<CCTimingFunction>(): CCEaseTimingFunction::create())); + curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, scoped_ptr<cc::CCTimingFunction>())); - OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), 0, 0, CCActiveAnimation::Opacity)); + scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.PassAs<CCAnimationCurve>(), 0, 0, CCActiveAnimation::Opacity)); animation->setNeedsSynchronizedStartTime(true); - target.addAnimation(animation.release()); + target.addAnimation(animation.Pass()); } template <class Target> void addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY) { static int id = 0; - OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); + scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); if (duration > 0) { WebKit::WebTransformOperations startOperations; startOperations.appendTranslate(deltaX, deltaY, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, startOperations, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(0, startOperations, scoped_ptr<cc::CCTimingFunction>())); } WebKit::WebTransformOperations operations; operations.appendTranslate(deltaX, deltaY, 0); - curve->addKeyframe(CCTransformKeyframe::create(duration, operations, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(duration, operations, scoped_ptr<cc::CCTimingFunction>())); - OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), id++, 0, CCActiveAnimation::Transform)); + scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.PassAs<CCAnimationCurve>(), id++, 0, CCActiveAnimation::Transform)); animation->setNeedsSynchronizedStartTime(true); - target.addAnimation(animation.release()); + target.addAnimation(animation.Pass()); } } // namespace @@ -81,9 +81,9 @@ float FakeFloatAnimationCurve::getValue(double now) const return 0; } -PassOwnPtr<cc::CCAnimationCurve> FakeFloatAnimationCurve::clone() const +scoped_ptr<cc::CCAnimationCurve> FakeFloatAnimationCurve::clone() const { - return adoptPtr(new FakeFloatAnimationCurve); + return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs<cc::CCAnimationCurve>(); } FakeTransformTransition::FakeTransformTransition(double duration) @@ -105,9 +105,9 @@ WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) c return WebKit::WebTransformationMatrix(); } -PassOwnPtr<cc::CCAnimationCurve> FakeTransformTransition::clone() const +scoped_ptr<cc::CCAnimationCurve> FakeTransformTransition::clone() const { - return adoptPtr(new FakeTransformTransition(*this)); + return make_scoped_ptr(new FakeTransformTransition(*this)).PassAs<cc::CCAnimationCurve>(); } @@ -169,9 +169,9 @@ const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::trans return m_transform; } -PassOwnPtr<cc::CCAnimationCurve> FakeFloatTransition::clone() const +scoped_ptr<cc::CCAnimationCurve> FakeFloatTransition::clone() const { - return adoptPtr(new FakeFloatTransition(*this)); + return make_scoped_ptr(new FakeFloatTransition(*this)).PassAs<cc::CCAnimationCurve>(); } void addOpacityTransitionToController(cc::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity, bool useTimingFunction) diff --git a/cc/test/CCAnimationTestCommon.h b/cc/test/CCAnimationTestCommon.h index 6ebf199..a768930 100644 --- a/cc/test/CCAnimationTestCommon.h +++ b/cc/test/CCAnimationTestCommon.h @@ -10,8 +10,6 @@ #include "CCLayerAnimationController.h" #include "IntSize.h" -#include <wtf/OwnPtr.h> - namespace cc { class CCLayerImpl; class LayerChromium; @@ -27,7 +25,7 @@ public: virtual double duration() const OVERRIDE; virtual float getValue(double now) const OVERRIDE; - virtual PassOwnPtr<cc::CCAnimationCurve> clone() const OVERRIDE; + virtual scoped_ptr<cc::CCAnimationCurve> clone() const OVERRIDE; private: double m_duration; @@ -41,7 +39,7 @@ public: virtual double duration() const OVERRIDE; virtual WebKit::WebTransformationMatrix getValue(double time) const OVERRIDE; - virtual PassOwnPtr<cc::CCAnimationCurve> clone() const OVERRIDE; + virtual scoped_ptr<cc::CCAnimationCurve> clone() const OVERRIDE; private: double m_duration; @@ -55,7 +53,7 @@ public: virtual double duration() const OVERRIDE; virtual float getValue(double time) const OVERRIDE; - virtual PassOwnPtr<cc::CCAnimationCurve> clone() const OVERRIDE; + virtual scoped_ptr<cc::CCAnimationCurve> clone() const OVERRIDE; private: double m_duration; |