0

[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
This commit is contained in:
enne@chromium.org
2012-10-08 05:54:11 +00:00
parent 362591a2da
commit a9c7b2e76a
30 changed files with 311 additions and 331 deletions

@@ -42,13 +42,13 @@ COMPILE_ASSERT(static_cast<int>(cc::CCActiveAnimation::TargetPropertyEnumSize) =
namespace cc { 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) CCActiveAnimation::CCActiveAnimation(scoped_ptr<CCAnimationCurve> curve, int animationId, int groupId, TargetProperty targetProperty)
: m_curve(curve) : m_curve(curve.Pass())
, m_id(animationId) , m_id(animationId)
, m_group(groupId) , m_group(groupId)
, m_targetProperty(targetProperty) , m_targetProperty(targetProperty)
@@ -180,14 +180,14 @@ double CCActiveAnimation::trimTimeToCurrentIteration(double monotonicTime) const
return trimmed; return trimmed;
} }
PassOwnPtr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const scoped_ptr<CCActiveAnimation> CCActiveAnimation::clone(InstanceType instanceType) const
{ {
return cloneAndInitialize(instanceType, m_runState, m_startTime); 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_runState = initialRunState;
toReturn->m_iterations = m_iterations; toReturn->m_iterations = m_iterations;
toReturn->m_startTime = startTime; toReturn->m_startTime = startTime;
@@ -196,7 +196,7 @@ PassOwnPtr<CCActiveAnimation> CCActiveAnimation::cloneAndInitialize(InstanceType
toReturn->m_timeOffset = m_timeOffset; toReturn->m_timeOffset = m_timeOffset;
toReturn->m_alternatesDirection = m_alternatesDirection; toReturn->m_alternatesDirection = m_alternatesDirection;
toReturn->m_isControllingInstance = instanceType == ControllingInstance; toReturn->m_isControllingInstance = instanceType == ControllingInstance;
return toReturn.release(); return toReturn.Pass();
} }
void CCActiveAnimation::pushPropertiesTo(CCActiveAnimation* other) const void CCActiveAnimation::pushPropertiesTo(CCActiveAnimation* other) const

@@ -6,8 +6,7 @@
#define CCActiveAnimation_h #define CCActiveAnimation_h
#include "base/basictypes.h" #include "base/basictypes.h"
#include <wtf/OwnPtr.h> #include "base/memory/scoped_ptr.h"
#include <wtf/PassOwnPtr.h>
namespace cc { namespace cc {
@@ -47,7 +46,7 @@ public:
TargetPropertyEnumSize 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(); virtual ~CCActiveAnimation();
@@ -100,16 +99,16 @@ public:
NonControllingInstance NonControllingInstance
}; };
PassOwnPtr<CCActiveAnimation> clone(InstanceType) const; scoped_ptr<CCActiveAnimation> clone(InstanceType) const;
PassOwnPtr<CCActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const; scoped_ptr<CCActiveAnimation> cloneAndInitialize(InstanceType, RunState initialRunState, double startTime) const;
bool isControllingInstance() const { return m_isControllingInstance; } bool isControllingInstance() const { return m_isControllingInstance; }
void pushPropertiesTo(CCActiveAnimation*) const; void pushPropertiesTo(CCActiveAnimation*) const;
private: 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. // IDs are not necessarily unique.
int m_id; int m_id;

@@ -15,21 +15,21 @@ using namespace cc;
namespace { 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); toReturn->setIterations(iterations);
return toReturn.release(); return toReturn.Pass();
} }
PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations) scoped_ptr<CCActiveAnimation> createActiveAnimation(int iterations)
{ {
return createActiveAnimation(iterations, 1); return createActiveAnimation(iterations, 1);
} }
TEST(CCActiveAnimationTest, TrimTimeZeroIterations) 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(-1));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1));
@@ -37,7 +37,7 @@ TEST(CCActiveAnimationTest, TrimTimeZeroIterations)
TEST(CCActiveAnimationTest, TrimTimeOneIteration) 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(-1));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1)); EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1));
@@ -46,7 +46,7 @@ TEST(CCActiveAnimationTest, TrimTimeOneIteration)
TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations) TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(-1));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1));
@@ -55,7 +55,7 @@ TEST(CCActiveAnimationTest, TrimTimeInfiniteIterations)
TEST(CCActiveAnimationTest, TrimTimeAlternating) TEST(CCActiveAnimationTest, TrimTimeAlternating)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(-1));
anim->setAlternatesDirection(true); anim->setAlternatesDirection(true);
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5));
@@ -65,7 +65,7 @@ TEST(CCActiveAnimationTest, TrimTimeAlternating)
TEST(CCActiveAnimationTest, TrimTimeStartTime) TEST(CCActiveAnimationTest, TrimTimeStartTime)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setStartTime(4); anim->setStartTime(4);
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(4));
@@ -76,7 +76,7 @@ TEST(CCActiveAnimationTest, TrimTimeStartTime)
TEST(CCActiveAnimationTest, TrimTimeTimeOffset) TEST(CCActiveAnimationTest, TrimTimeTimeOffset)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setTimeOffset(4); anim->setTimeOffset(4);
anim->setStartTime(4); anim->setStartTime(4);
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
@@ -87,7 +87,7 @@ TEST(CCActiveAnimationTest, TrimTimeTimeOffset)
TEST(CCActiveAnimationTest, TrimTimePauseResume) TEST(CCActiveAnimationTest, TrimTimePauseResume)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5));
@@ -100,7 +100,7 @@ TEST(CCActiveAnimationTest, TrimTimePauseResume)
TEST(CCActiveAnimationTest, TrimTimeSuspendResume) TEST(CCActiveAnimationTest, TrimTimeSuspendResume)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5)); EXPECT_EQ(0.5, anim->trimTimeToCurrentIteration(0.5));
@@ -113,7 +113,7 @@ TEST(CCActiveAnimationTest, TrimTimeSuspendResume)
TEST(CCActiveAnimationTest, TrimTimeZeroDuration) TEST(CCActiveAnimationTest, TrimTimeZeroDuration)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0, 0)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0, 0));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1));
EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0)); EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
@@ -122,7 +122,7 @@ TEST(CCActiveAnimationTest, TrimTimeZeroDuration)
TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations) TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_FALSE(anim->isFinishedAt(-1)); EXPECT_FALSE(anim->isFinishedAt(-1));
EXPECT_TRUE(anim->isFinishedAt(0)); EXPECT_TRUE(anim->isFinishedAt(0));
@@ -131,7 +131,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations)
TEST(CCActiveAnimationTest, IsFinishedAtOneIteration) TEST(CCActiveAnimationTest, IsFinishedAtOneIteration)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_FALSE(anim->isFinishedAt(-1)); EXPECT_FALSE(anim->isFinishedAt(-1));
EXPECT_FALSE(anim->isFinishedAt(0)); EXPECT_FALSE(anim->isFinishedAt(0));
@@ -141,7 +141,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtOneIteration)
TEST(CCActiveAnimationTest, IsFinishedAtInfiniteIterations) TEST(CCActiveAnimationTest, IsFinishedAtInfiniteIterations)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(-1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(-1));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_FALSE(anim->isFinishedAt(0)); EXPECT_FALSE(anim->isFinishedAt(0));
EXPECT_FALSE(anim->isFinishedAt(0.5)); EXPECT_FALSE(anim->isFinishedAt(0.5));
@@ -151,7 +151,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtInfiniteIterations)
TEST(CCActiveAnimationTest, IsFinishedAtNotRunning) TEST(CCActiveAnimationTest, IsFinishedAtNotRunning)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(0));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_TRUE(anim->isFinishedAt(0)); EXPECT_TRUE(anim->isFinishedAt(0));
anim->setRunState(CCActiveAnimation::Paused, 0); anim->setRunState(CCActiveAnimation::Paused, 0);
@@ -170,7 +170,7 @@ TEST(CCActiveAnimationTest, IsFinishedAtNotRunning)
TEST(CCActiveAnimationTest, IsFinished) TEST(CCActiveAnimationTest, IsFinished)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);
EXPECT_FALSE(anim->isFinished()); EXPECT_FALSE(anim->isFinished());
anim->setRunState(CCActiveAnimation::Paused, 0); anim->setRunState(CCActiveAnimation::Paused, 0);
@@ -189,7 +189,7 @@ TEST(CCActiveAnimationTest, IsFinished)
TEST(CCActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime) TEST(CCActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->setRunState(CCActiveAnimation::Running, 2); anim->setRunState(CCActiveAnimation::Running, 2);
EXPECT_FALSE(anim->isFinished()); EXPECT_FALSE(anim->isFinished());
anim->setRunState(CCActiveAnimation::Paused, 2); anim->setRunState(CCActiveAnimation::Paused, 2);
@@ -208,7 +208,7 @@ TEST(CCActiveAnimationTest, IsFinishedNeedsSynchronizedStartTime)
TEST(CCActiveAnimationTest, RunStateChangesIgnoredWhileSuspended) TEST(CCActiveAnimationTest, RunStateChangesIgnoredWhileSuspended)
{ {
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(1)); scoped_ptr<CCActiveAnimation> anim(createActiveAnimation(1));
anim->suspend(0); anim->suspend(0);
EXPECT_EQ(CCActiveAnimation::Paused, anim->runState()); EXPECT_EQ(CCActiveAnimation::Paused, anim->runState());
anim->setRunState(CCActiveAnimation::Running, 0); anim->setRunState(CCActiveAnimation::Running, 0);

@@ -5,8 +5,8 @@
#ifndef CCAnimationCurve_h #ifndef CCAnimationCurve_h
#define CCAnimationCurve_h #define CCAnimationCurve_h
#include "base/memory/scoped_ptr.h"
#include <public/WebTransformationMatrix.h> #include <public/WebTransformationMatrix.h>
#include <wtf/PassOwnPtr.h>
namespace cc { namespace cc {
@@ -25,7 +25,7 @@ public:
virtual double duration() const = 0; virtual double duration() const = 0;
virtual Type type() 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 CCFloatAnimationCurve* toFloatAnimationCurve() const;
const CCTransformAnimationCurve* toTransformAnimationCurve() const; const CCTransformAnimationCurve* toTransformAnimationCurve() const;

@@ -6,8 +6,6 @@
#include "CCKeyframedAnimationCurve.h" #include "CCKeyframedAnimationCurve.h"
#include <wtf/OwnPtr.h>
using WebKit::WebTransformationMatrix; using WebKit::WebTransformationMatrix;
namespace cc { namespace cc {
@@ -15,36 +13,34 @@ namespace cc {
namespace { namespace {
template <class Keyframe> 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 // Usually, the keyframes will be added in order, so this loop would be unnecessary and
// we should skip it if possible. // we should skip it if possible.
if (!keyframes.isEmpty() && keyframe->time() < keyframes.last()->time()) { if (!keyframes.isEmpty() && keyframe->time() < keyframes.last()->time()) {
for (size_t i = 0; i < keyframes.size(); ++i) { for (size_t i = 0; i < keyframes.size(); ++i) {
if (keyframe->time() < keyframes[i]->time()) { if (keyframe->time() < keyframes[i]->time()) {
keyframes.insert(i, keyframe.release()); keyframes.insert(i, keyframe.Pass());
return; return;
} }
} }
} }
keyframes.append(keyframe.release()); keyframes.append(keyframe.Pass());
} }
PassOwnPtr<CCTimingFunction> cloneTimingFunction(const CCTimingFunction* timingFunction) scoped_ptr<CCTimingFunction> cloneTimingFunction(const CCTimingFunction* timingFunction)
{ {
ASSERT(timingFunction); ASSERT(timingFunction);
OwnPtr<CCAnimationCurve> curve(timingFunction->clone()); scoped_ptr<CCAnimationCurve> curve(timingFunction->clone());
return adoptPtr(static_cast<CCTimingFunction*>(curve.leakPtr())); return scoped_ptr<CCTimingFunction>(static_cast<CCTimingFunction*>(curve.release()));
} }
} // namespace } // namespace
CCKeyframe::CCKeyframe(double time, PassOwnPtr<CCTimingFunction> timingFunction) CCKeyframe::CCKeyframe(double time, scoped_ptr<CCTimingFunction> timingFunction)
: m_time(time) : m_time(time)
, m_timingFunction(timingFunction) , m_timingFunction(timingFunction.Pass())
{ {
} }
@@ -62,13 +58,13 @@ const CCTimingFunction* CCKeyframe::timingFunction() const
return m_timingFunction.get(); 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) CCFloatKeyframe::CCFloatKeyframe(double time, float value, scoped_ptr<CCTimingFunction> timingFunction)
: CCKeyframe(time, timingFunction) : CCKeyframe(time, timingFunction.Pass())
, m_value(value) , m_value(value)
{ {
} }
@@ -82,18 +78,17 @@ float CCFloatKeyframe::value() const
return m_value; 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>()); }
scoped_ptr<CCTransformKeyframe> CCTransformKeyframe::create(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction> timingFunction)
{
return make_scoped_ptr(new CCTransformKeyframe(time, value, timingFunction.Pass()));
} }
PassOwnPtr<CCTransformKeyframe> CCTransformKeyframe::create(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction> timingFunction) CCTransformKeyframe::CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction> timingFunction)
{ : CCKeyframe(time, timingFunction.Pass())
return adoptPtr(new CCTransformKeyframe(time, value, timingFunction));
}
CCTransformKeyframe::CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction> timingFunction)
: CCKeyframe(time, timingFunction)
, m_value(value) , m_value(value)
{ {
} }
@@ -107,14 +102,14 @@ const WebKit::WebTransformOperations& CCTransformKeyframe::value() const
return m_value; 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() 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 double CCKeyframedFloatAnimationCurve::duration() const
@@ -135,12 +130,12 @@ double CCKeyframedFloatAnimationCurve::duration() const
return m_keyframes.last()->time() - m_keyframes.first()->time(); 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) for (size_t i = 0; i < m_keyframes.size(); ++i)
toReturn->addKeyframe(m_keyframes[i]->clone()); toReturn->addKeyframe(m_keyframes[i]->clone());
return toReturn.release(); return toReturn.PassAs<CCAnimationCurve>();
} }
float CCKeyframedFloatAnimationCurve::getValue(double t) const 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; 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() 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 double CCKeyframedTransformAnimationCurve::duration() const
@@ -188,12 +183,12 @@ double CCKeyframedTransformAnimationCurve::duration() const
return m_keyframes.last()->time() - m_keyframes.first()->time(); 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) for (size_t i = 0; i < m_keyframes.size(); ++i)
toReturn->addKeyframe(m_keyframes[i]->clone()); toReturn->addKeyframe(m_keyframes[i]->clone());
return toReturn.release(); return toReturn.PassAs<CCAnimationCurve>();
} }
WebTransformationMatrix CCKeyframedTransformAnimationCurve::getValue(double t) const WebTransformationMatrix CCKeyframedTransformAnimationCurve::getValue(double t) const

