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

Side by Side Diff: cc/animation/timing_function.cc

Issue 606543002: CC: Stop TimingFunction inheriting from AnimationCurve. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "cc/animation/timing_function.h" 6 #include "cc/animation/timing_function.h"
7 7
8 namespace cc { 8 namespace cc {
9 9
10 TimingFunction::TimingFunction() {} 10 TimingFunction::TimingFunction() {}
11 11
12 TimingFunction::~TimingFunction() {} 12 TimingFunction::~TimingFunction() {}
13 13
14 double TimingFunction::Duration() const {
15 return 1.0;
16 }
17
18 scoped_ptr<CubicBezierTimingFunction> CubicBezierTimingFunction::Create( 14 scoped_ptr<CubicBezierTimingFunction> CubicBezierTimingFunction::Create(
19 double x1, double y1, double x2, double y2) { 15 double x1, double y1, double x2, double y2) {
20 return make_scoped_ptr(new CubicBezierTimingFunction(x1, y1, x2, y2)); 16 return make_scoped_ptr(new CubicBezierTimingFunction(x1, y1, x2, y2));
21 } 17 }
22 18
23 CubicBezierTimingFunction::CubicBezierTimingFunction(double x1, 19 CubicBezierTimingFunction::CubicBezierTimingFunction(double x1,
24 double y1, 20 double y1,
25 double x2, 21 double x2,
26 double y2) 22 double y2)
27 : bezier_(x1, y1, x2, y2) {} 23 : bezier_(x1, y1, x2, y2) {}
28 24
29 CubicBezierTimingFunction::~CubicBezierTimingFunction() {} 25 CubicBezierTimingFunction::~CubicBezierTimingFunction() {}
30 26
31 float CubicBezierTimingFunction::GetValue(double x) const { 27 float CubicBezierTimingFunction::GetValue(double x) const {
32 return static_cast<float>(bezier_.Solve(x)); 28 return static_cast<float>(bezier_.Solve(x));
33 } 29 }
34 30
35 scoped_ptr<AnimationCurve> CubicBezierTimingFunction::Clone() const { 31 scoped_ptr<TimingFunction> CubicBezierTimingFunction::Clone() const {
36 return make_scoped_ptr( 32 return make_scoped_ptr(new CubicBezierTimingFunction(*this))
37 new CubicBezierTimingFunction(*this)).PassAs<AnimationCurve>(); 33 .PassAs<TimingFunction>();
38 } 34 }
39 35
40 void CubicBezierTimingFunction::Range(float* min, float* max) const { 36 void CubicBezierTimingFunction::Range(float* min, float* max) const {
41 double min_d = 0; 37 double min_d = 0;
42 double max_d = 1; 38 double max_d = 1;
43 bezier_.Range(&min_d, &max_d); 39 bezier_.Range(&min_d, &max_d);
44 *min = static_cast<float>(min_d); 40 *min = static_cast<float>(min_d);
45 *max = static_cast<float>(max_d); 41 *max = static_cast<float>(max_d);
46 } 42 }
47 43
(...skipping 17 matching lines...) Expand all
65 return CubicBezierTimingFunction::Create( 61 return CubicBezierTimingFunction::Create(
66 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>(); 62 0.0, 0.0, 0.58, 1.0).PassAs<TimingFunction>();
67 } 63 }
68 64
69 scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() { 65 scoped_ptr<TimingFunction> EaseInOutTimingFunction::Create() {
70 return CubicBezierTimingFunction::Create( 66 return CubicBezierTimingFunction::Create(
71 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>(); 67 0.42, 0.0, 0.58, 1).PassAs<TimingFunction>();
72 } 68 }
73 69
74 } // namespace cc 70 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698