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 "webkit/compositor_bindings/web_transform_animation_curve_impl.h" | 5 #include "webkit/compositor_bindings/web_transform_animation_curve_impl.h" |
6 | 6 |
7 #include "cc/animation/keyframed_animation_curve.h" | 7 #include "cc/animation/keyframed_animation_curve.h" |
8 #include "cc/animation/timing_function.h" | 8 #include "cc/animation/timing_function.h" |
9 #include "cc/animation/transform_operations.h" | 9 #include "cc/animation/transform_operations.h" |
10 #include "webkit/compositor_bindings/web_animation_curve_common.h" | 10 #include "webkit/compositor_bindings/web_animation_curve_common.h" |
11 #include "webkit/compositor_bindings/web_transform_operations_impl.h" | 11 #include "webkit/compositor_bindings/web_transform_operations_impl.h" |
12 | 12 |
13 namespace WebKit { | 13 using WebKit::WebTransformKeyframe; |
| 14 |
| 15 namespace webkit { |
14 | 16 |
15 WebTransformAnimationCurveImpl::WebTransformAnimationCurveImpl() | 17 WebTransformAnimationCurveImpl::WebTransformAnimationCurveImpl() |
16 : curve_(cc::KeyframedTransformAnimationCurve::Create()) {} | 18 : curve_(cc::KeyframedTransformAnimationCurve::Create()) {} |
17 | 19 |
18 WebTransformAnimationCurveImpl::~WebTransformAnimationCurveImpl() {} | 20 WebTransformAnimationCurveImpl::~WebTransformAnimationCurveImpl() {} |
19 | 21 |
20 WebAnimationCurve::AnimationCurveType | 22 WebKit::WebAnimationCurve::AnimationCurveType |
21 WebTransformAnimationCurveImpl::type() const { | 23 WebTransformAnimationCurveImpl::type() const { |
22 return WebAnimationCurve::AnimationCurveTypeTransform; | 24 return WebAnimationCurve::AnimationCurveTypeTransform; |
23 } | 25 } |
24 | 26 |
25 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe) { | 27 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe) { |
26 add(keyframe, TimingFunctionTypeEase); | 28 add(keyframe, TimingFunctionTypeEase); |
27 } | 29 } |
28 | 30 |
29 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, | 31 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, |
30 TimingFunctionType type) { | 32 TimingFunctionType type) { |
31 const cc::TransformOperations& transform_operations = | 33 const cc::TransformOperations& transform_operations = |
32 static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value()) | 34 static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value()) |
33 .AsTransformOperations(); | 35 .AsTransformOperations(); |
34 curve_->AddKeyframe(cc::TransformKeyframe::Create( | 36 curve_->AddKeyframe(cc::TransformKeyframe::Create( |
35 keyframe.time(), transform_operations, createTimingFunction(type))); | 37 keyframe.time(), transform_operations, CreateTimingFunction(type))); |
36 } | 38 } |
37 | 39 |
38 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, | 40 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, |
39 double x1, | 41 double x1, |
40 double y1, | 42 double y1, |
41 double x2, | 43 double x2, |
42 double y2) { | 44 double y2) { |
43 const cc::TransformOperations& transform_operations = | 45 const cc::TransformOperations& transform_operations = |
44 static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value()) | 46 static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value()) |
45 .AsTransformOperations(); | 47 .AsTransformOperations(); |
46 curve_->AddKeyframe(cc::TransformKeyframe::Create( | 48 curve_->AddKeyframe(cc::TransformKeyframe::Create( |
47 keyframe.time(), | 49 keyframe.time(), |
48 transform_operations, | 50 transform_operations, |
49 cc::CubicBezierTimingFunction::create(x1, y1, x2, y2) | 51 cc::CubicBezierTimingFunction::create(x1, y1, x2, y2) |
50 .PassAs<cc::TimingFunction>())); | 52 .PassAs<cc::TimingFunction>())); |
51 } | 53 } |
52 | 54 |
53 scoped_ptr<cc::AnimationCurve> | 55 scoped_ptr<cc::AnimationCurve> |
54 WebTransformAnimationCurveImpl::cloneToAnimationCurve() const { | 56 WebTransformAnimationCurveImpl::CloneToAnimationCurve() const { |
55 return curve_->Clone(); | 57 return curve_->Clone(); |
56 } | 58 } |
57 | 59 |
58 } // namespace WebKit | 60 } // namespace webkit |
OLD | NEW |