@@ -7,10 +7,8 @@
#include "CCAnimationCurve.h" #include "CCAnimationCurve.h"
#include "CCTimingFunction.h" #include "CCTimingFunction.h"
#include "cc/own_ptr_vector.h" #include "scoped_ptr_vector.h"
#include <public/WebTransformOperations.h> #include <public/WebTransformOperations.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace cc { namespace cc {
@@ -20,40 +18,40 @@ public:
const CCTimingFunction* timingFunction() const; const CCTimingFunction* timingFunction() const;
protected: protected:
CCKeyframe(double time, PassOwnPtr<CCTimingFunction>); CCKeyframe(double time, scoped_ptr<CCTimingFunction>);
virtual ~CCKeyframe(); virtual ~CCKeyframe();
private: private:
double m_time; double m_time;
OwnPtr<CCTimingFunction> m_timingFunction; scoped_ptr<CCTimingFunction> m_timingFunction;
}; };
class CCFloatKeyframe : public CCKeyframe { class CCFloatKeyframe : public CCKeyframe {
public: 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(); virtual ~CCFloatKeyframe();
float value() const; float value() const;
PassOwnPtr<CCFloatKeyframe> clone() const; scoped_ptr<CCFloatKeyframe> clone() const;
private: private:
CCFloatKeyframe(double time, float value, PassOwnPtr<CCTimingFunction>); CCFloatKeyframe(double time, float value, scoped_ptr<CCTimingFunction>);
float m_value; float m_value;
}; };
class CCTransformKeyframe : public CCKeyframe { class CCTransformKeyframe : public CCKeyframe {
public: 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(); virtual ~CCTransformKeyframe();
const WebKit::WebTransformOperations& value() const; const WebKit::WebTransformOperations& value() const;
PassOwnPtr<CCTransformKeyframe> clone() const; scoped_ptr<CCTransformKeyframe> clone() const;
private: private:
CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, PassOwnPtr<CCTimingFunction>); CCTransformKeyframe(double time, const WebKit::WebTransformOperations& value, scoped_ptr<CCTimingFunction>);
WebKit::WebTransformOperations m_value; WebKit::WebTransformOperations m_value;
}; };
@@ -61,15 +59,15 @@ private:
class CCKeyframedFloatAnimationCurve : public CCFloatAnimationCurve { class CCKeyframedFloatAnimationCurve : public CCFloatAnimationCurve {
public: public:
// It is required that the keyframes be sorted by time. // It is required that the keyframes be sorted by time.
static PassOwnPtr<CCKeyframedFloatAnimationCurve> create(); static scoped_ptr<CCKeyframedFloatAnimationCurve> create();
virtual ~CCKeyframedFloatAnimationCurve(); virtual ~CCKeyframedFloatAnimationCurve();
void addKeyframe(PassOwnPtr<CCFloatKeyframe>); void addKeyframe(scoped_ptr<CCFloatKeyframe>);
// CCAnimationCurve implementation // CCAnimationCurve implementation
virtual double duration() const OVERRIDE; virtual double duration() const OVERRIDE;
virtual PassOwnPtr<CCAnimationCurve> clone() const OVERRIDE; virtual scoped_ptr<CCAnimationCurve> clone() const OVERRIDE;
// CCFloatAnimationCurve implementation // CCFloatAnimationCurve implementation
virtual float getValue(double t) const OVERRIDE; virtual float getValue(double t) const OVERRIDE;
@@ -79,21 +77,21 @@ private:
// Always sorted in order of increasing time. No two keyframes have the // Always sorted in order of increasing time. No two keyframes have the
// same time. // same time.
OwnPtrVector<CCFloatKeyframe> m_keyframes; ScopedPtrVector<CCFloatKeyframe> m_keyframes;
}; };
class CCKeyframedTransformAnimationCurve : public CCTransformAnimationCurve { class CCKeyframedTransformAnimationCurve : public CCTransformAnimationCurve {
public: public:
// It is required that the keyframes be sorted by time. // It is required that the keyframes be sorted by time.
static PassOwnPtr<CCKeyframedTransformAnimationCurve> create(); static scoped_ptr<CCKeyframedTransformAnimationCurve> create();
virtual ~CCKeyframedTransformAnimationCurve(); virtual ~CCKeyframedTransformAnimationCurve();
void addKeyframe(PassOwnPtr<CCTransformKeyframe>); void addKeyframe(scoped_ptr<CCTransformKeyframe>);
// CCAnimationCurve implementation // CCAnimationCurve implementation
virtual double duration() const OVERRIDE; virtual double duration() const OVERRIDE;
virtual PassOwnPtr<CCAnimationCurve> clone() const OVERRIDE; virtual scoped_ptr<CCAnimationCurve> clone() const OVERRIDE;
// CCTransformAnimationCurve implementation // CCTransformAnimationCurve implementation
virtual WebKit::WebTransformationMatrix getValue(double t) const OVERRIDE; 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 // Always sorted in order of increasing time. No two keyframes have the
// same time. // same time.
OwnPtrVector<CCTransformKeyframe> m_keyframes; ScopedPtrVector<CCTransformKeyframe> m_keyframes;
}; };
} // namespace cc } // namespace cc

