From 28468de002bfefc84895e854d358bef0abd88ae6 Mon Sep 17 00:00:00 2001 From: "falken@chromium.org" Date: Fri, 12 Oct 2012 06:54:41 +0000 Subject: Revert 161488 - [cc] Use base ptr types for cc's CSS animation classes (Reverting as it seemed to cause build errors on Win Builder (dbg)) Rerelanding https://codereview.chromium.org/11085029/ BUG=154451 Review URL: https://chromiumcodereview.appspot.com/11091057 TBR=enne@chromium.org Review URL: https://codereview.chromium.org/11092097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161519 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/CCActiveAnimation.cpp | 16 ++-- cc/CCActiveAnimation.h | 13 +-- cc/CCActiveAnimationTest.cpp | 40 +++++----- cc/CCAnimationCurve.h | 4 +- cc/CCKeyframedAnimationCurve.cpp | 78 +++++++++--------- cc/CCKeyframedAnimationCurve.h | 36 +++++---- cc/CCKeyframedAnimationCurveTest.cpp | 71 +++++++++-------- cc/CCLayerAnimationController.cpp | 20 ++--- cc/CCLayerAnimationController.h | 11 +-- cc/CCLayerAnimationControllerTest.cpp | 146 +++++++++++++++++----------------- cc/CCLayerImpl.h | 2 +- cc/CCLayerTreeHostTest.cpp | 6 +- cc/CCTimingFunction.cpp | 26 +++--- cc/CCTimingFunction.h | 13 +-- cc/LayerChromium.cpp | 16 ++-- cc/LayerChromium.h | 12 +-- cc/LayerChromiumTest.cpp | 10 +-- cc/TreeSynchronizerTest.cpp | 6 +- cc/test/CCAnimationTestCommon.cpp | 32 ++++---- cc/test/CCAnimationTestCommon.h | 8 +- 20 files changed, 287 insertions(+), 279 deletions(-) (limited to 'cc') diff --git a/cc/CCActiveAnimation.cpp b/cc/CCActiveAnimation.cpp index b1817d1..e99bd42 100644 --- a/cc/CCActiveAnimation.cpp +++ b/cc/CCActiveAnimation.cpp @@ -42,13 +42,13 @@ COMPILE_ASSERT(static_cast(cc::CCActiveAnimation::TargetPropertyEnumSize) = namespace cc { -scoped_ptr CCActiveAnimation::create(scoped_ptr curve, int animationId, int groupId, TargetProperty targetProperty) +PassOwnPtr CCActiveAnimation::create(PassOwnPtr curve, int animationId, int groupId, TargetProperty targetProperty) { - return make_scoped_ptr(new CCActiveAnimation(curve.Pass(), animationId, groupId, targetProperty)); + return adoptPtr(new CCActiveAnimation(curve, animationId, groupId, targetProperty)); } -CCActiveAnimation::CCActiveAnimation(scoped_ptr curve, int animationId, int groupId, TargetProperty targetProperty) - : m_curve(curve.Pass()) +CCActiveAnimation::CCActiveAnimation(PassOwnPtr curve, int animationId, int groupId, TargetProperty targetProperty) + : m_curve(curve) , m_id(animationId) , m_group(groupId) , m_targetProperty(targetProperty) @@ -180,14 +180,14 @@ double CCActiveAnimation::trimTimeToCurrentIteration(double monotonicTime) const return trimmed; } -scoped_ptr CCActiveAnimation::clone(InstanceType instanceType) const +PassOwnPtr CCActiveAnimation::clone(InstanceType instanceType) const { return cloneAndInitialize(instanceType, m_runState, m_startTime); } -scoped_ptr CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const +PassOwnPtr CCActiveAnimation::cloneAndInitialize(InstanceType instanceType, RunState initialRunState, double startTime) const { - scoped_ptr toReturn(new CCActiveAnimation(m_curve->clone(), m_id, m_group, m_targetProperty)); + OwnPtr toReturn(adoptPtr(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 @@ scoped_ptr CCActiveAnimation::cloneAndInitialize(InstanceType toReturn->m_timeOffset = m_timeOffset; toReturn->m_alternatesDirection = m_alternatesDirection; toReturn->m_isControllingInstance = instanceType == ControllingInstance; - return toReturn.Pass(); + return toReturn.release(); } void CCActiveAnimation::pushPropertiesTo(CCActiveAnimation* other) const diff --git a/cc/CCActiveAnimation.h b/cc/CCActiveAnimation.h index b8d3607..213b510 100644 --- a/cc/CCActiveAnimation.h +++ b/cc/CCActiveAnimation.h @@ -6,7 +6,8 @@ #define CCActiveAnimation_h #include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" +#include +#include namespace cc { @@ -46,7 +47,7 @@ public: TargetPropertyEnumSize }; - static scoped_ptr create(scoped_ptr, int animationId, int groupId, TargetProperty); + static PassOwnPtr create(PassOwnPtr, int animationId, int groupId, TargetProperty); virtual ~CCActiveAnimation(); @@ -99,16 +100,16 @@ public: NonControllingInstance }; - scoped_ptr clone(InstanceType) const; - scoped_ptr cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; + PassOwnPtr clone(InstanceType) const; + PassOwnPtr cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; bool isControllingInstance() const { return m_isControllingInstance; } void pushPropertiesTo(CCActiveAnimation*) const; private: - CCActiveAnimation(scoped_ptr, int animationId, int groupId, TargetProperty); + CCActiveAnimation(PassOwnPtr, int animationId, int groupId, TargetProperty); - scoped_ptr m_curve; + OwnPtr m_curve; // IDs are not necessarily unique. int m_id; diff --git a/cc/CCActiveAnimationTest.cpp b/cc/CCActiveAnimationTest.cpp index c3076c9..bac66c7 100644 --- a/cc/CCActiveAnimationTest.cpp +++ b/cc/CCActiveAnimationTest.cpp @@ -15,21 +15,21 @@ using namespace cc; namespace { -scoped_ptr createActiveAnimation(int iterations, double duration) +PassOwnPtr createActiveAnimation(int iterations, double duration) { - scoped_ptr toReturn(CCActiveAnimation::create(make_scoped_ptr(new FakeFloatAnimationCurve(duration)).PassAs(), 0, 1, CCActiveAnimation::Opacity)); + OwnPtr toReturn(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve(duration)), 0, 1, CCActiveAnimation::Opacity)); toReturn->setIterations(iterations); - return toReturn.Pass(); + return toReturn.release(); } -scoped_ptr createActiveAnimation(int iterations) +PassOwnPtr createActiveAnimation(int iterations) { return createActiveAnimation(iterations, 1); } TEST(CCActiveAnimationTest, TrimTimeZeroIterations) { - scoped_ptr anim(createActiveAnimation(0)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(-1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(-1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(0, 0)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(0)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(-1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(0)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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) { - scoped_ptr anim(createActiveAnimation(1)); + OwnPtr 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 7ed6e7a..c177d23 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 +#include namespace cc { @@ -25,7 +25,7 @@ public: virtual double duration() const = 0; virtual Type type() const = 0; - virtual scoped_ptr clone() const = 0; + virtual PassOwnPtr clone() const = 0; const CCFloatAnimationCurve* toFloatAnimationCurve() const; const CCTransformAnimationCurve* toTransformAnimationCurve() const; diff --git a/cc/CCKeyframedAnimationCurve.cpp b/cc/CCKeyframedAnimationCurve.cpp index a6b368e..5357976 100644 --- a/cc/CCKeyframedAnimationCurve.cpp +++ b/cc/CCKeyframedAnimationCurve.cpp @@ -6,6 +6,8 @@ #include "CCKeyframedAnimationCurve.h" +#include + using WebKit::WebTransformationMatrix; namespace cc { @@ -13,34 +15,36 @@ namespace cc { namespace { template -void insertKeyframe(scoped_ptr keyframe, ScopedPtrVector& keyframes) +void insertKeyframe(PassOwnPtr popKeyframe, OwnPtrVector& keyframes) { + OwnPtr 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.Pass()); + keyframes.insert(i, keyframe.release()); return; } } } - keyframes.append(keyframe.Pass()); + keyframes.append(keyframe.release()); } -scoped_ptr cloneTimingFunction(const CCTimingFunction* timingFunction) +PassOwnPtr cloneTimingFunction(const CCTimingFunction* timingFunction) { ASSERT(timingFunction); - scoped_ptr curve(timingFunction->clone()); - return scoped_ptr(static_cast(curve.release())); + OwnPtr curve(timingFunction->clone()); + return adoptPtr(static_cast(curve.leakPtr())); } } // namespace -CCKeyframe::CCKeyframe(double time, scoped_ptr timingFunction) +CCKeyframe::CCKeyframe(double time, PassOwnPtr timingFunction) : m_time(time) - , m_timingFunction(timingFunction.Pass()) + , m_timingFunction(timingFunction) { } @@ -58,13 +62,13 @@ const CCTimingFunction* CCKeyframe::timingFunction() const return m_timingFunction.get(); } -scoped_ptr CCFloatKeyframe::create(double time, float value, scoped_ptr timingFunction) +PassOwnPtr CCFloatKeyframe::create(double time, float value, PassOwnPtr timingFunction) { - return make_scoped_ptr(new CCFloatKeyframe(time, value, timingFunction.Pass())); + return adoptPtr(new CCFloatKeyframe(time, value, timingFunction)); } -CCFloatKeyframe::CCFloatKeyframe(double time, float value, scoped_ptr timingFunction) - : CCKeyframe(time, timingFunction.Pass()) +CCFloatKeyframe::CCFloatKeyframe(double time, float value, PassOwnPtr timingFunction) + : CCKeyframe(time, timingFunction) , m_value(value) { } @@ -78,21 +82,18 @@ float CCFloatKeyframe::value() const return m_value; } -scoped_ptr CCFloatKeyframe::clone() const +PassOwnPtr CCFloatKeyframe::clone() const { - scoped_ptr func; - if (timingFunction()) - func = cloneTimingFunction(timingFunction()); - return CCFloatKeyframe::create(time(), value(), func.Pass()); + return CCFloatKeyframe::create(time(), value(), timingFunction() ? cloneTimingFunction(timingFunction()) : nullptr); } -scoped_ptr CCTransformKeyframe::create(double time, const WebKit::WebTransformOperations& value, scoped_ptr timingFunction) +PassOwnPtr CCTransformKeyframe::create(double time, const WebKit::WebTransformOperations& value, PassOwnPtr timingFunction) { - return make_scoped_ptr(new CCTransformKeyframe(time, value, timingFunction.Pass())); + return adoptPtr(new CCTransformKeyframe(time, value, timingFunction)); } -CCTransformKeyframe::CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, scoped_ptr timingFunction) - : CCKeyframe(time, timingFunction.Pass()) +CCTransformKeyframe::CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, PassOwnPtr timingFunction) + : CCKeyframe(time, timingFunction) , m_value(value) { } @@ -106,17 +107,14 @@ const WebKit::WebTransformOperations& CCTransformKeyframe::value() const return m_value; } -scoped_ptr CCTransformKeyframe::clone() const +PassOwnPtr CCTransformKeyframe::clone() const { - scoped_ptr func; - if (timingFunction()) - func = cloneTimingFunction(timingFunction()); - return CCTransformKeyframe::create(time(), value(), func.Pass()); + return CCTransformKeyframe::create(time(), value(), timingFunction() ? cloneTimingFunction(timingFunction()) : nullptr); } -scoped_ptr CCKeyframedFloatAnimationCurve::create() +PassOwnPtr CCKeyframedFloatAnimationCurve::create() { - return make_scoped_ptr(new CCKeyframedFloatAnimationCurve); + return adoptPtr(new CCKeyframedFloatAnimationCurve); } CCKeyframedFloatAnimationCurve::CCKeyframedFloatAnimationCurve() @@ -127,9 +125,9 @@ CCKeyframedFloatAnimationCurve::~CCKeyframedFloatAnimationCurve() { } -void CCKeyframedFloatAnimationCurve::addKeyframe(scoped_ptr keyframe) +void CCKeyframedFloatAnimationCurve::addKeyframe(PassOwnPtr keyframe) { - insertKeyframe(keyframe.Pass(), m_keyframes); + insertKeyframe(keyframe, m_keyframes); } double CCKeyframedFloatAnimationCurve::duration() const @@ -137,12 +135,12 @@ double CCKeyframedFloatAnimationCurve::duration() const return m_keyframes.last()->time() - m_keyframes.first()->time(); } -scoped_ptr CCKeyframedFloatAnimationCurve::clone() const +PassOwnPtr CCKeyframedFloatAnimationCurve::clone() const { - scoped_ptr toReturn(CCKeyframedFloatAnimationCurve::create()); + OwnPtr toReturn(CCKeyframedFloatAnimationCurve::create()); for (size_t i = 0; i < m_keyframes.size(); ++i) toReturn->addKeyframe(m_keyframes[i]->clone()); - return toReturn.PassAs(); + return toReturn.release(); } float CCKeyframedFloatAnimationCurve::getValue(double t) const @@ -167,9 +165,9 @@ float CCKeyframedFloatAnimationCurve::getValue(double t) const return m_keyframes[i]->value() + (m_keyframes[i+1]->value() - m_keyframes[i]->value()) * progress; } -scoped_ptr CCKeyframedTransformAnimationCurve::create() +PassOwnPtr CCKeyframedTransformAnimationCurve::create() { - return make_scoped_ptr(new CCKeyframedTransformAnimationCurve); + return adoptPtr(new CCKeyframedTransformAnimationCurve); } CCKeyframedTransformAnimationCurve::CCKeyframedTransformAnimationCurve() @@ -180,9 +178,9 @@ CCKeyframedTransformAnimationCurve::~CCKeyframedTransformAnimationCurve() { } -void CCKeyframedTransformAnimationCurve::addKeyframe(scoped_ptr keyframe) +void CCKeyframedTransformAnimationCurve::addKeyframe(PassOwnPtr keyframe) { - insertKeyframe(keyframe.Pass(), m_keyframes); + insertKeyframe(keyframe, m_keyframes); } double CCKeyframedTransformAnimationCurve::duration() const @@ -190,12 +188,12 @@ double CCKeyframedTransformAnimationCurve::duration() const return m_keyframes.last()->time() - m_keyframes.first()->time(); } -scoped_ptr CCKeyframedTransformAnimationCurve::clone() const +PassOwnPtr CCKeyframedTransformAnimationCurve::clone() const { - scoped_ptr toReturn(CCKeyframedTransformAnimationCurve::create()); + OwnPtr toReturn(CCKeyframedTransformAnimationCurve::create()); for (size_t i = 0; i < m_keyframes.size(); ++i) toReturn->addKeyframe(m_keyframes[i]->clone()); - return toReturn.PassAs(); + return toReturn.release(); } WebTransformationMatrix CCKeyframedTransformAnimationCurve::getValue(double t) const diff --git a/cc/CCKeyframedAnimationCurve.h b/cc/CCKeyframedAnimationCurve.h index 066e5c6..33cee77 100644 --- a/cc/CCKeyframedAnimationCurve.h +++ b/cc/CCKeyframedAnimationCurve.h @@ -7,8 +7,10 @@ #include "CCAnimationCurve.h" #include "CCTimingFunction.h" -#include "scoped_ptr_vector.h" +#include "cc/own_ptr_vector.h" #include +#include +#include namespace cc { @@ -18,40 +20,40 @@ public: const CCTimingFunction* timingFunction() const; protected: - CCKeyframe(double time, scoped_ptr); + CCKeyframe(double time, PassOwnPtr); virtual ~CCKeyframe(); private: double m_time; - scoped_ptr m_timingFunction; + OwnPtr m_timingFunction; }; class CCFloatKeyframe : public CCKeyframe { public: - static scoped_ptr create(double time, float value, scoped_ptr); + static PassOwnPtr create(double time, float value, PassOwnPtr); virtual ~CCFloatKeyframe(); float value() const; - scoped_ptr clone() const; + PassOwnPtr clone() const; private: - CCFloatKeyframe(double time, float value, scoped_ptr); + CCFloatKeyframe(double time, float value, PassOwnPtr); float m_value; }; class CCTransformKeyframe : public CCKeyframe { public: - static scoped_ptr create(double time, const WebKit::WebTransformOperations& value, scoped_ptr); + static PassOwnPtr create(double time, const WebKit::WebTransformOperations& value, PassOwnPtr); virtual ~CCTransformKeyframe(); const WebKit::WebTransformOperations& value() const; - scoped_ptr clone() const; + PassOwnPtr clone() const; private: - CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, scoped_ptr); + CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, PassOwnPtr); WebKit::WebTransformOperations m_value; }; @@ -59,15 +61,15 @@ private: class CCKeyframedFloatAnimationCurve : public CCFloatAnimationCurve { public: // It is required that the keyframes be sorted by time. - static scoped_ptr create(); + static PassOwnPtr create(); virtual ~CCKeyframedFloatAnimationCurve(); - void addKeyframe(scoped_ptr); + void addKeyframe(PassOwnPtr); // CCAnimationCurve implementation virtual double duration() const OVERRIDE; - virtual scoped_ptr clone() const OVERRIDE; + virtual PassOwnPtr clone() const OVERRIDE; // CCFloatAnimationCurve implementation virtual float getValue(double t) const OVERRIDE; @@ -77,21 +79,21 @@ private: // Always sorted in order of increasing time. No two keyframes have the // same time. - ScopedPtrVector m_keyframes; + OwnPtrVector m_keyframes; }; class CCKeyframedTransformAnimationCurve : public CCTransformAnimationCurve { public: // It is required that the keyframes be sorted by time. - static scoped_ptr create(); + static PassOwnPtr create(); virtual ~CCKeyframedTransformAnimationCurve(); - void addKeyframe(scoped_ptr); + void addKeyframe(PassOwnPtr); // CCAnimationCurve implementation virtual double duration() const OVERRIDE; - virtual scoped_ptr clone() const OVERRIDE; + virtual PassOwnPtr clone() const OVERRIDE; // CCTransformAnimationCurve implementation virtual WebKit::WebTransformationMatrix getValue(double t) const OVERRIDE; @@ -101,7 +103,7 @@ private: // Always sorted in order of increasing time. No two keyframes have the // same time. - ScopedPtrVector m_keyframes; + OwnPtrVector m_keyframes; }; } // namespace cc diff --git a/cc/CCKeyframedAnimationCurveTest.cpp b/cc/CCKeyframedAnimationCurveTest.cpp index 9dca26a..21353ed 100644 --- a/cc/CCKeyframedAnimationCurveTest.cpp +++ b/cc/CCKeyframedAnimationCurveTest.cpp @@ -10,6 +10,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include #include +#include using namespace cc; using WebKit::WebTransformationMatrix; @@ -24,8 +25,8 @@ void expectTranslateX(double translateX, const WebTransformationMatrix& matrix) // Tests that a float animation with one keyframe works as expected. TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr())); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); @@ -36,9 +37,9 @@ TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) // Tests that a float animation with two keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr())); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -49,10 +50,10 @@ TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) // Tests that a float animation with three keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr())); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -65,11 +66,11 @@ TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) // Tests that a float animation with multiple keys at a given time works sanely. TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 4, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(1, 6, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(2, 6, scoped_ptr())); + OwnPtr 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)); EXPECT_FLOAT_EQ(4, curve->getValue(-1)); EXPECT_FLOAT_EQ(4, curve->getValue(0)); @@ -88,10 +89,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) // Tests that a transform animation with one keyframe works as expected. TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) { - scoped_ptr curve(CCKeyframedTransformAnimationCurve::create()); + OwnPtr curve(CCKeyframedTransformAnimationCurve::create()); WebKit::WebTransformOperations operations; operations.appendTranslate(2, 0, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, operations, scoped_ptr())); + curve->addKeyframe(CCTransformKeyframe::create(0, operations, nullptr)); expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(0)); @@ -103,14 +104,14 @@ TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) // Tests that a transform animation with two keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) { - scoped_ptr curve(CCKeyframedTransformAnimationCurve::create()); + OwnPtr 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, scoped_ptr())); - curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr())); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(0)); expectTranslateX(3, curve->getValue(0.5)); @@ -121,16 +122,16 @@ TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) // Tests that a transform animation with three keyframes works as expected. TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) { - scoped_ptr curve(CCKeyframedTransformAnimationCurve::create()); + OwnPtr 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, scoped_ptr())); - curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr())); - curve->addKeyframe(CCTransformKeyframe::create(2, operations3, scoped_ptr())); + curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); + curve->addKeyframe(CCTransformKeyframe::create(2, operations3, nullptr)); expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(0)); expectTranslateX(3, curve->getValue(0.5)); @@ -143,7 +144,7 @@ TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) // Tests that a transform animation with multiple keys at a given time works sanely. TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) { - scoped_ptr curve(CCKeyframedTransformAnimationCurve::create()); + OwnPtr curve(CCKeyframedTransformAnimationCurve::create()); // A step function. WebKit::WebTransformOperations operations1; operations1.appendTranslate(4, 0, 0); @@ -153,10 +154,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) operations3.appendTranslate(6, 0, 0); WebKit::WebTransformOperations operations4; operations4.appendTranslate(6, 0, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr())); - curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr())); - curve->addKeyframe(CCTransformKeyframe::create(1, operations3, scoped_ptr())); - curve->addKeyframe(CCTransformKeyframe::create(2, operations4, scoped_ptr())); + 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)); expectTranslateX(4, curve->getValue(-1)); expectTranslateX(4, curve->getValue(0)); @@ -174,10 +175,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) // Tests that the keyframes may be added out of order. TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr())); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); @@ -190,9 +191,9 @@ TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) // Tests that a cubic bezier timing function works as expected. TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1).PassAs())); - curve->addKeyframe(CCFloatKeyframe::create(1, 1, scoped_ptr())); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1))); + curve->addKeyframe(CCFloatKeyframe::create(1, 1, nullptr)); 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 2025db8..83e5223 100644 --- a/cc/CCLayerAnimationController.cpp +++ b/cc/CCLayerAnimationController.cpp @@ -26,9 +26,9 @@ CCLayerAnimationController::~CCLayerAnimationController() { } -scoped_ptr CCLayerAnimationController::create(CCLayerAnimationControllerClient* client) +PassOwnPtr CCLayerAnimationController::create(CCLayerAnimationControllerClient* client) { - return make_scoped_ptr(new CCLayerAnimationController(client)); + return adoptPtr(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(scoped_ptr animation) +void CCLayerAnimationController::addAnimation(PassOwnPtr animation) { - m_activeAnimations.append(animation.Pass()); + m_activeAnimations.append(animation); } 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; - scoped_ptr toAdd(m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime)); + OwnPtr toAdd(m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime)); ASSERT(!toAdd->needsSynchronizedStartTime()); - controllerImpl->addAnimation(toAdd.Pass()); + controllerImpl->addAnimation(toAdd.release()); } } @@ -348,17 +348,17 @@ void CCLayerAnimationController::replaceImplThreadAnimations(CCLayerAnimationCon { controllerImpl->m_activeAnimations.clear(); for (size_t i = 0; i < m_activeAnimations.size(); ++i) { - scoped_ptr toAdd; + OwnPtr 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).Pass(); + toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime); } else - toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance).Pass(); + toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance); - controllerImpl->addAnimation(toAdd.Pass()); + controllerImpl->addAnimation(toAdd.release()); } } diff --git a/cc/CCLayerAnimationController.h b/cc/CCLayerAnimationController.h index 2fdb91c..f295d90 100644 --- a/cc/CCLayerAnimationController.h +++ b/cc/CCLayerAnimationController.h @@ -9,8 +9,9 @@ #include "base/basictypes.h" #include "base/hash_tables.h" -#include "base/memory/scoped_ptr.h" -#include "cc/scoped_ptr_vector.h" +#include "cc/own_ptr_vector.h" +#include +#include namespace WebKit { class WebTransformationMatrix; @@ -35,12 +36,12 @@ public: class CCLayerAnimationController { public: - static scoped_ptr create(CCLayerAnimationControllerClient*); + static PassOwnPtr create(CCLayerAnimationControllerClient*); virtual ~CCLayerAnimationController(); // These methods are virtual for testing. - virtual void addAnimation(scoped_ptr); + virtual void addAnimation(PassOwnPtr); virtual void pauseAnimation(int animationId, double timeOffset); virtual void removeAnimation(int animationId); virtual void removeAnimation(int animationId, CCActiveAnimation::TargetProperty); @@ -102,7 +103,7 @@ private: bool m_forceSync; CCLayerAnimationControllerClient* m_client; - ScopedPtrVector m_activeAnimations; + OwnPtrVector m_activeAnimations; DISALLOW_COPY_AND_ASSIGN(CCLayerAnimationController); }; diff --git a/cc/CCLayerAnimationControllerTest.cpp b/cc/CCLayerAnimationControllerTest.cpp index 4d9e575..b6004a0 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()); } -scoped_ptr createActiveAnimation(scoped_ptr curve, int id, CCActiveAnimation::TargetProperty property) +PassOwnPtr createActiveAnimation(PassOwnPtr curve, int id, CCActiveAnimation::TargetProperty property) { - return CCActiveAnimation::create(curve.Pass(), 0, id, property); + return CCActiveAnimation::create(curve, 0, id, property); } TEST(CCLayerAnimationControllerTest, syncNewAnimation) { FakeLayerAnimationControllerClient dummyImpl; - scoped_ptr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + OwnPtr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller(CCLayerAnimationController::create(&dummy)); + OwnPtr controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -51,9 +51,9 @@ TEST(CCLayerAnimationControllerTest, syncNewAnimation) TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes) { FakeLayerAnimationControllerClient dummyImpl; - scoped_ptr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + OwnPtr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller(CCLayerAnimationController::create(&dummy)); + OwnPtr controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -80,9 +80,9 @@ TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes) TEST(CCLayerAnimationControllerTest, syncPauseAndResume) { FakeLayerAnimationControllerClient dummyImpl; - scoped_ptr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + OwnPtr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller(CCLayerAnimationController::create(&dummy)); + OwnPtr controller(CCLayerAnimationController::create(&dummy)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); @@ -120,9 +120,9 @@ TEST(CCLayerAnimationControllerTest, syncPauseAndResume) TEST(CCLayerAnimationControllerTest, doNotSyncFinishedAnimation) { FakeLayerAnimationControllerClient dummyImpl; - scoped_ptr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + OwnPtr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller(CCLayerAnimationController::create(&dummy)); + OwnPtr 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); toAdd->setNeedsSynchronizedStartTime(true); // We should pause at the first keyframe indefinitely waiting for that animation to start. - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs(), 2, CCActiveAnimation::Opacity)); + 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->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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs(), 2, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5)), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForNextTick, 0); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); // 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs(), 1, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs(), 2, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 2, CCActiveAnimation::Opacity)); + 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->animate(0, events.get()); EXPECT_EQ(0, dummy.opacity()); @@ -275,14 +275,14 @@ TEST(CCLayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) // for both to finish). TEST(CCLayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(2)).PassAs(), 1, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs(), 2, CCActiveAnimation::Opacity)); + 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)); // 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0.5, 0)).PassAs(), 2, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0.5, 0)), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); // 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0.5, 0)).PassAs(), 2, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0.5, 0)), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 0.75)).PassAs(), 3, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 0.75)), 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), 1, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); toAdd->setIterations(3); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); const int id = 1; - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), id, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); toAdd->setIterations(-1); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); 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) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); const int id = 1; - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs(), id, CCActiveAnimation::Opacity)); + controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); controller->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -503,15 +503,15 @@ TEST(CCLayerAnimationControllerTest, PauseResume) TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation) { - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); const int id = 1; - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs(), id, CCActiveAnimation::Transform)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs(), id, CCActiveAnimation::Opacity)); - controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.75)).PassAs(), 2, CCActiveAnimation::Opacity)); + 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->animate(0, events.get()); EXPECT_TRUE(controller->hasActiveAnimation()); @@ -533,15 +533,15 @@ TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation) TEST(CCLayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) { FakeLayerAnimationControllerClient dummyImpl; - scoped_ptr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); - scoped_ptr events(make_scoped_ptr(new CCAnimationEventsVector)); + OwnPtr controllerImpl(CCLayerAnimationController::create(&dummyImpl)); + OwnPtr events(adoptPtr(new CCAnimationEventsVector)); FakeLayerAnimationControllerClient dummy; - scoped_ptr controller( + OwnPtr controller( CCLayerAnimationController::create(&dummy)); - scoped_ptr toAdd(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs(), 0, CCActiveAnimation::Opacity)); + OwnPtr toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 0, CCActiveAnimation::Opacity)); toAdd->setNeedsSynchronizedStartTime(true); - controller->addAnimation(toAdd.Pass()); + controller->addAnimation(toAdd.release()); controller->animate(0, 0); EXPECT_TRUE(controller->hasActiveAnimation()); diff --git a/cc/CCLayerImpl.h b/cc/CCLayerImpl.h index 441ef6e..665b000 100644 --- a/cc/CCLayerImpl.h +++ b/cc/CCLayerImpl.h @@ -387,7 +387,7 @@ private: FloatRect m_updateRect; // Manages animations for this layer. - scoped_ptr m_layerAnimationController; + OwnPtr m_layerAnimationController; // Manages scrollbars for this layer OwnPtr m_scrollbarAnimationController; diff --git a/cc/CCLayerTreeHostTest.cpp b/cc/CCLayerTreeHostTest.cpp index fbb46f4..129fa61 100644 --- a/cc/CCLayerTreeHostTest.cpp +++ b/cc/CCLayerTreeHostTest.cpp @@ -2188,9 +2188,9 @@ public: layer->setLayerAnimationDelegate(this); // Any valid CCAnimationCurve will do here. - scoped_ptr curve(CCEaseTimingFunction::create()); - scoped_ptr animation(CCActiveAnimation::create(curve.Pass(), 1, 1, CCActiveAnimation::Opacity)); - layer->layerAnimationController()->addAnimation(animation.Pass()); + OwnPtr curve(CCEaseTimingFunction::create()); + OwnPtr animation(CCActiveAnimation::create(curve.release(), 1, 1, CCActiveAnimation::Opacity)); + layer->layerAnimationController()->addAnimation(animation.release()); // 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 3a4ecd4..224a0ba 100644 --- a/cc/CCTimingFunction.cpp +++ b/cc/CCTimingFunction.cpp @@ -6,6 +6,8 @@ #include "CCTimingFunction.h" +#include + namespace { const double epsilon = 1e-6; } // namespace @@ -25,9 +27,9 @@ double CCTimingFunction::duration() const return 1.0; } -scoped_ptr CCCubicBezierTimingFunction::create(double x1, double y1, double x2, double y2) +PassOwnPtr CCCubicBezierTimingFunction::create(double x1, double y1, double x2, double y2) { - return make_scoped_ptr(new CCCubicBezierTimingFunction(x1, y1, x2, y2)); + return adoptPtr(new CCCubicBezierTimingFunction(x1, y1, x2, y2)); } CCCubicBezierTimingFunction::CCCubicBezierTimingFunction(double x1, double y1, double x2, double y2) @@ -45,30 +47,30 @@ float CCCubicBezierTimingFunction::getValue(double x) const return static_cast(temp.solve(x, epsilon)); } -scoped_ptr CCCubicBezierTimingFunction::clone() const +PassOwnPtr CCCubicBezierTimingFunction::clone() const { - return make_scoped_ptr(new CCCubicBezierTimingFunction(*this)).PassAs(); + return adoptPtr(new CCCubicBezierTimingFunction(*this)); } // These numbers come from http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag. -scoped_ptr CCEaseTimingFunction::create() +PassOwnPtr CCEaseTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0.25, 0.1, 0.25, 1).PassAs(); + return CCCubicBezierTimingFunction::create(0.25, 0.1, 0.25, 1); } -scoped_ptr CCEaseInTimingFunction::create() +PassOwnPtr CCEaseInTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0.42, 0, 1.0, 1).PassAs(); + return CCCubicBezierTimingFunction::create(0.42, 0, 1.0, 1); } -scoped_ptr CCEaseOutTimingFunction::create() +PassOwnPtr CCEaseOutTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0, 0, 0.58, 1).PassAs(); + return CCCubicBezierTimingFunction::create(0, 0, 0.58, 1); } -scoped_ptr CCEaseInOutTimingFunction::create() +PassOwnPtr CCEaseInOutTimingFunction::create() { - return CCCubicBezierTimingFunction::create(0.42, 0, 0.58, 1).PassAs(); + return CCCubicBezierTimingFunction::create(0.42, 0, 0.58, 1); } } // namespace cc diff --git a/cc/CCTimingFunction.h b/cc/CCTimingFunction.h index 993ab87..990403a 100644 --- a/cc/CCTimingFunction.h +++ b/cc/CCTimingFunction.h @@ -7,6 +7,7 @@ #include "CCAnimationCurve.h" #include "UnitBezier.h" +#include namespace cc { @@ -24,12 +25,12 @@ protected: class CCCubicBezierTimingFunction : public CCTimingFunction { public: - static scoped_ptr create(double x1, double y1, double x2, double y2); + static PassOwnPtr create(double x1, double y1, double x2, double y2); virtual ~CCCubicBezierTimingFunction(); // Partial implementation of CCFloatAnimationCurve. virtual float getValue(double time) const OVERRIDE; - virtual scoped_ptr clone() const OVERRIDE; + virtual PassOwnPtr clone() const OVERRIDE; protected: CCCubicBezierTimingFunction(double x1, double y1, double x2, double y2); @@ -39,22 +40,22 @@ protected: class CCEaseTimingFunction { public: - static scoped_ptr create(); + static PassOwnPtr create(); }; class CCEaseInTimingFunction { public: - static scoped_ptr create(); + static PassOwnPtr create(); }; class CCEaseOutTimingFunction { public: - static scoped_ptr create(); + static PassOwnPtr create(); }; class CCEaseInOutTimingFunction { public: - static scoped_ptr create(); + static PassOwnPtr create(); }; } // namespace cc diff --git a/cc/LayerChromium.cpp b/cc/LayerChromium.cpp index 55093d6..43145b6 100644 --- a/cc/LayerChromium.cpp +++ b/cc/LayerChromium.cpp @@ -657,7 +657,7 @@ void LayerChromium::setBoundsContainPageScale(bool boundsContainPageScale) void LayerChromium::createRenderSurface() { ASSERT(!m_renderSurface); - m_renderSurface = make_scoped_ptr(new RenderSurfaceChromium(this)); + m_renderSurface = adoptPtr(new RenderSurfaceChromium(this)); setRenderTarget(this); } @@ -701,7 +701,7 @@ void LayerChromium::setTransformFromAnimation(const WebTransformationMatrix& tra m_transform = transform; } -bool LayerChromium::addAnimation(scoped_ptr animation) +bool LayerChromium::addAnimation(PassOwnPtr animation) { // WebCore currently assumes that accelerated animations will start soon // after the animation is added. However we cannot guarantee that if we do @@ -712,7 +712,7 @@ bool LayerChromium::addAnimation(scoped_ptr animation) if (!CCSettings::acceleratedAnimationEnabled()) return false; - m_layerAnimationController->addAnimation(animation.Pass()); + m_layerAnimationController->addAnimation(animation); if (m_layerTreeHost) { m_layerTreeHost->didAddAnimation(); setNeedsCommit(); @@ -744,9 +744,9 @@ void LayerChromium::resumeAnimations(double monotonicTime) setNeedsCommit(); } -void LayerChromium::setLayerAnimationController(scoped_ptr layerAnimationController) +void LayerChromium::setLayerAnimationController(PassOwnPtr layerAnimationController) { - m_layerAnimationController = layerAnimationController.Pass(); + m_layerAnimationController = layerAnimationController; if (m_layerAnimationController) { m_layerAnimationController->setClient(this); m_layerAnimationController->setForceSync(); @@ -754,11 +754,11 @@ void LayerChromium::setLayerAnimationController(scoped_ptr LayerChromium::releaseLayerAnimationController() +PassOwnPtr LayerChromium::releaseLayerAnimationController() { - scoped_ptr toReturn = m_layerAnimationController.Pass(); + OwnPtr toReturn = m_layerAnimationController.release(); m_layerAnimationController = CCLayerAnimationController::create(this); - return toReturn.Pass(); + return toReturn.release(); } bool LayerChromium::hasActiveAnimation() const diff --git a/cc/LayerChromium.h b/cc/LayerChromium.h index dedc707..aecb520 100644 --- a/cc/LayerChromium.h +++ b/cc/LayerChromium.h @@ -197,7 +197,7 @@ public: virtual void pushPropertiesTo(CCLayerImpl*); - void clearRenderSurface() { m_renderSurface.reset(); } + void clearRenderSurface() { m_renderSurface.clear(); } RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); } void createRenderSurface(); @@ -249,7 +249,7 @@ public: // Set the priority of all desired textures in this layer. virtual void setTexturePriorities(const CCPriorityCalculator&) { } - bool addAnimation(scoped_ptr); + bool addAnimation(PassOwnPtr); void pauseAnimation(int animationId, double timeOffset); void removeAnimation(int animationId); @@ -257,8 +257,8 @@ public: void resumeAnimations(double monotonicTime); CCLayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); } - void setLayerAnimationController(scoped_ptr); - scoped_ptr releaseLayerAnimationController(); + void setLayerAnimationController(PassOwnPtr); + PassOwnPtr releaseLayerAnimationController(); void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationDelegate) { m_layerAnimationDelegate = layerAnimationDelegate; } @@ -323,7 +323,7 @@ private: // updated via setLayerTreeHost() if a layer moves between trees. CCLayerTreeHost* m_layerTreeHost; - scoped_ptr m_layerAnimationController; + OwnPtr m_layerAnimationController; // Layer properties. IntSize m_bounds; @@ -367,7 +367,7 @@ private: scoped_refptr m_replicaLayer; // Transient properties. - scoped_ptr m_renderSurface; + OwnPtr m_renderSurface; float m_drawOpacity; bool m_drawOpacityIsAnimating; diff --git a/cc/LayerChromiumTest.cpp b/cc/LayerChromiumTest.cpp index b1ca80e..867e4db 100644 --- a/cc/LayerChromiumTest.cpp +++ b/cc/LayerChromiumTest.cpp @@ -791,12 +791,12 @@ TEST(LayerChromiumLayerTreeHostTest, destroyHostWithNonNullRootLayer) static bool addTestAnimation(LayerChromium* layer) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); - curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, scoped_ptr())); - curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, scoped_ptr())); - scoped_ptr animation(CCActiveAnimation::create(curve.PassAs(), 0, 0, CCActiveAnimation::Opacity)); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); + curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, nullptr)); + curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, nullptr)); + OwnPtr animation(CCActiveAnimation::create(curve.release(), 0, 0, CCActiveAnimation::Opacity)); - return layer->addAnimation(animation.Pass()); + return layer->addAnimation(animation.release()); } TEST(LayerChromiumLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) diff --git a/cc/TreeSynchronizerTest.cpp b/cc/TreeSynchronizerTest.cpp index abc38e6..e1c811b8 100644 --- a/cc/TreeSynchronizerTest.cpp +++ b/cc/TreeSynchronizerTest.cpp @@ -77,9 +77,9 @@ private: class FakeLayerAnimationController : public CCLayerAnimationController { public: - static scoped_ptr create(CCLayerAnimationControllerClient* client) + static PassOwnPtr create(CCLayerAnimationControllerClient* client) { - return make_scoped_ptr(new FakeLayerAnimationController(client)); + return adoptPtr(new FakeLayerAnimationController(client)); } bool synchronizedAnimations() const { return m_synchronizedAnimations; } @@ -392,7 +392,7 @@ TEST(TreeSynchronizerTest, synchronizeAnimations) scoped_refptr layerTreeRoot = LayerChromium::create(); FakeLayerAnimationControllerClient dummy; - layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create(&dummy).PassAs()); + layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create(&dummy)); EXPECT_FALSE(static_cast(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); diff --git a/cc/test/CCAnimationTestCommon.cpp b/cc/test/CCAnimationTestCommon.cpp index 884b9fe..6b7801c 100644 --- a/cc/test/CCAnimationTestCommon.cpp +++ b/cc/test/CCAnimationTestCommon.cpp @@ -19,38 +19,38 @@ namespace { template void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity, bool useTimingFunction) { - scoped_ptr curve(CCKeyframedFloatAnimationCurve::create()); + OwnPtr curve(CCKeyframedFloatAnimationCurve::create()); if (duration > 0) - curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFunction ? scoped_ptr(): CCEaseTimingFunction::create())); - curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, scoped_ptr())); + curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFunction ? nullptr : CCEaseTimingFunction::create())); + curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, nullptr)); - scoped_ptr animation(CCActiveAnimation::create(curve.PassAs(), 0, 0, CCActiveAnimation::Opacity)); + OwnPtr animation(CCActiveAnimation::create(curve.release(), 0, 0, CCActiveAnimation::Opacity)); animation->setNeedsSynchronizedStartTime(true); - target.addAnimation(animation.Pass()); + target.addAnimation(animation.release()); } template void addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY) { static int id = 0; - scoped_ptr curve(CCKeyframedTransformAnimationCurve::create()); + OwnPtr curve(CCKeyframedTransformAnimationCurve::create()); if (duration > 0) { WebKit::WebTransformOperations startOperations; startOperations.appendTranslate(deltaX, deltaY, 0); - curve->addKeyframe(CCTransformKeyframe::create(0, startOperations, scoped_ptr())); + curve->addKeyframe(CCTransformKeyframe::create(0, startOperations, nullptr)); } WebKit::WebTransformOperations operations; operations.appendTranslate(deltaX, deltaY, 0); - curve->addKeyframe(CCTransformKeyframe::create(duration, operations, scoped_ptr())); + curve->addKeyframe(CCTransformKeyframe::create(duration, operations, nullptr)); - scoped_ptr animation(CCActiveAnimation::create(curve.PassAs(), id++, 0, CCActiveAnimation::Transform)); + OwnPtr animation(CCActiveAnimation::create(curve.release(), id++, 0, CCActiveAnimation::Transform)); animation->setNeedsSynchronizedStartTime(true); - target.addAnimation(animation.Pass()); + target.addAnimation(animation.release()); } } // namespace @@ -81,9 +81,9 @@ float FakeFloatAnimationCurve::getValue(double now) const return 0; } -scoped_ptr FakeFloatAnimationCurve::clone() const +PassOwnPtr FakeFloatAnimationCurve::clone() const { - return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs(); + return adoptPtr(new FakeFloatAnimationCurve); } FakeTransformTransition::FakeTransformTransition(double duration) @@ -105,9 +105,9 @@ WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) c return WebKit::WebTransformationMatrix(); } -scoped_ptr FakeTransformTransition::clone() const +PassOwnPtr FakeTransformTransition::clone() const { - return make_scoped_ptr(new FakeTransformTransition(*this)).PassAs(); + return adoptPtr(new FakeTransformTransition(*this)); } @@ -169,9 +169,9 @@ const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::trans return m_transform; } -scoped_ptr FakeFloatTransition::clone() const +PassOwnPtr FakeFloatTransition::clone() const { - return make_scoped_ptr(new FakeFloatTransition(*this)).PassAs(); + return adoptPtr(new FakeFloatTransition(*this)); } 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 a768930..6ebf199 100644 --- a/cc/test/CCAnimationTestCommon.h +++ b/cc/test/CCAnimationTestCommon.h @@ -10,6 +10,8 @@ #include "CCLayerAnimationController.h" #include "IntSize.h" +#include + namespace cc { class CCLayerImpl; class LayerChromium; @@ -25,7 +27,7 @@ public: virtual double duration() const OVERRIDE; virtual float getValue(double now) const OVERRIDE; - virtual scoped_ptr clone() const OVERRIDE; + virtual PassOwnPtr clone() const OVERRIDE; private: double m_duration; @@ -39,7 +41,7 @@ public: virtual double duration() const OVERRIDE; virtual WebKit::WebTransformationMatrix getValue(double time) const OVERRIDE; - virtual scoped_ptr clone() const OVERRIDE; + virtual PassOwnPtr clone() const OVERRIDE; private: double m_duration; @@ -53,7 +55,7 @@ public: virtual double duration() const OVERRIDE; virtual float getValue(double time) const OVERRIDE; - virtual scoped_ptr clone() const OVERRIDE; + virtual PassOwnPtr clone() const OVERRIDE; private: double m_duration; -- cgit v1.1