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_filter_animation_curve_impl.h" | |
6 | |
7 #include "cc/animation/keyframed_animation_curve.h" | |
8 #include "cc/animation/timing_function.h" | |
9 #include "cc/blink/web_animation_curve_common.h" | |
10 #include "cc/blink/web_filter_operations_impl.h" | |
11 #include "cc/output/filter_operations.h" | |
12 | |
13 using blink::WebFilterKeyframe; | |
14 | |
15 namespace cc_blink { | |
16 | |
17 WebFilterAnimationCurveImpl::WebFilterAnimationCurveImpl() | |
18 : curve_(cc::KeyframedFilterAnimationCurve::Create()) { | |
19 } | |
20 | |
21 WebFilterAnimationCurveImpl::~WebFilterAnimationCurveImpl() { | |
22 } | |
23 | |
24 blink::WebCompositorAnimationCurve::AnimationCurveType | |
25 WebFilterAnimationCurveImpl::type() const { | |
26 return WebCompositorAnimationCurve::AnimationCurveTypeFilter; | |
27 } | |
28 | |
29 void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe, | |
30 TimingFunctionType type) { | |
31 const cc::FilterOperations& filter_operations = | |
32 static_cast<const WebFilterOperationsImpl&>(keyframe.value()) | |
33 .AsFilterOperations(); | |
34 curve_->AddKeyframe(cc::FilterKeyframe::Create( | |
35 base::TimeDelta::FromSecondsD(keyframe.time()), filter_operations, | |
36 CreateTimingFunction(type))); | |
37 } | |
38 | |
39 void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe, | |
40 double x1, | |
41 double y1, | |
42 double x2, | |
43 double y2) { | |
44 const cc::FilterOperations& filter_operations = | |
45 static_cast<const WebFilterOperationsImpl&>(keyframe.value()) | |
46 .AsFilterOperations(); | |
47 curve_->AddKeyframe(cc::FilterKeyframe::Create( | |
48 base::TimeDelta::FromSecondsD(keyframe.time()), filter_operations, | |
49 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2))); | |
50 } | |
51 | |
52 void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe, | |
53 int steps, | |
54 float steps_start_offset) { | |
55 const cc::FilterOperations& filter_operations = | |
56 static_cast<const WebFilterOperationsImpl&>(keyframe.value()) | |
57 .AsFilterOperations(); | |
58 curve_->AddKeyframe(cc::FilterKeyframe::Create( | |
59 base::TimeDelta::FromSecondsD(keyframe.time()), filter_operations, | |
60 cc::StepsTimingFunction::Create(steps, steps_start_offset))); | |
61 } | |
62 | |
63 void WebFilterAnimationCurveImpl::setLinearTimingFunction() { | |
64 curve_->SetTimingFunction(nullptr); | |
65 } | |
66 | |
67 void WebFilterAnimationCurveImpl::setCubicBezierTimingFunction( | |
68 TimingFunctionType type) { | |
69 curve_->SetTimingFunction(CreateTimingFunction(type)); | |
70 } | |
71 | |
72 void WebFilterAnimationCurveImpl::setCubicBezierTimingFunction(double x1, | |
73 double y1, | |
74 double x2, | |
75 double y2) { | |
76 curve_->SetTimingFunction( | |
77 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)); | |
78 } | |
79 | |
80 void WebFilterAnimationCurveImpl::setStepsTimingFunction( | |
81 int number_of_steps, | |
82 float steps_start_offset) { | |
83 curve_->SetTimingFunction( | |
84 cc::StepsTimingFunction::Create(number_of_steps, steps_start_offset)); | |
85 } | |
86 | |
87 scoped_ptr<cc::AnimationCurve> | |
88 WebFilterAnimationCurveImpl::CloneToAnimationCurve() const { | |
89 return curve_->Clone(); | |
90 } | |
91 | |
92 } // namespace cc_blink | |
OLD | NEW |