@@ -10,7 +10,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include <public/WebTransformOperations.h> #include <public/WebTransformOperations.h>
#include <public/WebTransformationMatrix.h> #include <public/WebTransformationMatrix.h>
#include <wtf/OwnPtr.h>
using namespace cc; using namespace cc;
using WebKit::WebTransformationMatrix; 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. // Tests that a float animation with one keyframe works as expected.
TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(-1));
EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0));
EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); 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. // Tests that a float animation with two keyframes works as expected.
TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(-1));
EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0));
EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); 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. // Tests that a float animation with three keyframes works as expected.
TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction>()));
EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(-1));
EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0));
EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); 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. // Tests that a float animation with multiple keys at a given time works sanely.
TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(0, 4, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(0, 4, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 6, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 6, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(2, 6, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(2, 6, scoped_ptr<CCTimingFunction>()));
EXPECT_FLOAT_EQ(4, curve->getValue(-1)); EXPECT_FLOAT_EQ(4, curve->getValue(-1));
EXPECT_FLOAT_EQ(4, curve->getValue(0)); 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. // Tests that a transform animation with one keyframe works as expected.
TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe)
{ {
OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
WebKit::WebTransformOperations operations; WebKit::WebTransformOperations operations;
operations.appendTranslate(2, 0, 0); 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(-1));
expectTranslateX(2, curve->getValue(0)); expectTranslateX(2, curve->getValue(0));
@@ -104,14 +103,14 @@ TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe)
// Tests that a transform animation with two keyframes works as expected. // Tests that a transform animation with two keyframes works as expected.
TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe)
{ {
OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1; WebKit::WebTransformOperations operations1;
operations1.appendTranslate(2, 0, 0); operations1.appendTranslate(2, 0, 0);
WebKit::WebTransformOperations operations2; WebKit::WebTransformOperations operations2;
operations2.appendTranslate(4, 0, 0); operations2.appendTranslate(4, 0, 0);
curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>()));
expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(-1));
expectTranslateX(2, curve->getValue(0)); expectTranslateX(2, curve->getValue(0));
expectTranslateX(3, curve->getValue(0.5)); expectTranslateX(3, curve->getValue(0.5));
@@ -122,16 +121,16 @@ TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe)
// Tests that a transform animation with three keyframes works as expected. // Tests that a transform animation with three keyframes works as expected.
TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe)
{ {
OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1; WebKit::WebTransformOperations operations1;
operations1.appendTranslate(2, 0, 0); operations1.appendTranslate(2, 0, 0);
WebKit::WebTransformOperations operations2; WebKit::WebTransformOperations operations2;
operations2.appendTranslate(4, 0, 0); operations2.appendTranslate(4, 0, 0);
WebKit::WebTransformOperations operations3; WebKit::WebTransformOperations operations3;
operations3.appendTranslate(8, 0, 0); operations3.appendTranslate(8, 0, 0);
curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCTransformKeyframe::create(2, operations3, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(2, operations3, scoped_ptr<CCTimingFunction>()));
expectTranslateX(2, curve->getValue(-1)); expectTranslateX(2, curve->getValue(-1));
expectTranslateX(2, curve->getValue(0)); expectTranslateX(2, curve->getValue(0));
expectTranslateX(3, curve->getValue(0.5)); 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. // Tests that a transform animation with multiple keys at a given time works sanely.
TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
{ {
OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
// A step function. // A step function.
WebKit::WebTransformOperations operations1; WebKit::WebTransformOperations operations1;
operations1.appendTranslate(4, 0, 0); operations1.appendTranslate(4, 0, 0);
@@ -154,10 +153,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
operations3.appendTranslate(6, 0, 0); operations3.appendTranslate(6, 0, 0);
WebKit::WebTransformOperations operations4; WebKit::WebTransformOperations operations4;
operations4.appendTranslate(6, 0, 0); operations4.appendTranslate(6, 0, 0);
curve->addKeyframe(CCTransformKeyframe::create(0, operations1, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCTransformKeyframe::create(1, operations2, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCTransformKeyframe::create(1, operations3, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(1, operations3, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCTransformKeyframe::create(2, operations4, nullptr)); curve->addKeyframe(CCTransformKeyframe::create(2, operations4, scoped_ptr<CCTimingFunction>()));
expectTranslateX(4, curve->getValue(-1)); expectTranslateX(4, curve->getValue(-1));
expectTranslateX(4, curve->getValue(0)); expectTranslateX(4, curve->getValue(0));
@@ -175,10 +174,10 @@ TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
// Tests that the keyframes may be added out of order. // Tests that the keyframes may be added out of order.
TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes) TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(2, 8, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(0, 2, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 4, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
EXPECT_FLOAT_EQ(2, curve->getValue(-1)); EXPECT_FLOAT_EQ(2, curve->getValue(-1));
EXPECT_FLOAT_EQ(2, curve->getValue(0)); EXPECT_FLOAT_EQ(2, curve->getValue(0));
EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); 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. // Tests that a cubic bezier timing function works as expected.
TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction) TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1))); curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1).PassAs<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 1, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 1, scoped_ptr<CCTimingFunction>()));
EXPECT_FLOAT_EQ(0, curve->getValue(0)); EXPECT_FLOAT_EQ(0, curve->getValue(0));
EXPECT_LT(0, curve->getValue(0.25)); EXPECT_LT(0, curve->getValue(0.25));

@@ -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) void CCLayerAnimationController::pauseAnimation(int animationId, double timeOffset)
@@ -108,9 +108,9 @@ void CCLayerAnimationController::animate(double monotonicTime, CCAnimationEvents
startAnimationsWaitingForTargetAvailability(monotonicTime, events); 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 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. // The new animation should be set to run as soon as possible.
CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability; CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability;
double startTime = 0; 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()); ASSERT(!toAdd->needsSynchronizedStartTime());
controllerImpl->addAnimation(toAdd.release()); controllerImpl->addAnimation(toAdd.Pass());
} }
} }
@@ -348,17 +348,17 @@ void CCLayerAnimationController::replaceImplThreadAnimations(CCLayerAnimationCon
{ {
controllerImpl->m_activeAnimations.clear(); controllerImpl->m_activeAnimations.clear();
for (size_t i = 0; i < m_activeAnimations.size(); ++i) { for (size_t i = 0; i < m_activeAnimations.size(); ++i) {
OwnPtr<CCActiveAnimation> toAdd; scoped_ptr<CCActiveAnimation> toAdd;
if (m_activeAnimations[i]->needsSynchronizedStartTime()) { if (m_activeAnimations[i]->needsSynchronizedStartTime()) {
// We haven't received an animation started notification yet, so it // We haven't received an animation started notification yet, so it
// is important that we add it in a 'waiting' and not 'running' state. // is important that we add it in a 'waiting' and not 'running' state.
CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability; CCActiveAnimation::RunState initialRunState = CCActiveAnimation::WaitingForTargetAvailability;
double startTime = 0; double startTime = 0;
toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime); toAdd = m_activeAnimations[i]->cloneAndInitialize(CCActiveAnimation::ControllingInstance, initialRunState, startTime).Pass();
} else } else
toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance); toAdd = m_activeAnimations[i]->clone(CCActiveAnimation::ControllingInstance).Pass();
controllerImpl->addAnimation(toAdd.release()); controllerImpl->addAnimation(toAdd.Pass());
} }
} }

