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

Side by Side Diff: cc/CCTimingFunction.cpp

Issue 11085029: [cc] Use base ptr types for cc's CSS animation classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/CCTimingFunction.h ('k') | cc/LayerChromium.h » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "CCTimingFunction.h" 7 #include "CCTimingFunction.h"
8 8
9 #include <wtf/OwnPtr.h>
10
11 namespace { 9 namespace {
12 const double epsilon = 1e-6; 10 const double epsilon = 1e-6;
13 } // namespace 11 } // namespace
14 12
15 namespace cc { 13 namespace cc {
16 14
17 CCTimingFunction::CCTimingFunction() 15 CCTimingFunction::CCTimingFunction()
18 { 16 {
19 } 17 }
20 18
21 CCTimingFunction::~CCTimingFunction() 19 CCTimingFunction::~CCTimingFunction()
22 { 20 {
23 } 21 }
24 22
25 double CCTimingFunction::duration() const 23 double CCTimingFunction::duration() const
26 { 24 {
27 return 1.0; 25 return 1.0;
28 } 26 }
29 27
30 PassOwnPtr<CCCubicBezierTimingFunction> CCCubicBezierTimingFunction::create(doub le x1, double y1, double x2, double y2) 28 scoped_ptr<CCCubicBezierTimingFunction> CCCubicBezierTimingFunction::create(doub le x1, double y1, double x2, double y2)
31 { 29 {
32 return adoptPtr(new CCCubicBezierTimingFunction(x1, y1, x2, y2)); 30 return make_scoped_ptr(new CCCubicBezierTimingFunction(x1, y1, x2, y2));
33 } 31 }
34 32
35 CCCubicBezierTimingFunction::CCCubicBezierTimingFunction(double x1, double y1, d ouble x2, double y2) 33 CCCubicBezierTimingFunction::CCCubicBezierTimingFunction(double x1, double y1, d ouble x2, double y2)
36 : m_curve(x1, y1, x2, y2) 34 : m_curve(x1, y1, x2, y2)
37 { 35 {
38 } 36 }
39 37
40 CCCubicBezierTimingFunction::~CCCubicBezierTimingFunction() 38 CCCubicBezierTimingFunction::~CCCubicBezierTimingFunction()
41 { 39 {
42 } 40 }
43 41
44 float CCCubicBezierTimingFunction::getValue(double x) const 42 float CCCubicBezierTimingFunction::getValue(double x) const
45 { 43 {
46 UnitBezier temp(m_curve); 44 UnitBezier temp(m_curve);
47 return static_cast<float>(temp.solve(x, epsilon)); 45 return static_cast<float>(temp.solve(x, epsilon));
48 } 46 }
49 47
50 PassOwnPtr<CCAnimationCurve> CCCubicBezierTimingFunction::clone() const 48 scoped_ptr<CCAnimationCurve> CCCubicBezierTimingFunction::clone() const
51 { 49 {
52 return adoptPtr(new CCCubicBezierTimingFunction(*this)); 50 return make_scoped_ptr(new CCCubicBezierTimingFunction(*this)).PassAs<CCAnim ationCurve>();
53 } 51 }
54 52
55 // These numbers come from http://www.w3.org/TR/css3-transitions/#transition-tim ing-function_tag. 53 // These numbers come from http://www.w3.org/TR/css3-transitions/#transition-tim ing-function_tag.
56 PassOwnPtr<CCTimingFunction> CCEaseTimingFunction::create() 54 scoped_ptr<CCTimingFunction> CCEaseTimingFunction::create()
57 { 55 {
58 return CCCubicBezierTimingFunction::create(0.25, 0.1, 0.25, 1); 56 return CCCubicBezierTimingFunction::create(0.25, 0.1, 0.25, 1).PassAs<CCTimi ngFunction>();
59 } 57 }
60 58
61 PassOwnPtr<CCTimingFunction> CCEaseInTimingFunction::create() 59 scoped_ptr<CCTimingFunction> CCEaseInTimingFunction::create()
62 { 60 {
63 return CCCubicBezierTimingFunction::create(0.42, 0, 1.0, 1); 61 return CCCubicBezierTimingFunction::create(0.42, 0, 1.0, 1).PassAs<CCTimingF unction>();
64 } 62 }
65 63
66 PassOwnPtr<CCTimingFunction> CCEaseOutTimingFunction::create() 64 scoped_ptr<CCTimingFunction> CCEaseOutTimingFunction::create()
67 { 65 {
68 return CCCubicBezierTimingFunction::create(0, 0, 0.58, 1); 66 return CCCubicBezierTimingFunction::create(0, 0, 0.58, 1).PassAs<CCTimingFun ction>();
69 } 67 }
70 68
71 PassOwnPtr<CCTimingFunction> CCEaseInOutTimingFunction::create() 69 scoped_ptr<CCTimingFunction> CCEaseInOutTimingFunction::create()
72 { 70 {
73 return CCCubicBezierTimingFunction::create(0.42, 0, 0.58, 1); 71 return CCCubicBezierTimingFunction::create(0.42, 0, 0.58, 1).PassAs<CCTiming Function>();
74 } 72 }
75 73
76 } // namespace cc 74 } // namespace cc
OLDNEW
« no previous file with comments | « cc/CCTimingFunction.h ('k') | cc/LayerChromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698