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

Unified Diff: cc/animation/keyframed_animation_curve.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
« no previous file with comments | « cc/animation/keyframed_animation_curve.h ('k') | cc/animation/keyframed_animation_curve_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/keyframed_animation_curve.cc
diff --git a/cc/animation/keyframed_animation_curve.cc b/cc/animation/keyframed_animation_curve.cc
index a8dd9bdaa65153f059639006b2de09ec9be7c1f1..061d48e23a8f71524c80bc95c98fadebe281fd83 100644
--- a/cc/animation/keyframed_animation_curve.cc
+++ b/cc/animation/keyframed_animation_curve.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "cc/animation/keyframed_animation_curve.h"
+
#include <stddef.h>
#include <algorithm>
-#include "cc/animation/keyframed_animation_curve.h"
+#include "base/memory/ptr_util.h"
#include "cc/base/time_util.h"
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/geometry/box_f.h"
@@ -16,8 +18,8 @@ namespace cc {
namespace {
template <class KeyframeType>
-void InsertKeyframe(scoped_ptr<KeyframeType> keyframe,
- std::vector<scoped_ptr<KeyframeType>>* keyframes) {
+void InsertKeyframe(std::unique_ptr<KeyframeType> keyframe,
+ std::vector<std::unique_ptr<KeyframeType>>* 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()) {
@@ -34,8 +36,8 @@ void InsertKeyframe(scoped_ptr<KeyframeType> keyframe,
template <typename KeyframeType>
base::TimeDelta TransformedAnimationTime(
- const std::vector<scoped_ptr<KeyframeType>>& keyframes,
- const scoped_ptr<TimingFunction>& timing_function,
+ const std::vector<std::unique_ptr<KeyframeType>>& keyframes,
+ const std::unique_ptr<TimingFunction>& timing_function,
base::TimeDelta time) {
if (timing_function) {
base::TimeDelta start_time = keyframes.front()->Time();
@@ -51,8 +53,9 @@ base::TimeDelta TransformedAnimationTime(
}
template <typename KeyframeType>
-size_t GetActiveKeyframe(const std::vector<scoped_ptr<KeyframeType>>& keyframes,
- base::TimeDelta time) {
+size_t GetActiveKeyframe(
+ const std::vector<std::unique_ptr<KeyframeType>>& keyframes,
+ base::TimeDelta time) {
DCHECK_GE(keyframes.size(), 2ul);
size_t i = 0;
for (; i < keyframes.size() - 2; ++i) { // Last keyframe is never active.
@@ -65,7 +68,7 @@ size_t GetActiveKeyframe(const std::vector<scoped_ptr<KeyframeType>>& keyframes,
template <typename KeyframeType>
double TransformedKeyframeProgress(
- const std::vector<scoped_ptr<KeyframeType>>& keyframes,
+ const std::vector<std::unique_ptr<KeyframeType>>& keyframes,
base::TimeDelta time,
size_t i) {
double progress =
@@ -82,7 +85,7 @@ double TransformedKeyframeProgress(
} // namespace
Keyframe::Keyframe(base::TimeDelta time,
- scoped_ptr<TimingFunction> timing_function)
+ std::unique_ptr<TimingFunction> timing_function)
: time_(time), timing_function_(std::move(timing_function)) {}
Keyframe::~Keyframe() {}
@@ -91,41 +94,41 @@ base::TimeDelta Keyframe::Time() const {
return time_;
}
-scoped_ptr<ColorKeyframe> ColorKeyframe::Create(
+std::unique_ptr<ColorKeyframe> ColorKeyframe::Create(
base::TimeDelta time,
SkColor value,
- scoped_ptr<TimingFunction> timing_function) {
- return make_scoped_ptr(
+ std::unique_ptr<TimingFunction> timing_function) {
+ return base::WrapUnique(
new ColorKeyframe(time, value, std::move(timing_function)));
}
ColorKeyframe::ColorKeyframe(base::TimeDelta time,
SkColor value,
- scoped_ptr<TimingFunction> timing_function)
+ std::unique_ptr<TimingFunction> timing_function)
: Keyframe(time, std::move(timing_function)), value_(value) {}
ColorKeyframe::~ColorKeyframe() {}
SkColor ColorKeyframe::Value() const { return value_; }
-scoped_ptr<ColorKeyframe> ColorKeyframe::Clone() const {
- scoped_ptr<TimingFunction> func;
+std::unique_ptr<ColorKeyframe> ColorKeyframe::Clone() const {
+ std::unique_ptr<TimingFunction> func;
if (timing_function())
func = timing_function()->Clone();
return ColorKeyframe::Create(Time(), Value(), std::move(func));
}
-scoped_ptr<FloatKeyframe> FloatKeyframe::Create(
+std::unique_ptr<FloatKeyframe> FloatKeyframe::Create(
base::TimeDelta time,
float value,
- scoped_ptr<TimingFunction> timing_function) {
- return make_scoped_ptr(
+ std::unique_ptr<TimingFunction> timing_function) {
+ return base::WrapUnique(
new FloatKeyframe(time, value, std::move(timing_function)));
}
FloatKeyframe::FloatKeyframe(base::TimeDelta time,
float value,
- scoped_ptr<TimingFunction> timing_function)
+ std::unique_ptr<TimingFunction> timing_function)
: Keyframe(time, std::move(timing_function)), value_(value) {}
FloatKeyframe::~FloatKeyframe() {}
@@ -134,24 +137,25 @@ float FloatKeyframe::Value() const {
return value_;
}
-scoped_ptr<FloatKeyframe> FloatKeyframe::Clone() const {
- scoped_ptr<TimingFunction> func;
+std::unique_ptr<FloatKeyframe> FloatKeyframe::Clone() const {
+ std::unique_ptr<TimingFunction> func;
if (timing_function())
func = timing_function()->Clone();
return FloatKeyframe::Create(Time(), Value(), std::move(func));
}
-scoped_ptr<TransformKeyframe> TransformKeyframe::Create(
+std::unique_ptr<TransformKeyframe> TransformKeyframe::Create(
base::TimeDelta time,
const TransformOperations& value,
- scoped_ptr<TimingFunction> timing_function) {
- return make_scoped_ptr(
+ std::unique_ptr<TimingFunction> timing_function) {
+ return base::WrapUnique(
new TransformKeyframe(time, value, std::move(timing_function)));
}
-TransformKeyframe::TransformKeyframe(base::TimeDelta time,
- const TransformOperations& value,
- scoped_ptr<TimingFunction> timing_function)
+TransformKeyframe::TransformKeyframe(
+ base::TimeDelta time,
+ const TransformOperations& value,
+ std::unique_ptr<TimingFunction> timing_function)
: Keyframe(time, std::move(timing_function)), value_(value) {}
TransformKeyframe::~TransformKeyframe() {}
@@ -160,24 +164,24 @@ const TransformOperations& TransformKeyframe::Value() const {
return value_;
}
-scoped_ptr<TransformKeyframe> TransformKeyframe::Clone() const {
- scoped_ptr<TimingFunction> func;
+std::unique_ptr<TransformKeyframe> TransformKeyframe::Clone() const {
+ std::unique_ptr<TimingFunction> func;
if (timing_function())
func = timing_function()->Clone();
return TransformKeyframe::Create(Time(), Value(), std::move(func));
}
-scoped_ptr<FilterKeyframe> FilterKeyframe::Create(
+std::unique_ptr<FilterKeyframe> FilterKeyframe::Create(
base::TimeDelta time,
const FilterOperations& value,
- scoped_ptr<TimingFunction> timing_function) {
- return make_scoped_ptr(
+ std::unique_ptr<TimingFunction> timing_function) {
+ return base::WrapUnique(
new FilterKeyframe(time, value, std::move(timing_function)));
}
FilterKeyframe::FilterKeyframe(base::TimeDelta time,
const FilterOperations& value,
- scoped_ptr<TimingFunction> timing_function)
+ std::unique_ptr<TimingFunction> timing_function)
: Keyframe(time, std::move(timing_function)), value_(value) {}
FilterKeyframe::~FilterKeyframe() {}
@@ -186,16 +190,16 @@ const FilterOperations& FilterKeyframe::Value() const {
return value_;
}
-scoped_ptr<FilterKeyframe> FilterKeyframe::Clone() const {
- scoped_ptr<TimingFunction> func;
+std::unique_ptr<FilterKeyframe> FilterKeyframe::Clone() const {
+ std::unique_ptr<TimingFunction> func;
if (timing_function())
func = timing_function()->Clone();
return FilterKeyframe::Create(Time(), Value(), std::move(func));
}
-scoped_ptr<KeyframedColorAnimationCurve> KeyframedColorAnimationCurve::
- Create() {
- return make_scoped_ptr(new KeyframedColorAnimationCurve);
+std::unique_ptr<KeyframedColorAnimationCurve>
+KeyframedColorAnimationCurve::Create() {
+ return base::WrapUnique(new KeyframedColorAnimationCurve);
}
KeyframedColorAnimationCurve::KeyframedColorAnimationCurve() {}
@@ -203,7 +207,7 @@ KeyframedColorAnimationCurve::KeyframedColorAnimationCurve() {}
KeyframedColorAnimationCurve::~KeyframedColorAnimationCurve() {}
void KeyframedColorAnimationCurve::AddKeyframe(
- scoped_ptr<ColorKeyframe> keyframe) {
+ std::unique_ptr<ColorKeyframe> keyframe) {
InsertKeyframe(std::move(keyframe), &keyframes_);
}
@@ -211,8 +215,8 @@ base::TimeDelta KeyframedColorAnimationCurve::Duration() const {
return keyframes_.back()->Time() - keyframes_.front()->Time();
}
-scoped_ptr<AnimationCurve> KeyframedColorAnimationCurve::Clone() const {
- scoped_ptr<KeyframedColorAnimationCurve> to_return =
+std::unique_ptr<AnimationCurve> KeyframedColorAnimationCurve::Clone() const {
+ std::unique_ptr<KeyframedColorAnimationCurve> to_return =
KeyframedColorAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
@@ -240,9 +244,9 @@ SkColor KeyframedColorAnimationCurve::GetValue(base::TimeDelta t) const {
// KeyframedFloatAnimationCurve
-scoped_ptr<KeyframedFloatAnimationCurve> KeyframedFloatAnimationCurve::
- Create() {
- return make_scoped_ptr(new KeyframedFloatAnimationCurve);
+std::unique_ptr<KeyframedFloatAnimationCurve>
+KeyframedFloatAnimationCurve::Create() {
+ return base::WrapUnique(new KeyframedFloatAnimationCurve);
}
KeyframedFloatAnimationCurve::KeyframedFloatAnimationCurve() {}
@@ -250,7 +254,7 @@ KeyframedFloatAnimationCurve::KeyframedFloatAnimationCurve() {}
KeyframedFloatAnimationCurve::~KeyframedFloatAnimationCurve() {}
void KeyframedFloatAnimationCurve::AddKeyframe(
- scoped_ptr<FloatKeyframe> keyframe) {
+ std::unique_ptr<FloatKeyframe> keyframe) {
InsertKeyframe(std::move(keyframe), &keyframes_);
}
@@ -258,8 +262,8 @@ base::TimeDelta KeyframedFloatAnimationCurve::Duration() const {
return keyframes_.back()->Time() - keyframes_.front()->Time();
}
-scoped_ptr<AnimationCurve> KeyframedFloatAnimationCurve::Clone() const {
- scoped_ptr<KeyframedFloatAnimationCurve> to_return =
+std::unique_ptr<AnimationCurve> KeyframedFloatAnimationCurve::Clone() const {
+ std::unique_ptr<KeyframedFloatAnimationCurve> to_return =
KeyframedFloatAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
@@ -285,9 +289,9 @@ float KeyframedFloatAnimationCurve::GetValue(base::TimeDelta t) const {
(keyframes_[i+1]->Value() - keyframes_[i]->Value()) * progress;
}
-scoped_ptr<KeyframedTransformAnimationCurve> KeyframedTransformAnimationCurve::
- Create() {
- return make_scoped_ptr(new KeyframedTransformAnimationCurve);
+std::unique_ptr<KeyframedTransformAnimationCurve>
+KeyframedTransformAnimationCurve::Create() {
+ return base::WrapUnique(new KeyframedTransformAnimationCurve);
}
KeyframedTransformAnimationCurve::KeyframedTransformAnimationCurve() {}
@@ -295,7 +299,7 @@ KeyframedTransformAnimationCurve::KeyframedTransformAnimationCurve() {}
KeyframedTransformAnimationCurve::~KeyframedTransformAnimationCurve() {}
void KeyframedTransformAnimationCurve::AddKeyframe(
- scoped_ptr<TransformKeyframe> keyframe) {
+ std::unique_ptr<TransformKeyframe> keyframe) {
InsertKeyframe(std::move(keyframe), &keyframes_);
}
@@ -303,8 +307,9 @@ base::TimeDelta KeyframedTransformAnimationCurve::Duration() const {
return keyframes_.back()->Time() - keyframes_.front()->Time();
}
-scoped_ptr<AnimationCurve> KeyframedTransformAnimationCurve::Clone() const {
- scoped_ptr<KeyframedTransformAnimationCurve> to_return =
+std::unique_ptr<AnimationCurve> KeyframedTransformAnimationCurve::Clone()
+ const {
+ std::unique_ptr<KeyframedTransformAnimationCurve> to_return =
KeyframedTransformAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
@@ -425,9 +430,9 @@ bool KeyframedTransformAnimationCurve::MaximumTargetScale(
return true;
}
-scoped_ptr<KeyframedFilterAnimationCurve> KeyframedFilterAnimationCurve::
- Create() {
- return make_scoped_ptr(new KeyframedFilterAnimationCurve);
+std::unique_ptr<KeyframedFilterAnimationCurve>
+KeyframedFilterAnimationCurve::Create() {
+ return base::WrapUnique(new KeyframedFilterAnimationCurve);
}
KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {}
@@ -435,7 +440,7 @@ KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {}
KeyframedFilterAnimationCurve::~KeyframedFilterAnimationCurve() {}
void KeyframedFilterAnimationCurve::AddKeyframe(
- scoped_ptr<FilterKeyframe> keyframe) {
+ std::unique_ptr<FilterKeyframe> keyframe) {
InsertKeyframe(std::move(keyframe), &keyframes_);
}
@@ -443,8 +448,8 @@ base::TimeDelta KeyframedFilterAnimationCurve::Duration() const {
return keyframes_.back()->Time() - keyframes_.front()->Time();
}
-scoped_ptr<AnimationCurve> KeyframedFilterAnimationCurve::Clone() const {
- scoped_ptr<KeyframedFilterAnimationCurve> to_return =
+std::unique_ptr<AnimationCurve> KeyframedFilterAnimationCurve::Clone() const {
+ std::unique_ptr<KeyframedFilterAnimationCurve> to_return =
KeyframedFilterAnimationCurve::Create();
for (size_t i = 0; i < keyframes_.size(); ++i)
to_return->AddKeyframe(keyframes_[i]->Clone());
« no previous file with comments | « cc/animation/keyframed_animation_curve.h ('k') | cc/animation/keyframed_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698