@@ -8,10 +8,9 @@
#include "CCAnimationEvents.h" #include "CCAnimationEvents.h"
#include "base/basictypes.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/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace WebKit { namespace WebKit {
class WebTransformationMatrix; class WebTransformationMatrix;
@@ -36,12 +35,12 @@ public:
class CCLayerAnimationController { class CCLayerAnimationController {
public: public:
static PassOwnPtr<CCLayerAnimationController> create(CCLayerAnimationControllerClient*); static scoped_ptr<CCLayerAnimationController> create(CCLayerAnimationControllerClient*);
virtual ~CCLayerAnimationController(); virtual ~CCLayerAnimationController();
// These methods are virtual for testing. // 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 pauseAnimation(int animationId, double timeOffset);
virtual void removeAnimation(int animationId); virtual void removeAnimation(int animationId);
virtual void removeAnimation(int animationId, CCActiveAnimation::TargetProperty); virtual void removeAnimation(int animationId, CCActiveAnimation::TargetProperty);
@@ -103,7 +102,7 @@ private:
bool m_forceSync; bool m_forceSync;
CCLayerAnimationControllerClient* m_client; CCLayerAnimationControllerClient* m_client;
OwnPtrVector<CCActiveAnimation> m_activeAnimations; ScopedPtrVector<CCActiveAnimation> m_activeAnimations;
DISALLOW_COPY_AND_ASSIGN(CCLayerAnimationController); DISALLOW_COPY_AND_ASSIGN(CCLayerAnimationController);
}; };

