• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_scroll_offset_animation_curve_impl.h"
6 
7 #if WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED
8 
9 #include "cc/animation/scroll_offset_animation_curve.h"
10 #include "cc/animation/timing_function.h"
11 #include "content/renderer/compositor_bindings/web_animation_curve_common.h"
12 
13 using blink::WebFloatPoint;
14 
15 namespace content {
16 
WebScrollOffsetAnimationCurveImpl(WebFloatPoint target_value,TimingFunctionType timing_function)17 WebScrollOffsetAnimationCurveImpl::WebScrollOffsetAnimationCurveImpl(
18     WebFloatPoint target_value,
19     TimingFunctionType timing_function)
20     : curve_(cc::ScrollOffsetAnimationCurve::Create(
21           gfx::Vector2dF(target_value.x, target_value.y),
22           CreateTimingFunction(timing_function))) {
23 }
24 
~WebScrollOffsetAnimationCurveImpl()25 WebScrollOffsetAnimationCurveImpl::~WebScrollOffsetAnimationCurveImpl() {
26 }
27 
28 blink::WebAnimationCurve::AnimationCurveType
type() const29 WebScrollOffsetAnimationCurveImpl::type() const {
30   return WebAnimationCurve::AnimationCurveTypeScrollOffset;
31 }
32 
setInitialValue(WebFloatPoint initial_value)33 void WebScrollOffsetAnimationCurveImpl::setInitialValue(
34     WebFloatPoint initial_value) {
35   curve_->SetInitialValue(gfx::Vector2dF(initial_value.x, initial_value.y));
36 }
37 
getValue(double time) const38 WebFloatPoint WebScrollOffsetAnimationCurveImpl::getValue(double time) const {
39   gfx::Vector2dF value = curve_->GetValue(time);
40   return WebFloatPoint(value.x(), value.y());
41 }
42 
duration() const43 double WebScrollOffsetAnimationCurveImpl::duration() const {
44   return curve_->Duration();
45 }
46 
47 scoped_ptr<cc::AnimationCurve>
CloneToAnimationCurve() const48 WebScrollOffsetAnimationCurveImpl::CloneToAnimationCurve() const {
49   return curve_->Clone();
50 }
51 
52 }  // namespace content
53 
54 #endif  // WEB_SCROLL_OFFSET_ANIMATION_CURVE_IS_DEFINED
55 
56