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

Side by Side Diff: cc/test/animation_test_common.cc

Issue 11636051: Rename ActiveAnimation -> Animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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/test/animation_test_common.h ('k') | cc/test/layer_tree_test_common.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/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 "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati ons.h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati ons.h"
12 12
13 using cc::ActiveAnimation; 13 using cc::Animation;
14 using cc::AnimationCurve; 14 using cc::AnimationCurve;
15 using cc::EaseTimingFunction; 15 using cc::EaseTimingFunction;
16 using cc::FloatKeyframe; 16 using cc::FloatKeyframe;
17 using cc::KeyframedFloatAnimationCurve; 17 using cc::KeyframedFloatAnimationCurve;
18 using cc::KeyframedTransformAnimationCurve; 18 using cc::KeyframedTransformAnimationCurve;
19 using cc::TimingFunction; 19 using cc::TimingFunction;
20 using cc::TransformKeyframe; 20 using cc::TransformKeyframe;
21 21
22 namespace cc { 22 namespace cc {
23 23
24 static int nextAnimationId = 0; 24 static int nextAnimationId = 0;
25 25
26 template <class Target> 26 template <class Target>
27 int addOpacityTransition(Target& target, double duration, float startOpacity, fl oat endOpacity, bool useTimingFunction) 27 int addOpacityTransition(Target& target, double duration, float startOpacity, fl oat endOpacity, bool useTimingFunction)
28 { 28 {
29 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create()); 29 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create());
30 30
31 scoped_ptr<TimingFunction> func; 31 scoped_ptr<TimingFunction> func;
32 if (!useTimingFunction) 32 if (!useTimingFunction)
33 func = EaseTimingFunction::create(); 33 func = EaseTimingFunction::create();
34 if (duration > 0) 34 if (duration > 0)
35 curve->addKeyframe(FloatKeyframe::create(0, startOpacity, func.Pass())); 35 curve->addKeyframe(FloatKeyframe::create(0, startOpacity, func.Pass()));
36 curve->addKeyframe(FloatKeyframe::create(duration, endOpacity, scoped_ptr<cc ::TimingFunction>())); 36 curve->addKeyframe(FloatKeyframe::create(duration, endOpacity, scoped_ptr<cc ::TimingFunction>()));
37 37
38 int id = nextAnimationId++; 38 int id = nextAnimationId++;
39 39
40 scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<A nimationCurve>(), id, 0, ActiveAnimation::Opacity)); 40 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv e>(), id, 0, Animation::Opacity));
41 animation->setNeedsSynchronizedStartTime(true); 41 animation->setNeedsSynchronizedStartTime(true);
42 42
43 target.addAnimation(animation.Pass()); 43 target.addAnimation(animation.Pass());
44 return id; 44 return id;
45 } 45 }
46 46
47 template <class Target> 47 template <class Target>
48 int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY ) 48 int addAnimatedTransform(Target& target, double duration, int deltaX, int deltaY )
49 { 49 {
50 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create()); 50 scoped_ptr<KeyframedTransformAnimationCurve> curve(KeyframedTransformAnimati onCurve::create());
51 51
52 if (duration > 0) { 52 if (duration > 0) {
53 WebKit::WebTransformOperations startOperations; 53 WebKit::WebTransformOperations startOperations;
54 startOperations.appendTranslate(deltaX, deltaY, 0); 54 startOperations.appendTranslate(deltaX, deltaY, 0);
55 curve->addKeyframe(TransformKeyframe::create(0, startOperations, scoped_ ptr<cc::TimingFunction>())); 55 curve->addKeyframe(TransformKeyframe::create(0, startOperations, scoped_ ptr<cc::TimingFunction>()));
56 } 56 }
57 57
58 WebKit::WebTransformOperations operations; 58 WebKit::WebTransformOperations operations;
59 operations.appendTranslate(deltaX, deltaY, 0); 59 operations.appendTranslate(deltaX, deltaY, 0);
60 curve->addKeyframe(TransformKeyframe::create(duration, operations, scoped_pt r<cc::TimingFunction>())); 60 curve->addKeyframe(TransformKeyframe::create(duration, operations, scoped_pt r<cc::TimingFunction>()));
61 61
62 int id = nextAnimationId++; 62 int id = nextAnimationId++;
63 63
64 scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<A nimationCurve>(), id, 0, ActiveAnimation::Transform)); 64 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv e>(), id, 0, Animation::Transform));
65 animation->setNeedsSynchronizedStartTime(true); 65 animation->setNeedsSynchronizedStartTime(true);
66 66
67 target.addAnimation(animation.Pass()); 67 target.addAnimation(animation.Pass());
68 return id; 68 return id;
69 } 69 }
70 70
71 FakeFloatAnimationCurve::FakeFloatAnimationCurve() 71 FakeFloatAnimationCurve::FakeFloatAnimationCurve()
72 : m_duration(1) 72 : m_duration(1)
73 { 73 {
74 } 74 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 { 194 {
195 return addAnimatedTransform(layer, duration, deltaX, deltaY); 195 return addAnimatedTransform(layer, duration, deltaX, deltaY);
196 } 196 }
197 197
198 int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int delta X, int deltaY) 198 int addAnimatedTransformToLayer(cc::LayerImpl& layer, double duration, int delta X, int deltaY)
199 { 199 {
200 return addAnimatedTransform(*layer.layerAnimationController(), duration, del taX, deltaY); 200 return addAnimatedTransform(*layer.layerAnimationController(), duration, del taX, deltaY);
201 } 201 }
202 202
203 } // namespace cc 203 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/animation_test_common.h ('k') | cc/test/layer_tree_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698