@@ -24,17 +24,17 @@ void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
EXPECT_FLOAT_EQ(translateX, matrix.m41()); 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) TEST(CCLayerAnimationControllerTest, syncNewAnimation)
{ {
FakeLayerAnimationControllerClient dummyImpl; FakeLayerAnimationControllerClient dummyImpl;
OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity));
@@ -51,9 +51,9 @@ TEST(CCLayerAnimationControllerTest, syncNewAnimation)
TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes) TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes)
{ {
FakeLayerAnimationControllerClient dummyImpl; FakeLayerAnimationControllerClient dummyImpl;
OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity));
@@ -80,9 +80,9 @@ TEST(CCLayerAnimationControllerTest, doNotClobberStartTimes)
TEST(CCLayerAnimationControllerTest, syncPauseAndResume) TEST(CCLayerAnimationControllerTest, syncPauseAndResume)
{ {
FakeLayerAnimationControllerClient dummyImpl; FakeLayerAnimationControllerClient dummyImpl;
OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity));
@@ -120,9 +120,9 @@ TEST(CCLayerAnimationControllerTest, syncPauseAndResume)
TEST(CCLayerAnimationControllerTest, doNotSyncFinishedAnimation) TEST(CCLayerAnimationControllerTest, doNotSyncFinishedAnimation)
{ {
FakeLayerAnimationControllerClient dummyImpl; FakeLayerAnimationControllerClient dummyImpl;
OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy)); scoped_ptr<CCLayerAnimationController> controller(CCLayerAnimationController::create(&dummy));
EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); 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. // Tests that transitioning opacity from 0 to 1 works as expected.
TEST(CCLayerAnimationControllerTest, TrivialTransition) TEST(CCLayerAnimationControllerTest, TrivialTransition)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
EXPECT_EQ(0, dummy.opacity()); 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. // Tests animations that are waiting for a synchronized start time do not finish.
TEST(CCLayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDuration) TEST(CCLayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDuration)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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); toAdd->setNeedsSynchronizedStartTime(true);
// We should pause at the first keyframe indefinitely waiting for that animation to start. // 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()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
EXPECT_EQ(0, dummy.opacity()); EXPECT_EQ(0, dummy.opacity());
@@ -200,13 +200,13 @@ TEST(CCLayerAnimationControllerTest, AnimationsWaitingForStartTimeDoNotFinishIfT
// Tests that two queued animations affecting the same property run in sequence. // Tests that two queued animations affecting the same property run in sequence.
TEST(CCLayerAnimationControllerTest, TrivialQueuing) TEST(CCLayerAnimationControllerTest, TrivialQueuing)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5)), 2, CCActiveAnimation::Opacity)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.5)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity));
controller->animate(0, events.get()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
@@ -222,18 +222,18 @@ TEST(CCLayerAnimationControllerTest, TrivialQueuing)
// Tests interrupting a transition with another transition. // Tests interrupting a transition with another transition.
TEST(CCLayerAnimationControllerTest, Interrupt) TEST(CCLayerAnimationControllerTest, Interrupt)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
EXPECT_EQ(0, dummy.opacity()); 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); 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 // Since the animation was in the WaitingForNextTick state, it should start right in
// this call to animate. // this call to animate.
@@ -248,14 +248,14 @@ TEST(CCLayerAnimationControllerTest, Interrupt)
// Tests scheduling two animations to run together when only one property is free. // Tests scheduling two animations to run together when only one property is free.
TEST(CCLayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) TEST(CCLayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); CCLayerAnimationController::create(&dummy));
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), 1, CCActiveAnimation::Transform)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Transform));
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), 2, CCActiveAnimation::Transform)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Transform));
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 2, CCActiveAnimation::Opacity)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 0, 1)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity));
controller->animate(0, events.get()); controller->animate(0, events.get());
EXPECT_EQ(0, dummy.opacity()); EXPECT_EQ(0, dummy.opacity());
@@ -275,14 +275,14 @@ TEST(CCLayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked)
// for both to finish). // for both to finish).
TEST(CCLayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) TEST(CCLayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); CCLayerAnimationController::create(&dummy));
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(2)), 1, CCActiveAnimation::Transform)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(2)).PassAs<CCAnimationCurve>(), 1, CCActiveAnimation::Transform));
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->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5)), 2, 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. // Animations with id 1 should both start now.
controller->animate(0, events.get()); controller->animate(0, events.get());
@@ -305,15 +305,15 @@ TEST(CCLayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting)
// Tests scheduling an animation to start in the future. // Tests scheduling an animation to start in the future.
TEST(CCLayerAnimationControllerTest, ScheduleAnimation) TEST(CCLayerAnimationControllerTest, ScheduleAnimation)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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->setRunState(CCActiveAnimation::WaitingForStartTime, 0);
toAdd->setStartTime(1); toAdd->setStartTime(1);
controller->addAnimation(toAdd.release()); controller->addAnimation(toAdd.Pass());
controller->animate(0, events.get()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); 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. // Tests scheduling an animation to start in the future that's interrupting a running animation.
TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation) TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimation)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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->setRunState(CCActiveAnimation::WaitingForStartTime, 0);
toAdd->setStartTime(1); toAdd->setStartTime(1);
controller->addAnimation(toAdd.release()); controller->addAnimation(toAdd.Pass());
// First 2s opacity transition should start immediately. // First 2s opacity transition should start immediately.
controller->animate(0, events.get()); controller->animate(0, events.get());
@@ -360,19 +360,19 @@ TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimatio
// and there is yet another animation queued to start later. // and there is yet another animation queued to start later.
TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) TEST(CCLayerAnimationControllerTest, ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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->setRunState(CCActiveAnimation::WaitingForStartTime, 0);
toAdd->setStartTime(1); 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. // First 2s opacity transition should start immediately.
controller->animate(0, events.get()); 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 that a looping animation loops and for the correct number of iterations.
TEST(CCLayerAnimationControllerTest, TrivialLooping) TEST(CCLayerAnimationControllerTest, TrivialLooping)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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); toAdd->setIterations(3);
controller->addAnimation(toAdd.release()); controller->addAnimation(toAdd.Pass());
controller->animate(0, events.get()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
@@ -432,15 +432,15 @@ TEST(CCLayerAnimationControllerTest, TrivialLooping)
// Test that an infinitely looping animation does indeed go until aborted. // Test that an infinitely looping animation does indeed go until aborted.
TEST(CCLayerAnimationControllerTest, InfiniteLooping) TEST(CCLayerAnimationControllerTest, InfiniteLooping)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); CCLayerAnimationController::create(&dummy));
const int id = 1; 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); toAdd->setIterations(-1);
controller->addAnimation(toAdd.release()); controller->addAnimation(toAdd.Pass());
controller->animate(0, events.get()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
@@ -468,13 +468,13 @@ TEST(CCLayerAnimationControllerTest, InfiniteLooping)
// Test that pausing and resuming work as expected. // Test that pausing and resuming work as expected.
TEST(CCLayerAnimationControllerTest, PauseResume) TEST(CCLayerAnimationControllerTest, PauseResume)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); CCLayerAnimationController::create(&dummy));
const int id = 1; 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()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
@@ -503,15 +503,15 @@ TEST(CCLayerAnimationControllerTest, PauseResume)
TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation) TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation)
{ {
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); CCLayerAnimationController::create(&dummy));
const int id = 1; const int id = 1;
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), id, CCActiveAnimation::Transform)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeTransformTransition(1)).PassAs<CCAnimationCurve>(), id, CCActiveAnimation::Transform));
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), id, CCActiveAnimation::Opacity)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(2, 0, 1)).PassAs<CCAnimationCurve>(), id, CCActiveAnimation::Opacity));
controller->addAnimation(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.75)), 2, CCActiveAnimation::Opacity)); controller->addAnimation(createActiveAnimation(make_scoped_ptr(new FakeFloatTransition(1, 1, 0.75)).PassAs<CCAnimationCurve>(), 2, CCActiveAnimation::Opacity));
controller->animate(0, events.get()); controller->animate(0, events.get());
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());
@@ -533,15 +533,15 @@ TEST(CCLayerAnimationControllerTest, AbortAGroupedAnimation)
TEST(CCLayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) TEST(CCLayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded)
{ {
FakeLayerAnimationControllerClient dummyImpl; FakeLayerAnimationControllerClient dummyImpl;
OwnPtr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl)); scoped_ptr<CCLayerAnimationController> controllerImpl(CCLayerAnimationController::create(&dummyImpl));
OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); scoped_ptr<CCAnimationEventsVector> events(make_scoped_ptr(new CCAnimationEventsVector));
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
OwnPtr<CCLayerAnimationController> controller( scoped_ptr<CCLayerAnimationController> controller(
CCLayerAnimationController::create(&dummy)); 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); toAdd->setNeedsSynchronizedStartTime(true);
controller->addAnimation(toAdd.release()); controller->addAnimation(toAdd.Pass());
controller->animate(0, 0); controller->animate(0, 0);
EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_TRUE(controller->hasActiveAnimation());

@@ -386,7 +386,7 @@ private:
FloatRect m_updateRect; FloatRect m_updateRect;
// Manages animations for this layer. // Manages animations for this layer.
OwnPtr<CCLayerAnimationController> m_layerAnimationController; scoped_ptr<CCLayerAnimationController> m_layerAnimationController;
// Manages scrollbars for this layer // Manages scrollbars for this layer
OwnPtr<CCScrollbarAnimationController> m_scrollbarAnimationController; OwnPtr<CCScrollbarAnimationController> m_scrollbarAnimationController;

@@ -2188,9 +2188,9 @@ public:
layer->setLayerAnimationDelegate(this); layer->setLayerAnimationDelegate(this);
// Any valid CCAnimationCurve will do here. // Any valid CCAnimationCurve will do here.
OwnPtr<CCAnimationCurve> curve(CCEaseTimingFunction::create()); scoped_ptr<CCAnimationCurve> curve(CCEaseTimingFunction::create());
OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), 1, 1, CCActiveAnimation::Opacity)); scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.Pass(), 1, 1, CCActiveAnimation::Opacity));
layer->layerAnimationController()->addAnimation(animation.release()); layer->layerAnimationController()->addAnimation(animation.Pass());
// We add the animation *before* attaching the layer to the tree. // We add the animation *before* attaching the layer to the tree.
m_layerTreeHost->rootLayer()->addChild(layer); m_layerTreeHost->rootLayer()->addChild(layer);

