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 "cc/test/animation_test_common.h" | 5 #include "cc/test/animation_test_common.h" |
6 | 6 |
7 #include "cc/keyframed_animation_curve.h" | 7 #include "cc/keyframed_animation_curve.h" |
8 #include "cc/layer.h" | 8 #include "cc/layer.h" |
9 #include "cc/layer_animation_controller.h" | 9 #include "cc/layer_animation_controller.h" |
10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| 11 #include "cc/transform_operations.h" |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati
ons.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati
ons.h" |
12 | 13 |
13 using cc::Animation; | 14 using cc::Animation; |
14 using cc::AnimationCurve; | 15 using cc::AnimationCurve; |
15 using cc::EaseTimingFunction; | 16 using cc::EaseTimingFunction; |
16 using cc::FloatKeyframe; | 17 using cc::FloatKeyframe; |
17 using cc::KeyframedFloatAnimationCurve; | 18 using cc::KeyframedFloatAnimationCurve; |
18 using cc::KeyframedTransformAnimationCurve; | 19 using cc::KeyframedTransformAnimationCurve; |
19 using cc::TimingFunction; | 20 using cc::TimingFunction; |
20 using cc::TransformKeyframe; | 21 using cc::TransformKeyframe; |
(...skipping 21 matching lines...) Expand all Loading... |
42 | 43 |
43 target.addAnimation(animation.Pass()); | 44 target.addAnimation(animation.Pass()); |
44 return id; | 45 return id; |
45 } | 46 } |
46 | 47 |
47 template <class Target> | 48 template <class Target> |
48 int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY
) | 49 int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY
) |
49 { | 50 { |
50 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati
onCurve::create()); | 51 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati
onCurve::create()); |
51 | 52 |
| 53 #if WEB_TRANSFORM_OPERATIONS_IS_VIRTUAL |
| 54 if (duration > 0) { |
| 55 TransformOperations startOperations; |
| 56 startOperations.AppendTranslate(deltaX, deltaY, 0); |
| 57 curve->addKeyframe(TransformKeyframe::create(0, startOperations, scoped_
ptr<cc::TimingFunction>())); |
| 58 } |
| 59 |
| 60 TransformOperations operations; |
| 61 operations.AppendTranslate(deltaX, deltaY, 0); |
| 62 #else |
52 if (duration > 0) { | 63 if (duration > 0) { |
53 WebKit::WebTransformOperations startOperations; | 64 WebKit::WebTransformOperations startOperations; |
54 startOperations.appendTranslate(deltaX, deltaY, 0); | 65 startOperations.appendTranslate(deltaX, deltaY, 0); |
55 curve->addKeyframe(TransformKeyframe::create(0, startOperations, scoped_
ptr<cc::TimingFunction>())); | 66 curve->addKeyframe(TransformKeyframe::create(0, startOperations, scoped_
ptr<cc::TimingFunction>())); |
56 } | 67 } |
57 | 68 |
58 WebKit::WebTransformOperations operations; | 69 WebKit::WebTransformOperations operations; |
59 operations.appendTranslate(deltaX, deltaY, 0); | 70 operations.appendTranslate(deltaX, deltaY, 0); |
| 71 #endif |
60 curve->addKeyframe(TransformKeyframe::create(duration, operations, scoped_pt
r<cc::TimingFunction>())); | 72 curve->addKeyframe(TransformKeyframe::create(duration, operations, scoped_pt
r<cc::TimingFunction>())); |
61 | 73 |
62 int id = nextAnimationId++; | 74 int id = nextAnimationId++; |
63 | 75 |
64 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv
e>(), id, 0, Animation::Transform)); | 76 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv
e>(), id, 0, Animation::Transform)); |
65 animation->setNeedsSynchronizedStartTime(true); | 77 animation->setNeedsSynchronizedStartTime(true); |
66 | 78 |
67 target.addAnimation(animation.Pass()); | 79 target.addAnimation(animation.Pass()); |
68 return id; | 80 return id; |
69 } | 81 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 { | 211 { |
200 return addAnimatedTransform(layer, duration, deltaX, deltaY); | 212 return addAnimatedTransform(layer, duration, deltaX, deltaY); |
201 } | 213 } |
202 | 214 |
203 int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int delta
X, int deltaY) | 215 int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int delta
X, int deltaY) |
204 { | 216 { |
205 return addAnimatedTransform(*layer.layerAnimationController(), duration, del
taX, deltaY); | 217 return addAnimatedTransform(*layer.layerAnimationController(), duration, del
taX, deltaY); |
206 } | 218 } |
207 | 219 |
208 } // namespace cc | 220 } // namespace cc |
OLD | NEW |