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 "content/renderer/compositor_bindings/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/output/filter_operations.h"
10 #include "content/renderer/compositor_bindings/web_animation_curve_common.h"
11 #include "content/renderer/compositor_bindings/web_filter_operations_impl.h"
12
13 using blink::WebFilterKeyframe;
14
15 namespace content {
16
WebFilterAnimationCurveImpl()17 WebFilterAnimationCurveImpl::WebFilterAnimationCurveImpl()
18 : curve_(cc::KeyframedFilterAnimationCurve::Create()) {
19 }
20
~WebFilterAnimationCurveImpl()21 WebFilterAnimationCurveImpl::~WebFilterAnimationCurveImpl() {
22 }
23
type() const24 blink::WebAnimationCurve::AnimationCurveType WebFilterAnimationCurveImpl::type()
25 const {
26 return WebAnimationCurve::AnimationCurveTypeFilter;
27 }
28
add(const WebFilterKeyframe & keyframe,TimingFunctionType type)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 keyframe.time(), filter_operations, CreateTimingFunction(type)));
36 }
37
add(const WebFilterKeyframe & keyframe,double x1,double y1,double x2,double y2)38 void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe,
39 double x1,
40 double y1,
41 double x2,
42 double y2) {
43 const cc::FilterOperations& filter_operations =
44 static_cast<const WebFilterOperationsImpl&>(keyframe.value())
45 .AsFilterOperations();
46 curve_->AddKeyframe(cc::FilterKeyframe::Create(
47 keyframe.time(),
48 filter_operations,
49 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
50 .PassAs<cc::TimingFunction>()));
51 }
52
53 scoped_ptr<cc::AnimationCurve>
CloneToAnimationCurve() const54 WebFilterAnimationCurveImpl::CloneToAnimationCurve() const {
55 return curve_->Clone();
56 }
57
58 } // namespace content
59
60