| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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_TIMING_FUNCTION_H_ | 5 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_ |
| 6 #define CC_ANIMATION_TIMING_FUNCTION_H_ | 6 #define CC_ANIMATION_TIMING_FUNCTION_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 "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 11 #include "ui/gfx/geometry/cubic_bezier.h" | 12 #include "ui/gfx/geometry/cubic_bezier.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 // See http://www.w3.org/TR/css3-transitions/. | 16 // See http://www.w3.org/TR/css3-transitions/. |
| 16 class CC_EXPORT TimingFunction { | 17 class CC_EXPORT TimingFunction { |
| 17 public: | 18 public: |
| 18 virtual ~TimingFunction(); | 19 virtual ~TimingFunction(); |
| 19 | 20 |
| 20 virtual float GetValue(double t) const = 0; | 21 virtual float GetValue(double t) const = 0; |
| 21 virtual float Velocity(double time) const = 0; | 22 virtual float Velocity(double time) const = 0; |
| 22 // The smallest and largest values returned by GetValue for inputs in [0, 1]. | 23 // The smallest and largest values returned by GetValue for inputs in [0, 1]. |
| 23 virtual void Range(float* min, float* max) const = 0; | 24 virtual void Range(float* min, float* max) const = 0; |
| 24 virtual scoped_ptr<TimingFunction> Clone() const = 0; | 25 virtual std::unique_ptr<TimingFunction> Clone() const = 0; |
| 25 | 26 |
| 26 protected: | 27 protected: |
| 27 TimingFunction(); | 28 TimingFunction(); |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 DISALLOW_ASSIGN(TimingFunction); | 31 DISALLOW_ASSIGN(TimingFunction); |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction { | 34 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction { |
| 34 public: | 35 public: |
| 35 static scoped_ptr<CubicBezierTimingFunction> Create(double x1, double y1, | 36 static std::unique_ptr<CubicBezierTimingFunction> Create(double x1, |
| 36 double x2, double y2); | 37 double y1, |
| 38 double x2, |
| 39 double y2); |
| 37 ~CubicBezierTimingFunction() override; | 40 ~CubicBezierTimingFunction() override; |
| 38 | 41 |
| 39 // TimingFunction implementation. | 42 // TimingFunction implementation. |
| 40 float GetValue(double time) const override; | 43 float GetValue(double time) const override; |
| 41 float Velocity(double time) const override; | 44 float Velocity(double time) const override; |
| 42 void Range(float* min, float* max) const override; | 45 void Range(float* min, float* max) const override; |
| 43 scoped_ptr<TimingFunction> Clone() const override; | 46 std::unique_ptr<TimingFunction> Clone() const override; |
| 44 | 47 |
| 45 protected: | 48 protected: |
| 46 CubicBezierTimingFunction(double x1, double y1, double x2, double y2); | 49 CubicBezierTimingFunction(double x1, double y1, double x2, double y2); |
| 47 | 50 |
| 48 gfx::CubicBezier bezier_; | 51 gfx::CubicBezier bezier_; |
| 49 | 52 |
| 50 private: | 53 private: |
| 51 DISALLOW_ASSIGN(CubicBezierTimingFunction); | 54 DISALLOW_ASSIGN(CubicBezierTimingFunction); |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 class CC_EXPORT EaseTimingFunction { | 57 class CC_EXPORT EaseTimingFunction { |
| 55 public: | 58 public: |
| 56 static scoped_ptr<TimingFunction> Create(); | 59 static std::unique_ptr<TimingFunction> Create(); |
| 57 | 60 |
| 58 private: | 61 private: |
| 59 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseTimingFunction); | 62 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseTimingFunction); |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 class CC_EXPORT EaseInTimingFunction { | 65 class CC_EXPORT EaseInTimingFunction { |
| 63 public: | 66 public: |
| 64 static scoped_ptr<TimingFunction> Create(); | 67 static std::unique_ptr<TimingFunction> Create(); |
| 65 | 68 |
| 66 private: | 69 private: |
| 67 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInTimingFunction); | 70 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInTimingFunction); |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 class CC_EXPORT EaseOutTimingFunction { | 73 class CC_EXPORT EaseOutTimingFunction { |
| 71 public: | 74 public: |
| 72 static scoped_ptr<TimingFunction> Create(); | 75 static std::unique_ptr<TimingFunction> Create(); |
| 73 | 76 |
| 74 private: | 77 private: |
| 75 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseOutTimingFunction); | 78 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseOutTimingFunction); |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 class CC_EXPORT EaseInOutTimingFunction { | 81 class CC_EXPORT EaseInOutTimingFunction { |
| 79 public: | 82 public: |
| 80 static scoped_ptr<TimingFunction> Create(); | 83 static std::unique_ptr<TimingFunction> Create(); |
| 81 | 84 |
| 82 private: | 85 private: |
| 83 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInOutTimingFunction); | 86 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInOutTimingFunction); |
| 84 }; | 87 }; |
| 85 | 88 |
| 86 class CC_EXPORT StepsTimingFunction : public TimingFunction { | 89 class CC_EXPORT StepsTimingFunction : public TimingFunction { |
| 87 public: | 90 public: |
| 88 static scoped_ptr<StepsTimingFunction> Create(int steps, | 91 static std::unique_ptr<StepsTimingFunction> Create(int steps, |
| 89 float steps_start_offset); | 92 float steps_start_offset); |
| 90 ~StepsTimingFunction() override; | 93 ~StepsTimingFunction() override; |
| 91 | 94 |
| 92 float GetValue(double t) const override; | 95 float GetValue(double t) const override; |
| 93 scoped_ptr<TimingFunction> Clone() const override; | 96 std::unique_ptr<TimingFunction> Clone() const override; |
| 94 | 97 |
| 95 void Range(float* min, float* max) const override; | 98 void Range(float* min, float* max) const override; |
| 96 float Velocity(double time) const override; | 99 float Velocity(double time) const override; |
| 97 | 100 |
| 98 protected: | 101 protected: |
| 99 StepsTimingFunction(int steps, float steps_start_offset); | 102 StepsTimingFunction(int steps, float steps_start_offset); |
| 100 | 103 |
| 101 private: | 104 private: |
| 102 int steps_; | 105 int steps_; |
| 103 float steps_start_offset_; | 106 float steps_start_offset_; |
| 104 | 107 |
| 105 DISALLOW_ASSIGN(StepsTimingFunction); | 108 DISALLOW_ASSIGN(StepsTimingFunction); |
| 106 }; | 109 }; |
| 107 | 110 |
| 108 } // namespace cc | 111 } // namespace cc |
| 109 | 112 |
| 110 #endif // CC_ANIMATION_TIMING_FUNCTION_H_ | 113 #endif // CC_ANIMATION_TIMING_FUNCTION_H_ |
| OLD | NEW |