OLD | NEW |
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 "CCAnimationTestCommon.h" | 7 #include "CCAnimationTestCommon.h" |
8 | 8 |
9 #include "CCKeyframedAnimationCurve.h" | 9 #include "CCKeyframedAnimationCurve.h" |
10 #include "CCLayerAnimationController.h" | 10 #include "CCLayerAnimationController.h" |
11 #include "CCLayerImpl.h" | 11 #include "CCLayerImpl.h" |
12 #include "LayerChromium.h" | 12 #include "LayerChromium.h" |
13 #include <public/WebTransformOperations.h> | 13 #include <public/WebTransformOperations.h> |
14 | 14 |
15 using namespace cc; | 15 using namespace cc; |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 template <class Target> | 19 template <class Target> |
20 void addOpacityTransition(Target& target, double duration, float startOpacity, f
loat endOpacity, bool useTimingFunction) | 20 void addOpacityTransition(Target& target, double duration, float startOpacity, f
loat endOpacity, bool useTimingFunction) |
21 { | 21 { |
22 OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve:
:create()); | 22 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); |
23 | 23 |
24 if (duration > 0) | 24 if (duration > 0) |
25 curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFun
ction ? nullptr : CCEaseTimingFunction::create())); | 25 curve->addKeyframe(CCFloatKeyframe::create(0, startOpacity, useTimingFun
ction ? scoped_ptr<CCTimingFunction>(): CCEaseTimingFunction::create())); |
26 curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, nullptr)); | 26 curve->addKeyframe(CCFloatKeyframe::create(duration, endOpacity, scoped_ptr<
cc::CCTimingFunction>())); |
27 | 27 |
28 OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(
), 0, 0, CCActiveAnimation::Opacity)); | 28 scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.Pass
As<CCAnimationCurve>(), 0, 0, CCActiveAnimation::Opacity)); |
29 animation->setNeedsSynchronizedStartTime(true); | 29 animation->setNeedsSynchronizedStartTime(true); |
30 | 30 |
31 target.addAnimation(animation.release()); | 31 target.addAnimation(animation.Pass()); |
32 } | 32 } |
33 | 33 |
34 template <class Target> | 34 template <class Target> |
35 void addAnimatedTransform(Target& target, double duration, int deltaX, int delta
Y) | 35 void addAnimatedTransform(Target& target, double duration, int deltaX, int delta
Y) |
36 { | 36 { |
37 static int id = 0; | 37 static int id = 0; |
38 OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimati
onCurve::create()); | 38 scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAni
mationCurve::create()); |
39 | 39 |
40 if (duration > 0) { | 40 if (duration > 0) { |
41 WebKit::WebTransformOperations startOperations; | 41 WebKit::WebTransformOperations startOperations; |
42 startOperations.appendTranslate(deltaX, deltaY, 0); | 42 startOperations.appendTranslate(deltaX, deltaY, 0); |
43 curve->addKeyframe(CCTransformKeyframe::create(0, startOperations, nullp
tr)); | 43 curve->addKeyframe(CCTransformKeyframe::create(0, startOperations, scope
d_ptr<cc::CCTimingFunction>())); |
44 } | 44 } |
45 | 45 |
46 WebKit::WebTransformOperations operations; | 46 WebKit::WebTransformOperations operations; |
47 operations.appendTranslate(deltaX, deltaY, 0); | 47 operations.appendTranslate(deltaX, deltaY, 0); |
48 curve->addKeyframe(CCTransformKeyframe::create(duration, operations, nullptr
)); | 48 curve->addKeyframe(CCTransformKeyframe::create(duration, operations, scoped_
ptr<cc::CCTimingFunction>())); |
49 | 49 |
50 OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(
), id++, 0, CCActiveAnimation::Transform)); | 50 scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.Pass
As<CCAnimationCurve>(), id++, 0, CCActiveAnimation::Transform)); |
51 animation->setNeedsSynchronizedStartTime(true); | 51 animation->setNeedsSynchronizedStartTime(true); |
52 | 52 |
53 target.addAnimation(animation.release()); | 53 target.addAnimation(animation.Pass()); |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 namespace WebKitTests { | 58 namespace WebKitTests { |
59 | 59 |
60 FakeFloatAnimationCurve::FakeFloatAnimationCurve() | 60 FakeFloatAnimationCurve::FakeFloatAnimationCurve() |
61 : m_duration(1) | 61 : m_duration(1) |
62 { | 62 { |
63 } | 63 } |
(...skipping 10 matching lines...) Expand all Loading... |
74 double FakeFloatAnimationCurve::duration() const | 74 double FakeFloatAnimationCurve::duration() const |
75 { | 75 { |
76 return m_duration; | 76 return m_duration; |
77 } | 77 } |
78 | 78 |
79 float FakeFloatAnimationCurve::getValue(double now) const | 79 float FakeFloatAnimationCurve::getValue(double now) const |
80 { | 80 { |
81 return 0; | 81 return 0; |
82 } | 82 } |
83 | 83 |
84 PassOwnPtr<cc::CCAnimationCurve> FakeFloatAnimationCurve::clone() const | 84 scoped_ptr<cc::CCAnimationCurve> FakeFloatAnimationCurve::clone() const |
85 { | 85 { |
86 return adoptPtr(new FakeFloatAnimationCurve); | 86 return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs<cc::CCAnimationCu
rve>(); |
87 } | 87 } |
88 | 88 |
89 FakeTransformTransition::FakeTransformTransition(double duration) | 89 FakeTransformTransition::FakeTransformTransition(double duration) |
90 : m_duration(duration) | 90 : m_duration(duration) |
91 { | 91 { |
92 } | 92 } |
93 | 93 |
94 FakeTransformTransition::~FakeTransformTransition() | 94 FakeTransformTransition::~FakeTransformTransition() |
95 { | 95 { |
96 } | 96 } |
97 | 97 |
98 double FakeTransformTransition::duration() const | 98 double FakeTransformTransition::duration() const |
99 { | 99 { |
100 return m_duration; | 100 return m_duration; |
101 } | 101 } |
102 | 102 |
103 WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) c
onst | 103 WebKit::WebTransformationMatrix FakeTransformTransition::getValue(double time) c
onst |
104 { | 104 { |
105 return WebKit::WebTransformationMatrix(); | 105 return WebKit::WebTransformationMatrix(); |
106 } | 106 } |
107 | 107 |
108 PassOwnPtr<cc::CCAnimationCurve> FakeTransformTransition::clone() const | 108 scoped_ptr<cc::CCAnimationCurve> FakeTransformTransition::clone() const |
109 { | 109 { |
110 return adoptPtr(new FakeTransformTransition(*this)); | 110 return make_scoped_ptr(new FakeTransformTransition(*this)).PassAs<cc::CCAnim
ationCurve>(); |
111 } | 111 } |
112 | 112 |
113 | 113 |
114 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) | 114 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) |
115 : m_duration(duration) | 115 : m_duration(duration) |
116 , m_from(from) | 116 , m_from(from) |
117 , m_to(to) | 117 , m_to(to) |
118 { | 118 { |
119 } | 119 } |
120 | 120 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void FakeLayerAnimationControllerClient::setTransformFromAnimation(const WebKit:
:WebTransformationMatrix& transform) | 162 void FakeLayerAnimationControllerClient::setTransformFromAnimation(const WebKit:
:WebTransformationMatrix& transform) |
163 { | 163 { |
164 m_transform = transform; | 164 m_transform = transform; |
165 } | 165 } |
166 | 166 |
167 const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::trans
form() const | 167 const WebKit::WebTransformationMatrix& FakeLayerAnimationControllerClient::trans
form() const |
168 { | 168 { |
169 return m_transform; | 169 return m_transform; |
170 } | 170 } |
171 | 171 |
172 PassOwnPtr<cc::CCAnimationCurve> FakeFloatTransition::clone() const | 172 scoped_ptr<cc::CCAnimationCurve> FakeFloatTransition::clone() const |
173 { | 173 { |
174 return adoptPtr(new FakeFloatTransition(*this)); | 174 return make_scoped_ptr(new FakeFloatTransition(*this)).PassAs<cc::CCAnimatio
nCurve>(); |
175 } | 175 } |
176 | 176 |
177 void addOpacityTransitionToController(cc::CCLayerAnimationController& controller
, double duration, float startOpacity, float endOpacity, bool useTimingFunction) | 177 void addOpacityTransitionToController(cc::CCLayerAnimationController& controller
, double duration, float startOpacity, float endOpacity, bool useTimingFunction) |
178 { | 178 { |
179 addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimi
ngFunction); | 179 addOpacityTransition(controller, duration, startOpacity, endOpacity, useTimi
ngFunction); |
180 } | 180 } |
181 | 181 |
182 void addAnimatedTransformToController(cc::CCLayerAnimationController& controller
, double duration, int deltaX, int deltaY) | 182 void addAnimatedTransformToController(cc::CCLayerAnimationController& controller
, double duration, int deltaX, int deltaY) |
183 { | 183 { |
184 addAnimatedTransform(controller, duration, deltaX, deltaY); | 184 addAnimatedTransform(controller, duration, deltaX, deltaY); |
(...skipping 13 matching lines...) Expand all Loading... |
198 { | 198 { |
199 addAnimatedTransform(layer, duration, deltaX, deltaY); | 199 addAnimatedTransform(layer, duration, deltaX, deltaY); |
200 } | 200 } |
201 | 201 |
202 void addAnimatedTransformToLayer(cc::CCLayerImpl& layer, double duration, int de
ltaX, int deltaY) | 202 void addAnimatedTransformToLayer(cc::CCLayerImpl& layer, double duration, int de
ltaX, int deltaY) |
203 { | 203 { |
204 addAnimatedTransform(*layer.layerAnimationController(), duration, deltaX, de
ltaY); | 204 addAnimatedTransform(*layer.layerAnimationController(), duration, deltaX, de
ltaY); |
205 } | 205 } |
206 | 206 |
207 } // namespace WebKitTests | 207 } // namespace WebKitTests |
OLD | NEW |