| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_ANIMATION_SCROLL_OFFSET_ANIMATION_CURVE_H_ | 5 #ifndef CC_ANIMATION_SCROLL_OFFSET_ANIMATION_CURVE_H_ |
| 6 #define CC_ANIMATION_SCROLL_OFFSET_ANIMATION_CURVE_H_ | 6 #define CC_ANIMATION_SCROLL_OFFSET_ANIMATION_CURVE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 11 #include "cc/animation/animation_curve.h" | 12 #include "cc/animation/animation_curve.h" |
| 12 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
| 13 #include "ui/gfx/geometry/scroll_offset.h" | 14 #include "ui/gfx/geometry/scroll_offset.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| 17 class TimingFunction; | 18 class TimingFunction; |
| 18 | 19 |
| 19 class CC_EXPORT ScrollOffsetAnimationCurve : public AnimationCurve { | 20 class CC_EXPORT ScrollOffsetAnimationCurve : public AnimationCurve { |
| 20 public: | 21 public: |
| 21 enum class DurationBehavior { DELTA_BASED, CONSTANT, INVERSE_DELTA }; | 22 enum class DurationBehavior { DELTA_BASED, CONSTANT, INVERSE_DELTA }; |
| 22 static scoped_ptr<ScrollOffsetAnimationCurve> Create( | 23 static std::unique_ptr<ScrollOffsetAnimationCurve> Create( |
| 23 const gfx::ScrollOffset& target_value, | 24 const gfx::ScrollOffset& target_value, |
| 24 scoped_ptr<TimingFunction> timing_function, | 25 std::unique_ptr<TimingFunction> timing_function, |
| 25 DurationBehavior = DurationBehavior::DELTA_BASED); | 26 DurationBehavior = DurationBehavior::DELTA_BASED); |
| 26 | 27 |
| 27 ~ScrollOffsetAnimationCurve() override; | 28 ~ScrollOffsetAnimationCurve() override; |
| 28 | 29 |
| 29 void SetInitialValue(const gfx::ScrollOffset& initial_value); | 30 void SetInitialValue(const gfx::ScrollOffset& initial_value); |
| 30 bool HasSetInitialValue() const; | 31 bool HasSetInitialValue() const; |
| 31 gfx::ScrollOffset GetValue(base::TimeDelta t) const; | 32 gfx::ScrollOffset GetValue(base::TimeDelta t) const; |
| 32 gfx::ScrollOffset target_value() const { return target_value_; } | 33 gfx::ScrollOffset target_value() const { return target_value_; } |
| 33 void UpdateTarget(double t, const gfx::ScrollOffset& new_target); | 34 void UpdateTarget(double t, const gfx::ScrollOffset& new_target); |
| 34 | 35 |
| 35 // AnimationCurve implementation | 36 // AnimationCurve implementation |
| 36 base::TimeDelta Duration() const override; | 37 base::TimeDelta Duration() const override; |
| 37 CurveType Type() const override; | 38 CurveType Type() const override; |
| 38 scoped_ptr<AnimationCurve> Clone() const override; | 39 std::unique_ptr<AnimationCurve> Clone() const override; |
| 39 scoped_ptr<ScrollOffsetAnimationCurve> CloneToScrollOffsetAnimationCurve() | 40 std::unique_ptr<ScrollOffsetAnimationCurve> |
| 40 const; | 41 CloneToScrollOffsetAnimationCurve() const; |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 ScrollOffsetAnimationCurve(const gfx::ScrollOffset& target_value, | 44 ScrollOffsetAnimationCurve(const gfx::ScrollOffset& target_value, |
| 44 scoped_ptr<TimingFunction> timing_function, | 45 std::unique_ptr<TimingFunction> timing_function, |
| 45 DurationBehavior); | 46 DurationBehavior); |
| 46 | 47 |
| 47 gfx::ScrollOffset initial_value_; | 48 gfx::ScrollOffset initial_value_; |
| 48 gfx::ScrollOffset target_value_; | 49 gfx::ScrollOffset target_value_; |
| 49 base::TimeDelta total_animation_duration_; | 50 base::TimeDelta total_animation_duration_; |
| 50 | 51 |
| 51 // Time from animation start to most recent UpdateTarget. | 52 // Time from animation start to most recent UpdateTarget. |
| 52 base::TimeDelta last_retarget_; | 53 base::TimeDelta last_retarget_; |
| 53 | 54 |
| 54 scoped_ptr<TimingFunction> timing_function_; | 55 std::unique_ptr<TimingFunction> timing_function_; |
| 55 DurationBehavior duration_behavior_; | 56 DurationBehavior duration_behavior_; |
| 56 | 57 |
| 57 bool has_set_initial_value_; | 58 bool has_set_initial_value_; |
| 58 | 59 |
| 59 DISALLOW_COPY_AND_ASSIGN(ScrollOffsetAnimationCurve); | 60 DISALLOW_COPY_AND_ASSIGN(ScrollOffsetAnimationCurve); |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 } // namespace cc | 63 } // namespace cc |
| 63 | 64 |
| 64 #endif // CC_ANIMATION_SCROLL_OFFSET_ANIMATION_CURVE_H_ | 65 #endif // CC_ANIMATION_SCROLL_OFFSET_ANIMATION_CURVE_H_ |
| OLD | NEW |