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

Side by Side Diff: cc/timing_function.cc

Issue 12517003: cc: Chromify the Animation and LayerAnimationController classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/timing_function.h ('k') | cc/timing_function_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/timing_function.h" 5 #include "cc/timing_function.h"
6 6
7 #include "third_party/skia/include/core/SkMath.h" 7 #include "third_party/skia/include/core/SkMath.h"
8 8
9 // TODO(danakj) These methods come from SkInterpolator.cpp. When such a method 9 // TODO(danakj) These methods come from SkInterpolator.cpp. When such a method
10 // is available in the public Skia API, we should switch to using that. 10 // is available in the public Skia API, we should switch to using that.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } // namespace 77 } // namespace
78 78
79 namespace cc { 79 namespace cc {
80 80
81 TimingFunction::TimingFunction() { 81 TimingFunction::TimingFunction() {
82 } 82 }
83 83
84 TimingFunction::~TimingFunction() { 84 TimingFunction::~TimingFunction() {
85 } 85 }
86 86
87 double TimingFunction::duration() const { 87 double TimingFunction::Duration() const {
88 return 1.0; 88 return 1.0;
89 } 89 }
90 90
91 scoped_ptr<CubicBezierTimingFunction> CubicBezierTimingFunction::create( 91 scoped_ptr<CubicBezierTimingFunction> CubicBezierTimingFunction::create(
92 double x1, double y1, double x2, double y2) { 92 double x1, double y1, double x2, double y2) {
93 return make_scoped_ptr(new CubicBezierTimingFunction(x1, y1, x2, y2)); 93 return make_scoped_ptr(new CubicBezierTimingFunction(x1, y1, x2, y2));
94 } 94 }
95 95
96 CubicBezierTimingFunction::CubicBezierTimingFunction(double x1, double y1, 96 CubicBezierTimingFunction::CubicBezierTimingFunction(double x1, double y1,
97 double x2, double y2) 97 double x2, double y2)
98 : x1_(SkDoubleToScalar(x1)), 98 : x1_(SkDoubleToScalar(x1)),
99 y1_(SkDoubleToScalar(y1)), 99 y1_(SkDoubleToScalar(y1)),
100 x2_(SkDoubleToScalar(x2)), 100 x2_(SkDoubleToScalar(x2)),
101 y2_(SkDoubleToScalar(y2)) { 101 y2_(SkDoubleToScalar(y2)) {
102 } 102 }
103 103
104 CubicBezierTimingFunction::~CubicBezierTimingFunction() { 104 CubicBezierTimingFunction::~CubicBezierTimingFunction() {
105 } 105 }
106 106
107 float CubicBezierTimingFunction::getValue(double x) const { 107 float CubicBezierTimingFunction::GetValue(double x) const {
108 SkScalar value = SkUnitCubicInterp(x1_, y1_, x2_, y2_, x); 108 SkScalar value = SkUnitCubicInterp(x1_, y1_, x2_, y2_, x);
109 return SkScalarToFloat(value); 109 return SkScalarToFloat(value);
110 } 110 }
111 111
112 scoped_ptr<AnimationCurve> CubicBezierTimingFunction::clone() const { 112 scoped_ptr<AnimationCurve> CubicBezierTimingFunction::Clone() const {
113 return make_scoped_ptr( 113 return make_scoped_ptr(
114 new CubicBezierTimingFunction(*this)).PassAs<AnimationCurve>(); 114 new CubicBezierTimingFunction(*this)).PassAs<AnimationCurve>();
115 } 115 }
116 116
117 // These numbers come from http://www.w3.org/TR/css3-transitions/#transition-tim ing-function_tag. 117 // These numbers come from
118 // http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag.
118 scoped_ptr<TimingFunction> EaseTimingFunction::create() { 119 scoped_ptr<TimingFunction> EaseTimingFunction::create() {
119 return CubicBezierTimingFunction::create( 120 return CubicBezierTimingFunction::create(
120 0.25, 0.1, 0.25, 1).PassAs<TimingFunction>(); 121 0.25, 0.1, 0.25, 1).PassAs<TimingFunction>();
121 } 122 }
122 123
123 scoped_ptr<TimingFunction> EaseInTimingFunction::create() { 124 scoped_ptr<TimingFunction> EaseInTimingFunction::create() {
124 return CubicBezierTimingFunction::create( 125 return CubicBezierTimingFunction::create(
125 0.42, 0, 1.0, 1).PassAs<TimingFunction>(); 126 0.42, 0, 1.0, 1).PassAs<TimingFunction>();
126 } 127 }
127 128
128 scoped_ptr<TimingFunction> EaseOutTimingFunction::create() { 129 scoped_ptr<TimingFunction> EaseOutTimingFunction::create() {
129 return CubicBezierTimingFunction::create( 130 return CubicBezierTimingFunction::create(
130 0, 0, 0.58, 1).PassAs<TimingFunction>(); 131 0, 0, 0.58, 1).PassAs<TimingFunction>();
131 } 132 }
132 133
133 scoped_ptr<TimingFunction> EaseInOutTimingFunction::create() { 134 scoped_ptr<TimingFunction> EaseInOutTimingFunction::create() {
134 return CubicBezierTimingFunction::create( 135 return CubicBezierTimingFunction::create(
135 0.42, 0, 0.58, 1).PassAs<TimingFunction>(); 136 0.42, 0, 0.58, 1).PassAs<TimingFunction>();
136 } 137 }
137 138
138 } // namespace cc 139 } // namespace cc
OLDNEW
« no previous file with comments | « cc/timing_function.h ('k') | cc/timing_function_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698