Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / cc / blink / web_transform_animation_curve_impl.cc
blob86f3602cecd560cdb10d4fe709d3a61ae117b697
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.
5 #include "cc/blink/web_transform_animation_curve_impl.h"
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"
13 using blink::WebTransformKeyframe;
15 namespace cc_blink {
17 WebTransformAnimationCurveImpl::WebTransformAnimationCurveImpl()
18 : curve_(cc::KeyframedTransformAnimationCurve::Create()) {
21 WebTransformAnimationCurveImpl::~WebTransformAnimationCurveImpl() {
24 blink::WebCompositorAnimationCurve::AnimationCurveType
25 WebTransformAnimationCurveImpl::type() const {
26 return WebCompositorAnimationCurve::AnimationCurveTypeTransform;
29 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe) {
30 add(keyframe, TimingFunctionTypeEase);
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)));
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)));
56 void WebTransformAnimationCurveImpl::setTimingFunction(
57 TimingFunctionType type) {
58 curve_->SetTimingFunction(CreateTimingFunction(type));
61 void WebTransformAnimationCurveImpl::setTimingFunction(double x1,
62 double y1,
63 double x2,
64 double y2) {
65 curve_->SetTimingFunction(
66 cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2).Pass());
69 scoped_ptr<cc::AnimationCurve>
70 WebTransformAnimationCurveImpl::CloneToAnimationCurve() const {
71 return curve_->Clone();
74 } // namespace cc_blink