• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "webkit/renderer/compositor_bindings/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 "webkit/renderer/compositor_bindings/web_animation_curve_common.h"
11 #include "webkit/renderer/compositor_bindings/web_transform_operations_impl.h"
12 
13 using blink::WebTransformKeyframe;
14 
15 namespace webkit {
16 
WebTransformAnimationCurveImpl()17 WebTransformAnimationCurveImpl::WebTransformAnimationCurveImpl()
18     : curve_(cc::KeyframedTransformAnimationCurve::Create()) {}
19 
~WebTransformAnimationCurveImpl()20 WebTransformAnimationCurveImpl::~WebTransformAnimationCurveImpl() {}
21 
22 blink::WebAnimationCurve::AnimationCurveType
type() const23 WebTransformAnimationCurveImpl::type() const {
24   return WebAnimationCurve::AnimationCurveTypeTransform;
25 }
26 
add(const WebTransformKeyframe & keyframe)27 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe) {
28   add(keyframe, TimingFunctionTypeEase);
29 }
30 
add(const WebTransformKeyframe & keyframe,TimingFunctionType type)31 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe,
32                                          TimingFunctionType type) {
33   const cc::TransformOperations& transform_operations =
34       static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value())
35       .AsTransformOperations();
36   curve_->AddKeyframe(cc::TransformKeyframe::Create(
37       keyframe.time(), transform_operations, CreateTimingFunction(type)));
38 }
39 
add(const WebTransformKeyframe & keyframe,double x1,double y1,double x2,double y2)40 void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe,
41                                          double x1,
42                                          double y1,
43                                          double x2,
44                                          double y2) {
45   const cc::TransformOperations& transform_operations =
46       static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value())
47       .AsTransformOperations();
48   curve_->AddKeyframe(cc::TransformKeyframe::Create(
49       keyframe.time(),
50       transform_operations,
51       cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
52           .PassAs<cc::TimingFunction>()));
53 }
54 
55 scoped_ptr<cc::AnimationCurve>
CloneToAnimationCurve() const56 WebTransformAnimationCurveImpl::CloneToAnimationCurve() const {
57   return curve_->Clone();
58 }
59 
60 }  // namespace webkit
61