@@ -6,8 +6,6 @@
#include "CCTimingFunction.h" #include "CCTimingFunction.h"
#include <wtf/OwnPtr.h>
namespace { namespace {
const double epsilon = 1e-6; const double epsilon = 1e-6;
} // namespace } // namespace
@@ -27,9 +25,9 @@ double CCTimingFunction::duration() const
return 1.0; 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) 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)); 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. // 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 } // namespace cc

@@ -7,7 +7,6 @@
#include "CCAnimationCurve.h" #include "CCAnimationCurve.h"
#include "UnitBezier.h" #include "UnitBezier.h"
#include <wtf/PassOwnPtr.h>
namespace cc { namespace cc {
@@ -25,12 +24,12 @@ protected:
class CCCubicBezierTimingFunction : public CCTimingFunction { class CCCubicBezierTimingFunction : public CCTimingFunction {
public: 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(); virtual ~CCCubicBezierTimingFunction();
// Partial implementation of CCFloatAnimationCurve. // Partial implementation of CCFloatAnimationCurve.
virtual float getValue(double time) const OVERRIDE; virtual float getValue(double time) const OVERRIDE;
virtual PassOwnPtr<CCAnimationCurve> clone() const OVERRIDE; virtual scoped_ptr<CCAnimationCurve> clone() const OVERRIDE;
protected: protected:
CCCubicBezierTimingFunction(double x1, double y1, double x2, double y2); CCCubicBezierTimingFunction(double x1, double y1, double x2, double y2);
@@ -40,22 +39,22 @@ protected:
class CCEaseTimingFunction { class CCEaseTimingFunction {
public: public:
static PassOwnPtr<CCTimingFunction> create(); static scoped_ptr<CCTimingFunction> create();
}; };
class CCEaseInTimingFunction { class CCEaseInTimingFunction {
public: public:
static PassOwnPtr<CCTimingFunction> create(); static scoped_ptr<CCTimingFunction> create();
}; };
class CCEaseOutTimingFunction { class CCEaseOutTimingFunction {
public: public:
static PassOwnPtr<CCTimingFunction> create(); static scoped_ptr<CCTimingFunction> create();
}; };
class CCEaseInOutTimingFunction { class CCEaseInOutTimingFunction {
public: public:
static PassOwnPtr<CCTimingFunction> create(); static scoped_ptr<CCTimingFunction> create();
}; };
} // namespace cc } // namespace cc

@@ -648,7 +648,7 @@ void LayerChromium::setBoundsContainPageScale(bool boundsContainPageScale)
void LayerChromium::createRenderSurface() void LayerChromium::createRenderSurface()
{ {
ASSERT(!m_renderSurface); ASSERT(!m_renderSurface);
m_renderSurface = adoptPtr(new RenderSurfaceChromium(this)); m_renderSurface = make_scoped_ptr(new RenderSurfaceChromium(this));
setRenderTarget(this); setRenderTarget(this);
} }
@@ -692,7 +692,7 @@ void LayerChromium::setTransformFromAnimation(const WebTransformationMatrix& tra
m_transform = transform; 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 // WebCore currently assumes that accelerated animations will start soon
// after the animation is added. However we cannot guarantee that if we do // 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()) if (!CCSettings::acceleratedAnimationEnabled())
return false; return false;
m_layerAnimationController->addAnimation(animation); m_layerAnimationController->addAnimation(animation.Pass());
if (m_layerTreeHost) { if (m_layerTreeHost) {
m_layerTreeHost->didAddAnimation(); m_layerTreeHost->didAddAnimation();
setNeedsCommit(); setNeedsCommit();
@@ -735,9 +735,9 @@ void LayerChromium::resumeAnimations(double monotonicTime)
setNeedsCommit(); setNeedsCommit();
} }
void LayerChromium::setLayerAnimationController(PassOwnPtr<CCLayerAnimationController> layerAnimationController) void LayerChromium::setLayerAnimationController(scoped_ptr<CCLayerAnimationController> layerAnimationController)
{ {
m_layerAnimationController = layerAnimationController; m_layerAnimationController = layerAnimationController.Pass();
if (m_layerAnimationController) { if (m_layerAnimationController) {
m_layerAnimationController->setClient(this); m_layerAnimationController->setClient(this);
m_layerAnimationController->setForceSync(); m_layerAnimationController->setForceSync();
@@ -745,11 +745,11 @@ void LayerChromium::setLayerAnimationController(PassOwnPtr<CCLayerAnimationContr
setNeedsCommit(); 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); m_layerAnimationController = CCLayerAnimationController::create(this);
return toReturn.release(); return toReturn.Pass();
} }
bool LayerChromium::hasActiveAnimation() const bool LayerChromium::hasActiveAnimation() const

@@ -196,7 +196,7 @@ public:
virtual void pushPropertiesTo(CCLayerImpl*); virtual void pushPropertiesTo(CCLayerImpl*);
void clearRenderSurface() { m_renderSurface.clear(); } void clearRenderSurface() { m_renderSurface.reset(); }
RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); } RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); }
void createRenderSurface(); void createRenderSurface();
@@ -243,7 +243,7 @@ public:
// Set the priority of all desired textures in this layer. // Set the priority of all desired textures in this layer.
virtual void setTexturePriorities(const CCPriorityCalculator&) { } virtual void setTexturePriorities(const CCPriorityCalculator&) { }
bool addAnimation(PassOwnPtr<CCActiveAnimation>); bool addAnimation(scoped_ptr<CCActiveAnimation>);
void pauseAnimation(int animationId, double timeOffset); void pauseAnimation(int animationId, double timeOffset);
void removeAnimation(int animationId); void removeAnimation(int animationId);
@@ -251,8 +251,8 @@ public:
void resumeAnimations(double monotonicTime); void resumeAnimations(double monotonicTime);
CCLayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); } CCLayerAnimationController* layerAnimationController() { return m_layerAnimationController.get(); }
void setLayerAnimationController(PassOwnPtr<CCLayerAnimationController>); void setLayerAnimationController(scoped_ptr<CCLayerAnimationController>);
PassOwnPtr<CCLayerAnimationController> releaseLayerAnimationController(); scoped_ptr<CCLayerAnimationController> releaseLayerAnimationController();
void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationDelegate) { m_layerAnimationDelegate = layerAnimationDelegate; } void setLayerAnimationDelegate(WebKit::WebAnimationDelegate* layerAnimationDelegate) { m_layerAnimationDelegate = layerAnimationDelegate; }
@@ -317,7 +317,7 @@ private:
// updated via setLayerTreeHost() if a layer moves between trees. // updated via setLayerTreeHost() if a layer moves between trees.
CCLayerTreeHost* m_layerTreeHost; CCLayerTreeHost* m_layerTreeHost;
OwnPtr<CCLayerAnimationController> m_layerAnimationController; scoped_ptr<CCLayerAnimationController> m_layerAnimationController;
// Layer properties. // Layer properties.
IntSize m_bounds; IntSize m_bounds;
@@ -361,7 +361,7 @@ private:
scoped_refptr<LayerChromium> m_replicaLayer; scoped_refptr<LayerChromium> m_replicaLayer;
// Transient properties. // Transient properties.
OwnPtr<RenderSurfaceChromium> m_renderSurface; scoped_ptr<RenderSurfaceChromium> m_renderSurface;
float m_drawOpacity; float m_drawOpacity;
bool m_drawOpacityIsAnimating; bool m_drawOpacityIsAnimating;

