OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/blink/web_transform_animation_curve_impl.h" | |
6 | |
7 #include "cc/animation/keyframed_animation_curve.h" | |
8 #include "cc/animation/timing_function.h" | |
9 #include "cc/animation/transform_operations.h" | |
10 #include "cc/blink/web_animation_curve_common.h" | |
11 #include "cc/blink/web_transform_operations_impl.h" | |
12 | |
13 using blink::WebTransformKeyframe; | |
14 | |
15 namespace cc_blink { | |
16 | |
17 WebTransformAnimationCurveImpl::WebTransformAnimationCurveImpl() | |
18 : curve_(cc::KeyframedTransformAnimationCurve::Create()) { | |
19 } | |
20 | |
21 WebTransformAnimationCurveImpl::~WebTransformAnimationCurveImpl() { | |
22 } | |
23 | |
24 blink::WebCompositorAnimationCurve::AnimationCurveType | |
25 WebTransformAnimationCurveImpl::type() const { | |
26 return WebCompositorAnimationCurve::AnimationCurveTypeTransform; | |
27 } | |
28 | |
29 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe) { | |
30 add(keyframe, TimingFunctionTypeEase); | |
31 } | |
32 | |
33 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, | |
34 TimingFunctionType type) { | |
35 const cc::TransformOperations& transform_operations = | |
36 static_cast<const WebTransformOperationsImpl&>(keyframe.value()) | |
37 .AsTransformOperations(); | |
38 curve_->AddKeyframe(cc::TransformKeyframe::Create( | |
39 base::TimeDelta::FromSecondsD(keyframe.time()), transform_operations, | |
40 CreateTimingFunction(type))); | |
41 } | |
42 | |
43 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, | |
44 double x1, | |
45 double y1, | |
46 double x2, | |
47 double y2) { | |
48 const cc::TransformOperations& transform_operations = | |
49 static_cast<const WebTransformOperationsImpl&>(keyframe.value()) | |
50 .AsTransformOperations(); | |
51 curve_->AddKeyframe(cc::TransformKeyframe::Create( | |
52 base::TimeDelta::FromSecondsD(keyframe.time()), transform_operations, | |
53 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); | |
54 } | |
55 | |
56 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe, | |
57 int steps, | |
58 float steps_start_offset) { | |
59 const cc::TransformOperations& transform_operations = | |
60 static_cast<const WebTransformOperationsImpl&>(keyframe.value()) | |
61 .AsTransformOperations(); | |
62 curve_->AddKeyframe(cc::TransformKeyframe::Create( | |
63 base::TimeDelta::FromSecondsD(keyframe.time()), transform_operations, | |
64 cc::StepsTimingFunction::Create(steps, steps_start_offset))); | |
65 } | |
66 | |
67 void WebTransformAnimationCurveImpl::setLinearTimingFunction() { | |
68 curve_->SetTimingFunction(nullptr); | |
69 } | |
70 | |
71 void WebTransformAnimationCurveImpl::setCubicBezierTimingFunction( | |
72 TimingFunctionType type) { | |
73 curve_->SetTimingFunction(CreateTimingFunction(type)); | |
74 } | |
75 | |
76 void WebTransformAnimationCurveImpl::setCubicBezierTimingFunction(double x1, | |
77 double y1, | |
78 double x2, | |
79 double y2) { | |
80 curve_->SetTimingFunction( | |
81 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); | |
82 } | |
83 | |
84 void WebTransformAnimationCurveImpl::setStepsTimingFunction( | |
85 int number_of_steps, | |
86 float steps_start_offset) { | |
87 curve_->SetTimingFunction( | |
88 cc::StepsTimingFunction::Create(number_of_steps, steps_start_offset)); | |
89 } | |
90 | |
91 scoped_ptr<cc::AnimationCurve> | |
92 WebTransformAnimationCurveImpl::CloneToAnimationCurve() const { | |
93 return curve_->Clone(); | |
94 } | |
95 | |
96 } // namespace cc_blink | |
OLD | NEW |