summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/animation/keyframed_animation_curve_unittest.cc2
-rw-r--r--cc/animation/timing_function.cc151
-rw-r--r--cc/animation/timing_function.h10
-rw-r--r--cc/animation/timing_function_unittest.cc2
-rw-r--r--cc/input/top_controls_manager.cc2
-rw-r--r--cc/test/animation_test_common.cc2
-rw-r--r--cc/trees/layer_tree_host_unittest_animation.cc2
-rw-r--r--cc/trees/layer_tree_impl.cc4
-rw-r--r--webkit/compositor_bindings/web_animation_curve_common.cc8
-rw-r--r--webkit/compositor_bindings/web_float_animation_curve_impl.cc2
-rw-r--r--webkit/compositor_bindings/web_float_animation_curve_unittest.cc12
-rw-r--r--webkit/compositor_bindings/web_transform_animation_curve_impl.cc2
12 files changed, 101 insertions, 98 deletions
diff --git a/cc/animation/keyframed_animation_curve_unittest.cc b/cc/animation/keyframed_animation_curve_unittest.cc
index dd7f869..1e2245f 100644
--- a/cc/animation/keyframed_animation_curve_unittest.cc
+++ b/cc/animation/keyframed_animation_curve_unittest.cc
@@ -225,7 +225,7 @@ TEST(KeyframedAnimationCurveTest, CubicBezierTimingFunction)
FloatKeyframe::Create(
0.f,
0,
- CubicBezierTimingFunction::create(
+ CubicBezierTimingFunction::Create(
0.25f, 0.f, 0.75f, 1.f).PassAs<TimingFunction>()));
curve->AddKeyframe(
FloatKeyframe::Create(1.0, 1.f, scoped_ptr<TimingFunction>()));
diff --git a/cc/animation/timing_function.cc b/cc/animation/timing_function.cc
index c0af3c2..769e9f0 100644
--- a/cc/animation/timing_function.cc
+++ b/cc/animation/timing_function.cc
@@ -13,96 +13,99 @@ namespace {
// Dot14 has 14 bits for decimal places, and the remainder for whole numbers.
typedef int Dot14;
-#define DOT14_ONE (1 << 14)
-#define DOT14_HALF (1 << 13)
-
-#define Dot14ToFloat(x) ((x) / 16384.f)
+#define DOT14_ONE (1 << 14)
+#define DOT14_HALF (1 << 13)
static inline Dot14 Dot14Mul(Dot14 a, Dot14 b) {
- return (a * b + DOT14_HALF) >> 14;
+ return (a * b + DOT14_HALF) >> 14;
}
static inline Dot14 EvalCubic(Dot14 t, Dot14 A, Dot14 B, Dot14 C) {
- return Dot14Mul(Dot14Mul(Dot14Mul(C, t) + B, t) + A, t);
+ return Dot14Mul(Dot14Mul(Dot14Mul(C, t) + B, t) + A, t);
}
static inline Dot14 PinAndConvert(SkScalar x) {
- if (x <= 0)
- return 0;
- if (x >= SK_Scalar1)
- return DOT14_ONE;
- return SkScalarToFixed(x) >> 2;
+ if (x <= 0)
+ return 0;
+ if (x >= SK_Scalar1)
+ return DOT14_ONE;
+ return SkScalarToFixed(x) >> 2;
}
-SkScalar SkUnitCubicInterp(SkScalar bx, SkScalar by,
- SkScalar cx, SkScalar cy,
+SkScalar SkUnitCubicInterp(SkScalar bx,
+ SkScalar by,
+ SkScalar cx,
+ SkScalar cy,
SkScalar value) {
- Dot14 x = PinAndConvert(value);
-
- if (x == 0) return 0;
- if (x == DOT14_ONE) return SK_Scalar1;
-
- Dot14 b = PinAndConvert(bx);
- Dot14 c = PinAndConvert(cx);
-
- // Now compute our coefficients from the control points.
- // t -> 3b
- // t^2 -> 3c - 6b
- // t^3 -> 3b - 3c + 1
- Dot14 A = 3 * b;
- Dot14 B = 3 * (c - 2 * b);
- Dot14 C = 3 * (b - c) + DOT14_ONE;
-
- // Now search for a t value given x.
- Dot14 t = DOT14_HALF;
- Dot14 dt = DOT14_HALF;
- for (int i = 0; i < 13; i++) {
- dt >>= 1;
- Dot14 guess = EvalCubic(t, A, B, C);
- if (x < guess)
- t -= dt;
- else
- t += dt;
- }
-
- // Now we have t, so compute the coefficient for Y and evaluate.
- b = PinAndConvert(by);
- c = PinAndConvert(cy);
- A = 3 * b;
- B = 3 * (c - 2 * b);
- C = 3 * (b - c) + DOT14_ONE;
- return SkFixedToScalar(EvalCubic(t, A, B, C) << 2);
+ Dot14 x = PinAndConvert(value);
+
+ if (x == 0)
+ return 0;
+ if (x == DOT14_ONE)
+ return SK_Scalar1;
+
+ Dot14 b = PinAndConvert(bx);
+ Dot14 c = PinAndConvert(cx);
+
+ // Now compute our coefficients from the control points.
+ // t -> 3b
+ // t^2 -> 3c - 6b
+ // t^3 -> 3b - 3c + 1
+ Dot14 A = 3 * b;
+ Dot14 B = 3 * (c - 2 * b);
+ Dot14 C = 3 * (b - c) + DOT14_ONE;
+
+ // Now search for a t value given x.
+ Dot14 t = DOT14_HALF;
+ Dot14 dt = DOT14_HALF;
+ for (int i = 0; i < 13; i++) {
+ dt >>= 1;
+ Dot14 guess = EvalCubic(t, A, B, C);
+ if (x < guess)
+ t -= dt;
+ else
+ t += dt;
+ }
+
+ // Now we have t, so compute the coefficient for Y and evaluate.
+ b = PinAndConvert(by);
+ c = PinAndConvert(cy);
+ A = 3 * b;
+ B = 3 * (c - 2 * b);
+ C = 3 * (b - c) + DOT14_ONE;
+ return SkFixedToScalar(EvalCubic(t, A, B, C) << 2);
}
} // namespace
namespace cc {
-TimingFunction::TimingFunction() {
-}
+TimingFunction::TimingFunction() {}
-TimingFunction::~TimingFunction() {
-}
+TimingFunction::~TimingFunction() {}
double TimingFunction::Duration() const {
- return 1.0;
+ return 1.0;
}
-scoped_ptr<CubicBezierTimingFunction> CubicBezierTimingFunction::create(
- double x1, double y1, double x2, double y2) {
- return make_scoped_ptr(new CubicBezierTimingFunction(x1, y1, x2, y2));
+scoped_ptr<CubicBezierTimingFunction> CubicBezierTimingFunction::Create(
+ double x1,
+ double y1,
+ double x2,
+ double y2) {
+ return make_scoped_ptr(new CubicBezierTimingFunction(x1, y1, x2, y2));
}
-CubicBezierTimingFunction::CubicBezierTimingFunction(double x1, double y1,
- double x2, double y2)
+CubicBezierTimingFunction::CubicBezierTimingFunction(double x1,
+ double y1,
+ double x2,
+ double y2)
: x1_(SkDoubleToScalar(x1)),
y1_(SkDoubleToScalar(y1)),
x2_(SkDoubleToScalar(x2)),
- y2_(SkDoubleToScalar(y2)) {
-}
+ y2_(SkDoubleToScalar(y2)) {}
-CubicBezierTimingFunction::~CubicBezierTimingFunction() {
-}
+CubicBezierTimingFunction::~CubicBezierTimingFunction() {}
float CubicBezierTimingFunction::GetValue(double x) const {
SkScalar value = SkUnitCubicInterp(x1_, y1_, x2_, y2_, x);
@@ -116,24 +119,24 @@ scoped_ptr<AnimationCurve> CubicBezierTimingFunction::Clone() const {
// These numbers come from
// http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag.
-scoped_ptr<TimingFunction> EaseTimingFunction::create() {
- return CubicBezierTimingFunction::create(
- 0.25, 0.1, 0.25, 1).PassAs<TimingFunction>();
+scoped_ptr<TimingFunction> EaseTimingFunction::Create() {
+ return CubicBezierTimingFunction::Create(
+ 0.25, 0.1, 0.25, 1.0).PassAs<TimingFunction>();
}
-scoped_ptr<TimingFunction> EaseInTimingFunction::create() {
- return CubicBezierTimingFunction::create(
- 0.42, 0, 1.0, 1).PassAs<TimingFunction>();
+scoped_ptr<TimingFunction> EaseInTimingFunction::Create() {
+ return CubicBezierTimingFunction::Create(
+ 0.42, 0.0, 1.0, 1.0).PassAs<TimingFunction>();
}
-scoped_ptr<TimingFunction> EaseOutTimingFunction::create() {
- return CubicBezierTimingFunction::create(
- 0, 0, 0.58, 1).PassAs<TimingFunction>();
+scoped_ptr<TimingFunction> EaseOutTimingFunction::Create() {
+ return CubicBezierTimingFunction::Create(
+ 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>();
}
-scoped_ptr<TimingFunction> EaseInOutTimingFunction::create() {
- return CubicBezierTimingFunction::create(
- 0.42, 0, 0.58, 1).PassAs<TimingFunction>();
+scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() {
+ return CubicBezierTimingFunction::Create(
+ 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>();
}
} // namespace cc
diff --git a/cc/animation/timing_function.h b/cc/animation/timing_function.h
index 3c88ecb..30cbd0d 100644
--- a/cc/animation/timing_function.h
+++ b/cc/animation/timing_function.h
@@ -25,7 +25,7 @@ class CC_EXPORT TimingFunction : public FloatAnimationCurve {
class CC_EXPORT CubicBezierTimingFunction : public TimingFunction {
public:
- static scoped_ptr<CubicBezierTimingFunction> create(double x1, double y1,
+ static scoped_ptr<CubicBezierTimingFunction> Create(double x1, double y1,
double x2, double y2);
virtual ~CubicBezierTimingFunction();
@@ -44,22 +44,22 @@ class CC_EXPORT CubicBezierTimingFunction : public TimingFunction {
class CC_EXPORT EaseTimingFunction {
public:
- static scoped_ptr<TimingFunction> create();
+ static scoped_ptr<TimingFunction> Create();
};
class CC_EXPORT EaseInTimingFunction {
public:
- static scoped_ptr<TimingFunction> create();
+ static scoped_ptr<TimingFunction> Create();
};
class CC_EXPORT EaseOutTimingFunction {
public:
- static scoped_ptr<TimingFunction> create();
+ static scoped_ptr<TimingFunction> Create();
};
class CC_EXPORT EaseInOutTimingFunction {
public:
- static scoped_ptr<TimingFunction> create();
+ static scoped_ptr<TimingFunction> Create();
};
} // namespace cc
diff --git a/cc/animation/timing_function_unittest.cc b/cc/animation/timing_function_unittest.cc
index f97201b..c076d52 100644
--- a/cc/animation/timing_function_unittest.cc
+++ b/cc/animation/timing_function_unittest.cc
@@ -11,7 +11,7 @@ namespace {
TEST(TimingFunctionTest, CubicBezierTimingFunction) {
scoped_ptr<CubicBezierTimingFunction> function =
- CubicBezierTimingFunction::create(0.25, 0, 0.75, 1);
+ CubicBezierTimingFunction::Create(0.25, 0.0, 0.75, 1.0);
double epsilon = 0.00015;
diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc
index a0ea636..e1698f1 100644
--- a/cc/input/top_controls_manager.cc
+++ b/cc/input/top_controls_manager.cc
@@ -148,7 +148,7 @@ void TopControlsManager::SetupAnimation(AnimationDirection direction) {
top_controls_animation_->AddKeyframe(
FloatKeyframe::Create(start_time + kShowHideMaxDurationMs,
controls_top_offset_ + max_ending_offset,
- EaseTimingFunction::create()));
+ EaseTimingFunction::Create()));
animation_direction_ = direction;
}
diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc
index 47f4ca7..9c025f2 100644
--- a/cc/test/animation_test_common.cc
+++ b/cc/test/animation_test_common.cc
@@ -34,7 +34,7 @@ int AddOpacityTransition(Target* target,
scoped_ptr<TimingFunction> func;
if (!useTimingFunction)
- func = EaseTimingFunction::create();
+ func = EaseTimingFunction::Create();
if (duration > 0.0)
curve->AddKeyframe(FloatKeyframe::Create(0.0, startOpacity, func.Pass()));
curve->AddKeyframe(FloatKeyframe::Create(duration,
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index cfde40b..78f1a6e 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -424,7 +424,7 @@ class LayerTreeHostAnimationTestLayerAddedWithAnimation :
layer->set_layer_animation_delegate(this);
// Any valid AnimationCurve will do here.
- scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create());
+ scoped_ptr<AnimationCurve> curve(EaseTimingFunction::Create());
scoped_ptr<Animation> animation(
Animation::Create(curve.Pass(), 1, 1,
Animation::Opacity));
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index d1b8ded..95d2291 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -603,10 +603,10 @@ static scoped_ptr<Animation> MakePinchZoomFadeAnimation(
scoped_ptr<KeyframedFloatAnimationCurve> curve =
KeyframedFloatAnimationCurve::Create();
curve->AddKeyframe(FloatKeyframe::Create(
- 0, start_opacity, EaseInTimingFunction::create()));
+ 0, start_opacity, EaseInTimingFunction::Create()));
curve->AddKeyframe(FloatKeyframe::Create(
PinchZoomScrollbar::kFadeDurationInSeconds, end_opacity,
- EaseInTimingFunction::create()));
+ EaseInTimingFunction::Create()));
scoped_ptr<Animation> animation = Animation::Create(
curve.PassAs<AnimationCurve>(), AnimationIdProvider::NextAnimationId(),
diff --git a/webkit/compositor_bindings/web_animation_curve_common.cc b/webkit/compositor_bindings/web_animation_curve_common.cc
index 914348b..fedf8f8 100644
--- a/webkit/compositor_bindings/web_animation_curve_common.cc
+++ b/webkit/compositor_bindings/web_animation_curve_common.cc
@@ -12,13 +12,13 @@ scoped_ptr<cc::TimingFunction> CreateTimingFunction(
WebKit::WebAnimationCurve::TimingFunctionType type) {
switch (type) {
case WebKit::WebAnimationCurve::TimingFunctionTypeEase:
- return cc::EaseTimingFunction::create();
+ return cc::EaseTimingFunction::Create();
case WebKit::WebAnimationCurve::TimingFunctionTypeEaseIn:
- return cc::EaseInTimingFunction::create();
+ return cc::EaseInTimingFunction::Create();
case WebKit::WebAnimationCurve::TimingFunctionTypeEaseOut:
- return cc::EaseOutTimingFunction::create();
+ return cc::EaseOutTimingFunction::Create();
case WebKit::WebAnimationCurve::TimingFunctionTypeEaseInOut:
- return cc::EaseInOutTimingFunction::create();
+ return cc::EaseInOutTimingFunction::Create();
case WebKit::WebAnimationCurve::TimingFunctionTypeLinear:
return scoped_ptr<cc::TimingFunction>();
}
diff --git a/webkit/compositor_bindings/web_float_animation_curve_impl.cc b/webkit/compositor_bindings/web_float_animation_curve_impl.cc
index 5d13564..99fbe47 100644
--- a/webkit/compositor_bindings/web_float_animation_curve_impl.cc
+++ b/webkit/compositor_bindings/web_float_animation_curve_impl.cc
@@ -41,7 +41,7 @@ void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe,
curve_->AddKeyframe(cc::FloatKeyframe::Create(
keyframe.time,
keyframe.value,
- cc::CubicBezierTimingFunction::create(x1, y1, x2, y2)
+ cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
.PassAs<cc::TimingFunction>()));
}
diff --git a/webkit/compositor_bindings/web_float_animation_curve_unittest.cc b/webkit/compositor_bindings/web_float_animation_curve_unittest.cc
index 3910a3c..c59ff28 100644
--- a/webkit/compositor_bindings/web_float_animation_curve_unittest.cc
+++ b/webkit/compositor_bindings/web_float_animation_curve_unittest.cc
@@ -126,7 +126,7 @@ TEST(WebFloatAnimationCurveTest, EaseTimingFunction) {
WebAnimationCurve::TimingFunctionTypeLinear);
scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseTimingFunction::create());
+ cc::EaseTimingFunction::Create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
@@ -156,7 +156,7 @@ TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) {
WebAnimationCurve::TimingFunctionTypeLinear);
scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseInTimingFunction::create());
+ cc::EaseInTimingFunction::Create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
@@ -172,7 +172,7 @@ TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) {
WebAnimationCurve::TimingFunctionTypeLinear);
scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseOutTimingFunction::create());
+ cc::EaseOutTimingFunction::Create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
@@ -188,7 +188,7 @@ TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) {
WebAnimationCurve::TimingFunctionTypeLinear);
scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseInOutTimingFunction::create());
+ cc::EaseInOutTimingFunction::Create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
@@ -207,7 +207,7 @@ TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) {
WebAnimationCurve::TimingFunctionTypeLinear);
scoped_ptr<cc::TimingFunction> timing_function(
- cc::CubicBezierTimingFunction::create(x1, y1, x2, y2));
+ cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2));
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
@@ -222,7 +222,7 @@ TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) {
WebAnimationCurve::TimingFunctionTypeLinear);
scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseTimingFunction::create());
+ cc::EaseTimingFunction::Create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
diff --git a/webkit/compositor_bindings/web_transform_animation_curve_impl.cc b/webkit/compositor_bindings/web_transform_animation_curve_impl.cc
index 52f2f54..9ce8605 100644
--- a/webkit/compositor_bindings/web_transform_animation_curve_impl.cc
+++ b/webkit/compositor_bindings/web_transform_animation_curve_impl.cc
@@ -48,7 +48,7 @@ void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe,
curve_->AddKeyframe(cc::TransformKeyframe::Create(
keyframe.time(),
transform_operations,
- cc::CubicBezierTimingFunction::create(x1, y1, x2, y2)
+ cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
.PassAs<cc::TimingFunction>()));
}