@@ -791,12 +791,12 @@ TEST(LayerChromiumLayerTreeHostTest, destroyHostWithNonNullRootLayer)
static bool addTestAnimation(LayerChromium* layer) static bool addTestAnimation(LayerChromium* layer)
{ {
OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create()); scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, scoped_ptr<CCTimingFunction>()));
curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, nullptr)); curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, scoped_ptr<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));
return layer->addAnimation(animation.release()); return layer->addAnimation(animation.Pass());
} }
TEST(LayerChromiumLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) TEST(LayerChromiumLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost)

@@ -77,9 +77,9 @@ private:
class FakeLayerAnimationController : public CCLayerAnimationController { class FakeLayerAnimationController : public CCLayerAnimationController {
public: 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; } bool synchronizedAnimations() const { return m_synchronizedAnimations; }
@@ -392,7 +392,7 @@ TEST(TreeSynchronizerTest, synchronizeAnimations)
scoped_refptr<LayerChromium> layerTreeRoot = LayerChromium::create(); scoped_refptr<LayerChromium> layerTreeRoot = LayerChromium::create();
FakeLayerAnimationControllerClient dummy; FakeLayerAnimationControllerClient dummy;
layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create(&dummy)); layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create(&dummy).PassAs<CCLayerAnimationController>());
EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations());

@@ -19,38 +19,38 @@ namespace {
template <class Target> template <class Target>
void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity, bool useTimingFunction) 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) if (duration > 0)
curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFunction ? nullptr : CCEaseTimingFunction::create())); curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFunction ? scoped_ptr<CCTimingFunction>(): CCEaseTimingFunction::create()));
curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, nullptr)); 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); animation->setNeedsSynchronizedStartTime(true);
target.addAnimation(animation.release()); target.addAnimation(animation.Pass());
} }
template <class Target> template <class Target>
void addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY) void addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY)
{ {
static int id = 0; static int id = 0;
OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create()); scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
if (duration > 0) { if (duration > 0) {
WebKit::WebTransformOperations startOperations; WebKit::WebTransformOperations startOperations;
startOperations.appendTranslate(deltaX, deltaY, 0); 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; WebKit::WebTransformOperations operations;
operations.appendTranslate(deltaX, deltaY, 0); 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); animation->setNeedsSynchronizedStartTime(true);
target.addAnimation(animation.release()); target.addAnimation(animation.Pass());
} }
} // namespace } // namespace
@@ -81,9 +81,9 @@ float FakeFloatAnimationCurve::getValue(double now) const
return 0; 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) FakeTransformTransition::FakeTransformTransition(double duration)
@@ -105,9 +105,9 @@ WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) c
return WebKit::WebTransformationMatrix(); 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; 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) void addOpacityTransitionToController(cc::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity, bool useTimingFunction)

@@ -10,8 +10,6 @@
#include "CCLayerAnimationController.h" #include "CCLayerAnimationController.h"
#include "IntSize.h" #include "IntSize.h"
#include <wtf/OwnPtr.h>
namespace cc { namespace cc {
class CCLayerImpl; class CCLayerImpl;
class LayerChromium; class LayerChromium;
@@ -27,7 +25,7 @@ public:
virtual double duration() const OVERRIDE; virtual double duration() const OVERRIDE;
virtual float getValue(double now) 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: private:
double m_duration; double m_duration;
@@ -41,7 +39,7 @@ public:
virtual double duration() const OVERRIDE; virtual double duration() const OVERRIDE;
virtual WebKit::WebTransformationMatrix getValue(double time) 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: private:
double m_duration; double m_duration;
@@ -55,7 +53,7 @@ public:
virtual double duration() const OVERRIDE; virtual double duration() const OVERRIDE;
virtual float getValue(double time) 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: private:
double m_duration; double m_duration;

@@ -8,12 +8,9 @@
#include "CCTimingFunction.h" #include "CCTimingFunction.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace WebKit { namespace WebKit {
PassOwnPtr<cc::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingFunctionType type) scoped_ptr<cc::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingFunctionType type)
{ {
switch (type) { switch (type) {
case WebAnimationCurve::TimingFunctionTypeEase: case WebAnimationCurve::TimingFunctionTypeEase:
@@ -25,9 +22,9 @@ PassOwnPtr<cc::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingF
case WebAnimationCurve::TimingFunctionTypeEaseInOut: case WebAnimationCurve::TimingFunctionTypeEaseInOut:
return cc::CCEaseInOutTimingFunction::create(); return cc::CCEaseInOutTimingFunction::create();
case WebAnimationCurve::TimingFunctionTypeLinear: case WebAnimationCurve::TimingFunctionTypeLinear:
return nullptr; return scoped_ptr<cc::CCTimingFunction>();
} }
return nullptr; return scoped_ptr<cc::CCTimingFunction>();
} }
} // namespace WebKit } // namespace WebKit

@@ -5,6 +5,7 @@
#ifndef WebAnimationCurveCommon_h #ifndef WebAnimationCurveCommon_h
#define WebAnimationCurveCommon_h #define WebAnimationCurveCommon_h
#include "base/memory/scoped_ptr.h"
#include <public/WebAnimationCurve.h> #include <public/WebAnimationCurve.h>
#include <wtf/Forward.h> #include <wtf/Forward.h>
@@ -13,7 +14,7 @@ class CCTimingFunction;
} }
namespace WebKit { namespace WebKit {
PassOwnPtr<cc::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingFunctionType); scoped_ptr<cc::CCTimingFunction> createTimingFunction(WebAnimationCurve::TimingFunctionType);
} }
#endif // WebAnimationCurveCommon_h #endif // WebAnimationCurveCommon_h

@@ -13,7 +13,6 @@
#include <public/WebAnimation.h> #include <public/WebAnimation.h>
#include <public/WebAnimationCurve.h> #include <public/WebAnimationCurve.h>
#include <wtf/OwnPtr.h> #include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
using cc::CCActiveAnimation; using cc::CCActiveAnimation;
@@ -34,7 +33,7 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp
groupId = nextGroupId++; groupId = nextGroupId++;
WebAnimationCurve::AnimationCurveType curveType = webCurve.type(); WebAnimationCurve::AnimationCurveType curveType = webCurve.type();
OwnPtr<cc::CCAnimationCurve> curve; scoped_ptr<cc::CCAnimationCurve> curve;
switch (curveType) { switch (curveType) {
case WebAnimationCurve::AnimationCurveTypeFloat: { case WebAnimationCurve::AnimationCurveTypeFloat: {
const WebFloatAnimationCurveImpl* floatCurveImpl = static_cast<const WebFloatAnimationCurveImpl*>(&webCurve); const WebFloatAnimationCurveImpl* floatCurveImpl = static_cast<const WebFloatAnimationCurveImpl*>(&webCurve);
@@ -47,7 +46,7 @@ WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& webCurve, TargetProp
break; break;
} }
} }
m_animation = CCActiveAnimation::create(curve.release(), animationId, groupId, static_cast<cc::CCActiveAnimation::TargetProperty>(targetProperty)); m_animation = CCActiveAnimation::create(curve.Pass(), animationId, groupId, static_cast<cc::CCActiveAnimation::TargetProperty>(targetProperty));
} }
WebAnimationImpl::~WebAnimationImpl() WebAnimationImpl::~WebAnimationImpl()
@@ -104,11 +103,11 @@ void WebAnimationImpl::setAlternatesDirection(bool alternates)
m_animation->setAlternatesDirection(alternates); m_animation->setAlternatesDirection(alternates);
} }
PassOwnPtr<cc::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation() scoped_ptr<cc::CCActiveAnimation> WebAnimationImpl::cloneToCCAnimation()
{ {
OwnPtr<cc::CCActiveAnimation> toReturn(m_animation->clone(cc::CCActiveAnimation::NonControllingInstance)); scoped_ptr<cc::CCActiveAnimation> toReturn(m_animation->clone(cc::CCActiveAnimation::NonControllingInstance));
toReturn->setNeedsSynchronizedStartTime(true); toReturn->setNeedsSynchronizedStartTime(true);
return toReturn.release(); return toReturn.Pass();
} }
} // namespace WebKit } // namespace WebKit

