| 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_scroll_offset_animation_curve_impl.h" | |
| 6 | |
| 7 #include "cc/animation/scroll_offset_animation_curve.h" | |
| 8 #include "cc/animation/timing_function.h" | |
| 9 #include "cc/blink/web_animation_curve_common.h" | |
| 10 | |
| 11 using blink::WebFloatPoint; | |
| 12 using blink::WebScrollOffsetAnimationCurve; | |
| 13 using DurationBehavior = cc::ScrollOffsetAnimationCurve::DurationBehavior; | |
| 14 | |
| 15 namespace cc_blink { | |
| 16 | |
| 17 static DurationBehavior GetDurationBehavior( | |
| 18 WebScrollOffsetAnimationCurve::ScrollDurationBehavior webDurationBehavior) { | |
| 19 switch (webDurationBehavior) { | |
| 20 case WebScrollOffsetAnimationCurve::ScrollDurationDeltaBased: | |
| 21 return DurationBehavior::DELTA_BASED; | |
| 22 | |
| 23 case WebScrollOffsetAnimationCurve::ScrollDurationConstant: | |
| 24 return DurationBehavior::CONSTANT; | |
| 25 | |
| 26 case WebScrollOffsetAnimationCurve::ScrollDurationInverseDelta: | |
| 27 return DurationBehavior::INVERSE_DELTA; | |
| 28 } | |
| 29 NOTREACHED(); | |
| 30 return DurationBehavior::DELTA_BASED; | |
| 31 } | |
| 32 | |
| 33 WebScrollOffsetAnimationCurveImpl::WebScrollOffsetAnimationCurveImpl( | |
| 34 WebFloatPoint target_value, | |
| 35 TimingFunctionType timing_function, | |
| 36 ScrollDurationBehavior duration_behavior) | |
| 37 : curve_(cc::ScrollOffsetAnimationCurve::Create( | |
| 38 gfx::ScrollOffset(target_value.x, target_value.y), | |
| 39 CreateTimingFunction(timing_function), | |
| 40 GetDurationBehavior(duration_behavior))) {} | |
| 41 | |
| 42 WebScrollOffsetAnimationCurveImpl::~WebScrollOffsetAnimationCurveImpl() { | |
| 43 } | |
| 44 | |
| 45 blink::WebCompositorAnimationCurve::AnimationCurveType | |
| 46 WebScrollOffsetAnimationCurveImpl::type() const { | |
| 47 return WebCompositorAnimationCurve::AnimationCurveTypeScrollOffset; | |
| 48 } | |
| 49 | |
| 50 void WebScrollOffsetAnimationCurveImpl::setInitialValue( | |
| 51 WebFloatPoint initial_value) { | |
| 52 curve_->SetInitialValue(gfx::ScrollOffset(initial_value.x, initial_value.y)); | |
| 53 } | |
| 54 | |
| 55 WebFloatPoint WebScrollOffsetAnimationCurveImpl::getValue(double time) const { | |
| 56 gfx::ScrollOffset value = | |
| 57 curve_->GetValue(base::TimeDelta::FromSecondsD(time)); | |
| 58 return WebFloatPoint(value.x(), value.y()); | |
| 59 } | |
| 60 | |
| 61 double WebScrollOffsetAnimationCurveImpl::duration() const { | |
| 62 return curve_->Duration().InSecondsF(); | |
| 63 } | |
| 64 | |
| 65 WebFloatPoint WebScrollOffsetAnimationCurveImpl::targetValue() const { | |
| 66 gfx::ScrollOffset target = curve_->target_value(); | |
| 67 return WebFloatPoint(target.x(), target.y()); | |
| 68 } | |
| 69 | |
| 70 void WebScrollOffsetAnimationCurveImpl::updateTarget(double time, | |
| 71 WebFloatPoint new_target) { | |
| 72 curve_->UpdateTarget(time, gfx::ScrollOffset(new_target.x, new_target.y)); | |
| 73 } | |
| 74 | |
| 75 scoped_ptr<cc::AnimationCurve> | |
| 76 WebScrollOffsetAnimationCurveImpl::CloneToAnimationCurve() const { | |
| 77 return curve_->Clone(); | |
| 78 } | |
| 79 | |
| 80 } // namespace cc_blink | |
| OLD | NEW |