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

Unified Diff: cc/animation/keyframed_animation_curve.cc

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: no-base-changes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/animation/keyframed_animation_curve.cc
diff --git a/cc/animation/keyframed_animation_curve.cc b/cc/animation/keyframed_animation_curve.cc
index e98a2e6945dbbf3c8a2f36fcac1ca2ffce79ff06..f4e9e2732d2645aff46ba890ec2c1c7eda34cfbc 100644
--- a/cc/animation/keyframed_animation_curve.cc
+++ b/cc/animation/keyframed_animation_curve.cc
@@ -14,19 +14,19 @@ namespace {
template <class Keyframe>
void InsertKeyframe(scoped_ptr<Keyframe> keyframe,
- ScopedPtrVector<Keyframe>& keyframes) {
+ ScopedPtrVector<Keyframe>* keyframes) {
// Usually, the keyframes will be added in order, so this loop would be
// unnecessary and we should skip it if possible.
- if (!keyframes.empty() && keyframe->Time() < keyframes.back()->Time()) {
- for (size_t i = 0; i < keyframes.size(); ++i) {
- if (keyframe->Time() < keyframes[i]->Time()) {
- keyframes.insert(keyframes.begin() + i, keyframe.Pass());
+ if (!keyframes->empty() && keyframe->Time() < keyframes->back()->Time()) {
+ for (size_t i = 0; i < keyframes->size(); ++i) {
+ if (keyframe->Time() < keyframes->at(i)->Time()) {
+ keyframes->insert(keyframes->begin() + i, keyframe.Pass());
return;
}
}
}
- keyframes.push_back(keyframe.Pass());
+ keyframes->push_back(keyframe.Pass());
}
template <class Keyframes>
@@ -169,7 +169,7 @@ KeyframedColorAnimationCurve::~KeyframedColorAnimationCurve() {}
void KeyframedColorAnimationCurve::AddKeyframe(
scoped_ptr<ColorKeyframe> keyframe) {
- InsertKeyframe(keyframe.Pass(), keyframes_);
+ InsertKeyframe(keyframe.Pass(), &keyframes_);
}
double KeyframedColorAnimationCurve::Duration() const {
@@ -177,11 +177,11 @@ double KeyframedColorAnimationCurve::Duration() const {
}
scoped_ptr<AnimationCurve> KeyframedColorAnimationCurve::Clone() const {
- scoped_ptr<KeyframedColorAnimationCurve> to_return(
- KeyframedColorAnimationCurve::Create());
+ scoped_ptr<KeyframedColorAnimationCurve> to_return =
+ KeyframedColorAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
- return to_return.PassAs<AnimationCurve>();
+ return to_return.Pass();
}
SkColor KeyframedColorAnimationCurve::GetValue(double t) const {
@@ -216,7 +216,7 @@ KeyframedFloatAnimationCurve::~KeyframedFloatAnimationCurve() {}
void KeyframedFloatAnimationCurve::AddKeyframe(
scoped_ptr<FloatKeyframe> keyframe) {
- InsertKeyframe(keyframe.Pass(), keyframes_);
+ InsertKeyframe(keyframe.Pass(), &keyframes_);
}
double KeyframedFloatAnimationCurve::Duration() const {
@@ -224,11 +224,11 @@ double KeyframedFloatAnimationCurve::Duration() const {
}
scoped_ptr<AnimationCurve> KeyframedFloatAnimationCurve::Clone() const {
- scoped_ptr<KeyframedFloatAnimationCurve> to_return(
- KeyframedFloatAnimationCurve::Create());
+ scoped_ptr<KeyframedFloatAnimationCurve> to_return =
+ KeyframedFloatAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
- return to_return.PassAs<AnimationCurve>();
+ return to_return.Pass();
}
float KeyframedFloatAnimationCurve::GetValue(double t) const {
@@ -261,7 +261,7 @@ KeyframedTransformAnimationCurve::~KeyframedTransformAnimationCurve() {}
void KeyframedTransformAnimationCurve::AddKeyframe(
scoped_ptr<TransformKeyframe> keyframe) {
- InsertKeyframe(keyframe.Pass(), keyframes_);
+ InsertKeyframe(keyframe.Pass(), &keyframes_);
}
double KeyframedTransformAnimationCurve::Duration() const {
@@ -269,11 +269,11 @@ double KeyframedTransformAnimationCurve::Duration() const {
}
scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::Clone() const {
- scoped_ptr<KeyframedTransformAnimationCurve> to_return(
vmpstr 2014/09/26 16:44:23 Are we not allowing this type of constructor eithe
danakj 2014/09/26 16:56:44 No, it's fine, I just think following matching ()
- KeyframedTransformAnimationCurve::Create());
+ scoped_ptr<KeyframedTransformAnimationCurve> to_return =
+ KeyframedTransformAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
- return to_return.PassAs<AnimationCurve>();
+ return to_return.Pass();
}
// Assumes that (*keyframes).front()->Time() < t < (*keyframes).back()-Time().
@@ -376,7 +376,7 @@ KeyframedFilterAnimationCurve::~KeyframedFilterAnimationCurve() {}
void KeyframedFilterAnimationCurve::AddKeyframe(
scoped_ptr<FilterKeyframe> keyframe) {
- InsertKeyframe(keyframe.Pass(), keyframes_);
+ InsertKeyframe(keyframe.Pass(), &keyframes_);
}
double KeyframedFilterAnimationCurve::Duration() const {
@@ -384,11 +384,11 @@ double KeyframedFilterAnimationCurve::Duration() const {
}
scoped_ptr<AnimationCurve> KeyframedFilterAnimationCurve::Clone() const {
- scoped_ptr<KeyframedFilterAnimationCurve> to_return(
- KeyframedFilterAnimationCurve::Create());
+ scoped_ptr<KeyframedFilterAnimationCurve> to_return =
+ KeyframedFilterAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
- return to_return.PassAs<AnimationCurve>();
+ return to_return.Pass();
}
FilterOperations KeyframedFilterAnimationCurve::GetValue(double t) const {

Powered by Google App Engine
This is Rietveld 408576698