@@ -5,6 +5,7 @@
#ifndef WebAnimationImpl_h #ifndef WebAnimationImpl_h
#define WebAnimationImpl_h #define WebAnimationImpl_h
#include "base/memory/scoped_ptr.h"
#include <public/WebAnimation.h> #include <public/WebAnimation.h>
#include <wtf/OwnPtr.h> #include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h> #include <wtf/PassOwnPtr.h>
@@ -32,9 +33,10 @@ public:
virtual bool alternatesDirection() const OVERRIDE; virtual bool alternatesDirection() const OVERRIDE;
virtual void setAlternatesDirection(bool) OVERRIDE; virtual void setAlternatesDirection(bool) OVERRIDE;
PassOwnPtr<cc::CCActiveAnimation> cloneToCCAnimation(); scoped_ptr<cc::CCActiveAnimation> cloneToCCAnimation();
private: private:
OwnPtr<cc::CCActiveAnimation> m_animation; scoped_ptr<cc::CCActiveAnimation> m_animation;
}; };
} }

@@ -10,8 +10,6 @@
#include "CCKeyframedAnimationCurve.h" #include "CCKeyframedAnimationCurve.h"
#include "CCTimingFunction.h" #include "CCTimingFunction.h"
#include "WebAnimationCurveCommon.h" #include "WebAnimationCurveCommon.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace WebKit { namespace WebKit {
@@ -46,7 +44,7 @@ void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, TimingFun
void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, double x1, double y1, double x2, double y2) void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe, double x1, double y1, double x2, double y2)
{ {
m_curve->addKeyframe(cc::CCFloatKeyframe::create(keyframe.time, keyframe.value, cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2))); m_curve->addKeyframe(cc::CCFloatKeyframe::create(keyframe.time, keyframe.value, cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2).PassAs<cc::CCTimingFunction>()));
} }
float WebFloatAnimationCurveImpl::getValue(double time) const float WebFloatAnimationCurveImpl::getValue(double time) const
@@ -54,7 +52,7 @@ float WebFloatAnimationCurveImpl::getValue(double time) const
return m_curve->getValue(time); return m_curve->getValue(time);
} }
PassOwnPtr<cc::CCAnimationCurve> WebFloatAnimationCurveImpl::cloneToCCAnimationCurve() const scoped_ptr<cc::CCAnimationCurve> WebFloatAnimationCurveImpl::cloneToCCAnimationCurve() const
{ {
return m_curve->clone(); return m_curve->clone();
} }

@@ -5,9 +5,8 @@
#ifndef WebFloatAnimationCurveImpl_h #ifndef WebFloatAnimationCurveImpl_h
#define WebFloatAnimationCurveImpl_h #define WebFloatAnimationCurveImpl_h
#include "base/memory/scoped_ptr.h"
#include <public/WebFloatAnimationCurve.h> #include <public/WebFloatAnimationCurve.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace cc { namespace cc {
class CCAnimationCurve; class CCAnimationCurve;
@@ -31,10 +30,10 @@ public:
virtual float getValue(double time) const OVERRIDE; virtual float getValue(double time) const OVERRIDE;
PassOwnPtr<cc::CCAnimationCurve> cloneToCCAnimationCurve() const; scoped_ptr<cc::CCAnimationCurve> cloneToCCAnimationCurve() const;
private: private:
OwnPtr<cc::CCKeyframedFloatAnimationCurve> m_curve; scoped_ptr<cc::CCKeyframedFloatAnimationCurve> m_curve;
}; };
} }

@@ -119,7 +119,7 @@ TEST(WebFloatAnimationCurveTest, EaseTimingFunction)
curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase); curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase);
curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time));
@@ -146,7 +146,7 @@ TEST(WebFloatAnimationCurveTest, EaseInTimingFunction)
curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseIn); curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseIn);
curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time));
@@ -160,7 +160,7 @@ TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction)
curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseOut); curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseOut);
curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time));
@@ -174,7 +174,7 @@ TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction)
curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseInOut); curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEaseInOut);
curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time));
@@ -192,7 +192,7 @@ TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction)
curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2);
curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2)); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2));
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time));
@@ -206,7 +206,7 @@ TEST(WebFloatAnimationCurveTest, DefaultTimingFunction)
curve->add(WebFloatKeyframe(0, 0)); curve->add(WebFloatKeyframe(0, 0));
curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time));

@@ -45,7 +45,7 @@ void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, T
void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, double x1, double y1, double x2, double y2) void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, double x1, double y1, double x2, double y2)
{ {
m_curve->addKeyframe(cc::CCTransformKeyframe::create(keyframe.time, keyframe.value, cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2))); m_curve->addKeyframe(cc::CCTransformKeyframe::create(keyframe.time, keyframe.value, cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2).PassAs<cc::CCTimingFunction>()));
} }
WebTransformationMatrix WebTransformAnimationCurveImpl::getValue(double time) const WebTransformationMatrix WebTransformAnimationCurveImpl::getValue(double time) const
@@ -53,7 +53,7 @@ WebTransformationMatrix WebTransformAnimationCurveImpl::getValue(double time) co
return m_curve->getValue(time); return m_curve->getValue(time);
} }
PassOwnPtr<cc::CCAnimationCurve> WebTransformAnimationCurveImpl::cloneToCCAnimationCurve() const scoped_ptr<cc::CCAnimationCurve> WebTransformAnimationCurveImpl::cloneToCCAnimationCurve() const
{ {
return m_curve->clone(); return m_curve->clone();
} }

@@ -5,9 +5,8 @@
#ifndef WebTransformAnimationCurveImpl_h #ifndef WebTransformAnimationCurveImpl_h
#define WebTransformAnimationCurveImpl_h #define WebTransformAnimationCurveImpl_h
#include "base/memory/scoped_ptr.h"
#include <public/WebTransformAnimationCurve.h> #include <public/WebTransformAnimationCurve.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace cc { namespace cc {
class CCAnimationCurve; class CCAnimationCurve;
@@ -31,10 +30,10 @@ public:
virtual WebTransformationMatrix getValue(double time) const OVERRIDE; virtual WebTransformationMatrix getValue(double time) const OVERRIDE;
PassOwnPtr<cc::CCAnimationCurve> cloneToCCAnimationCurve() const; scoped_ptr<cc::CCAnimationCurve> cloneToCCAnimationCurve() const;
private: private:
OwnPtr<cc::CCKeyframedTransformAnimationCurve> m_curve; scoped_ptr<cc::CCKeyframedTransformAnimationCurve> m_curve;
}; };
} }

@@ -156,7 +156,7 @@ TEST(WebTransformAnimationCurveTest, EaseTimingFunction)
curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEase); curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEase);
curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41()); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
@@ -191,7 +191,7 @@ TEST(WebTransformAnimationCurveTest, EaseInTimingFunction)
curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseIn); curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseIn);
curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41()); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
@@ -209,7 +209,7 @@ TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction)
curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseOut); curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseOut);
curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41()); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
@@ -227,7 +227,7 @@ TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction)
curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseInOut); curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseInOut);
curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41()); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
@@ -249,7 +249,7 @@ TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction)
curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2); curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2);
curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2)); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunction::create(x1, y1, x2, y2));
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41()); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
@@ -267,7 +267,7 @@ TEST(WebTransformAnimationCurveTest, DefaultTimingFunction)
curve->add(WebTransformKeyframe(0, operations1)); curve->add(WebTransformKeyframe(0, operations1));
curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear); curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create()); scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create());
for (int i = 0; i <= 4; ++i) { for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25; const double time = i * 0.25;
EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41()); EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());