| 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_KEYFRAMED_ANIMATION_CURVE_H_ | 5 #ifndef CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | 
| 6 #define CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | 6 #define CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | 
| 7 | 7 | 
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" | 
| 9 #include "cc/animation/animation_curve.h" | 9 #include "cc/animation/animation_curve.h" | 
| 10 #include "cc/animation/timing_function.h" | 10 #include "cc/animation/timing_function.h" | 
| 11 #include "cc/animation/transform_operations.h" | 11 #include "cc/animation/transform_operations.h" | 
| 12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" | 
| 13 #include "cc/base/scoped_ptr_vector.h" | 13 #include "cc/base/scoped_ptr_vector.h" | 
| 14 | 14 | 
| 15 namespace cc { | 15 namespace cc { | 
| 16 | 16 | 
| 17 class CC_EXPORT Keyframe { | 17 class CC_EXPORT Keyframe { | 
| 18  public: | 18  public: | 
| 19   double Time() const; | 19   base::TimeDelta Time() const; | 
| 20   const TimingFunction* timing_function() const { | 20   const TimingFunction* timing_function() const { | 
| 21     return timing_function_.get(); | 21     return timing_function_.get(); | 
| 22   } | 22   } | 
| 23 | 23 | 
| 24  protected: | 24  protected: | 
| 25   Keyframe(double time, scoped_ptr<TimingFunction> timing_function); | 25   Keyframe(base::TimeDelta time, scoped_ptr<TimingFunction> timing_function); | 
| 26   virtual ~Keyframe(); | 26   virtual ~Keyframe(); | 
| 27 | 27 | 
| 28  private: | 28  private: | 
| 29   double time_; | 29   base::TimeDelta time_; | 
| 30   scoped_ptr<TimingFunction> timing_function_; | 30   scoped_ptr<TimingFunction> timing_function_; | 
| 31 | 31 | 
| 32   DISALLOW_COPY_AND_ASSIGN(Keyframe); | 32   DISALLOW_COPY_AND_ASSIGN(Keyframe); | 
| 33 }; | 33 }; | 
| 34 | 34 | 
| 35 class CC_EXPORT ColorKeyframe : public Keyframe { | 35 class CC_EXPORT ColorKeyframe : public Keyframe { | 
| 36  public: | 36  public: | 
| 37   static scoped_ptr<ColorKeyframe> Create( | 37   static scoped_ptr<ColorKeyframe> Create( | 
| 38       double time, | 38       base::TimeDelta time, | 
| 39       SkColor value, | 39       SkColor value, | 
| 40       scoped_ptr<TimingFunction> timing_function); | 40       scoped_ptr<TimingFunction> timing_function); | 
| 41   ~ColorKeyframe() override; | 41   ~ColorKeyframe() override; | 
| 42 | 42 | 
| 43   SkColor Value() const; | 43   SkColor Value() const; | 
| 44 | 44 | 
| 45   scoped_ptr<ColorKeyframe> Clone() const; | 45   scoped_ptr<ColorKeyframe> Clone() const; | 
| 46 | 46 | 
| 47  private: | 47  private: | 
| 48   ColorKeyframe(double time, | 48   ColorKeyframe(base::TimeDelta time, | 
| 49                 SkColor value, | 49                 SkColor value, | 
| 50                 scoped_ptr<TimingFunction> timing_function); | 50                 scoped_ptr<TimingFunction> timing_function); | 
| 51 | 51 | 
| 52   SkColor value_; | 52   SkColor value_; | 
| 53 }; | 53 }; | 
| 54 | 54 | 
| 55 class CC_EXPORT FloatKeyframe : public Keyframe { | 55 class CC_EXPORT FloatKeyframe : public Keyframe { | 
| 56  public: | 56  public: | 
| 57   static scoped_ptr<FloatKeyframe> Create( | 57   static scoped_ptr<FloatKeyframe> Create( | 
| 58       double time, | 58       base::TimeDelta time, | 
| 59       float value, | 59       float value, | 
| 60       scoped_ptr<TimingFunction> timing_function); | 60       scoped_ptr<TimingFunction> timing_function); | 
| 61   ~FloatKeyframe() override; | 61   ~FloatKeyframe() override; | 
| 62 | 62 | 
| 63   float Value() const; | 63   float Value() const; | 
| 64 | 64 | 
| 65   scoped_ptr<FloatKeyframe> Clone() const; | 65   scoped_ptr<FloatKeyframe> Clone() const; | 
| 66 | 66 | 
| 67  private: | 67  private: | 
| 68   FloatKeyframe(double time, | 68   FloatKeyframe(base::TimeDelta time, | 
| 69                 float value, | 69                 float value, | 
| 70                 scoped_ptr<TimingFunction> timing_function); | 70                 scoped_ptr<TimingFunction> timing_function); | 
| 71 | 71 | 
| 72   float value_; | 72   float value_; | 
| 73 }; | 73 }; | 
| 74 | 74 | 
| 75 class CC_EXPORT TransformKeyframe : public Keyframe { | 75 class CC_EXPORT TransformKeyframe : public Keyframe { | 
| 76  public: | 76  public: | 
| 77   static scoped_ptr<TransformKeyframe> Create( | 77   static scoped_ptr<TransformKeyframe> Create( | 
| 78       double time, | 78       base::TimeDelta time, | 
| 79       const TransformOperations& value, | 79       const TransformOperations& value, | 
| 80       scoped_ptr<TimingFunction> timing_function); | 80       scoped_ptr<TimingFunction> timing_function); | 
| 81   ~TransformKeyframe() override; | 81   ~TransformKeyframe() override; | 
| 82 | 82 | 
| 83   const TransformOperations& Value() const; | 83   const TransformOperations& Value() const; | 
| 84 | 84 | 
| 85   scoped_ptr<TransformKeyframe> Clone() const; | 85   scoped_ptr<TransformKeyframe> Clone() const; | 
| 86 | 86 | 
| 87  private: | 87  private: | 
| 88   TransformKeyframe( | 88   TransformKeyframe(base::TimeDelta time, | 
| 89       double time, | 89                     const TransformOperations& value, | 
| 90       const TransformOperations& value, | 90                     scoped_ptr<TimingFunction> timing_function); | 
| 91       scoped_ptr<TimingFunction> timing_function); |  | 
| 92 | 91 | 
| 93   TransformOperations value_; | 92   TransformOperations value_; | 
| 94 }; | 93 }; | 
| 95 | 94 | 
| 96 class CC_EXPORT FilterKeyframe : public Keyframe { | 95 class CC_EXPORT FilterKeyframe : public Keyframe { | 
| 97  public: | 96  public: | 
| 98   static scoped_ptr<FilterKeyframe> Create( | 97   static scoped_ptr<FilterKeyframe> Create( | 
| 99       double time, | 98       base::TimeDelta time, | 
| 100       const FilterOperations& value, | 99       const FilterOperations& value, | 
| 101       scoped_ptr<TimingFunction> timing_function); | 100       scoped_ptr<TimingFunction> timing_function); | 
| 102   ~FilterKeyframe() override; | 101   ~FilterKeyframe() override; | 
| 103 | 102 | 
| 104   const FilterOperations& Value() const; | 103   const FilterOperations& Value() const; | 
| 105 | 104 | 
| 106   scoped_ptr<FilterKeyframe> Clone() const; | 105   scoped_ptr<FilterKeyframe> Clone() const; | 
| 107 | 106 | 
| 108  private: | 107  private: | 
| 109   FilterKeyframe( | 108   FilterKeyframe(base::TimeDelta time, | 
| 110       double time, | 109                  const FilterOperations& value, | 
| 111       const FilterOperations& value, | 110                  scoped_ptr<TimingFunction> timing_function); | 
| 112       scoped_ptr<TimingFunction> timing_function); |  | 
| 113 | 111 | 
| 114   FilterOperations value_; | 112   FilterOperations value_; | 
| 115 }; | 113 }; | 
| 116 | 114 | 
| 117 class CC_EXPORT KeyframedColorAnimationCurve : public ColorAnimationCurve { | 115 class CC_EXPORT KeyframedColorAnimationCurve : public ColorAnimationCurve { | 
| 118  public: | 116  public: | 
| 119   // It is required that the keyframes be sorted by time. | 117   // It is required that the keyframes be sorted by time. | 
| 120   static scoped_ptr<KeyframedColorAnimationCurve> Create(); | 118   static scoped_ptr<KeyframedColorAnimationCurve> Create(); | 
| 121 | 119 | 
| 122   ~KeyframedColorAnimationCurve() override; | 120   ~KeyframedColorAnimationCurve() override; | 
| 123 | 121 | 
| 124   void AddKeyframe(scoped_ptr<ColorKeyframe> keyframe); | 122   void AddKeyframe(scoped_ptr<ColorKeyframe> keyframe); | 
| 125   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 123   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 
| 126     timing_function_ = timing_function.Pass(); | 124     timing_function_ = timing_function.Pass(); | 
| 127   } | 125   } | 
| 128 | 126 | 
| 129   // AnimationCurve implementation | 127   // AnimationCurve implementation | 
| 130   base::TimeDelta Duration() const override; | 128   base::TimeDelta Duration() const override; | 
| 131   scoped_ptr<AnimationCurve> Clone() const override; | 129   scoped_ptr<AnimationCurve> Clone() const override; | 
| 132 | 130 | 
| 133   // BackgrounColorAnimationCurve implementation | 131   // BackgrounColorAnimationCurve implementation | 
| 134   SkColor GetValue(double t) const override; | 132   SkColor GetValue(base::TimeDelta t) const override; | 
| 135 | 133 | 
| 136  private: | 134  private: | 
| 137   KeyframedColorAnimationCurve(); | 135   KeyframedColorAnimationCurve(); | 
| 138 | 136 | 
| 139   // Always sorted in order of increasing time. No two keyframes have the | 137   // Always sorted in order of increasing time. No two keyframes have the | 
| 140   // same time. | 138   // same time. | 
| 141   ScopedPtrVector<ColorKeyframe> keyframes_; | 139   ScopedPtrVector<ColorKeyframe> keyframes_; | 
| 142   scoped_ptr<TimingFunction> timing_function_; | 140   scoped_ptr<TimingFunction> timing_function_; | 
| 143 | 141 | 
| 144   DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve); | 142   DISALLOW_COPY_AND_ASSIGN(KeyframedColorAnimationCurve); | 
| 145 }; | 143 }; | 
| 146 | 144 | 
| 147 class CC_EXPORT KeyframedFloatAnimationCurve : public FloatAnimationCurve { | 145 class CC_EXPORT KeyframedFloatAnimationCurve : public FloatAnimationCurve { | 
| 148  public: | 146  public: | 
| 149   // It is required that the keyframes be sorted by time. | 147   // It is required that the keyframes be sorted by time. | 
| 150   static scoped_ptr<KeyframedFloatAnimationCurve> Create(); | 148   static scoped_ptr<KeyframedFloatAnimationCurve> Create(); | 
| 151 | 149 | 
| 152   ~KeyframedFloatAnimationCurve() override; | 150   ~KeyframedFloatAnimationCurve() override; | 
| 153 | 151 | 
| 154   void AddKeyframe(scoped_ptr<FloatKeyframe> keyframe); | 152   void AddKeyframe(scoped_ptr<FloatKeyframe> keyframe); | 
| 155   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 153   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 
| 156     timing_function_ = timing_function.Pass(); | 154     timing_function_ = timing_function.Pass(); | 
| 157   } | 155   } | 
| 158 | 156 | 
| 159   // AnimationCurve implementation | 157   // AnimationCurve implementation | 
| 160   base::TimeDelta Duration() const override; | 158   base::TimeDelta Duration() const override; | 
| 161   scoped_ptr<AnimationCurve> Clone() const override; | 159   scoped_ptr<AnimationCurve> Clone() const override; | 
| 162 | 160 | 
| 163   // FloatAnimationCurve implementation | 161   // FloatAnimationCurve implementation | 
| 164   float GetValue(double t) const override; | 162   float GetValue(base::TimeDelta t) const override; | 
| 165 | 163 | 
| 166  private: | 164  private: | 
| 167   KeyframedFloatAnimationCurve(); | 165   KeyframedFloatAnimationCurve(); | 
| 168 | 166 | 
| 169   // Always sorted in order of increasing time. No two keyframes have the | 167   // Always sorted in order of increasing time. No two keyframes have the | 
| 170   // same time. | 168   // same time. | 
| 171   ScopedPtrVector<FloatKeyframe> keyframes_; | 169   ScopedPtrVector<FloatKeyframe> keyframes_; | 
| 172   scoped_ptr<TimingFunction> timing_function_; | 170   scoped_ptr<TimingFunction> timing_function_; | 
| 173 | 171 | 
| 174   DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve); | 172   DISALLOW_COPY_AND_ASSIGN(KeyframedFloatAnimationCurve); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 185   void AddKeyframe(scoped_ptr<TransformKeyframe> keyframe); | 183   void AddKeyframe(scoped_ptr<TransformKeyframe> keyframe); | 
| 186   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 184   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 
| 187     timing_function_ = timing_function.Pass(); | 185     timing_function_ = timing_function.Pass(); | 
| 188   } | 186   } | 
| 189 | 187 | 
| 190   // AnimationCurve implementation | 188   // AnimationCurve implementation | 
| 191   base::TimeDelta Duration() const override; | 189   base::TimeDelta Duration() const override; | 
| 192   scoped_ptr<AnimationCurve> Clone() const override; | 190   scoped_ptr<AnimationCurve> Clone() const override; | 
| 193 | 191 | 
| 194   // TransformAnimationCurve implementation | 192   // TransformAnimationCurve implementation | 
| 195   gfx::Transform GetValue(double t) const override; | 193   gfx::Transform GetValue(base::TimeDelta t) const override; | 
| 196   bool AnimatedBoundsForBox(const gfx::BoxF& box, | 194   bool AnimatedBoundsForBox(const gfx::BoxF& box, | 
| 197                             gfx::BoxF* bounds) const override; | 195                             gfx::BoxF* bounds) const override; | 
| 198   bool AffectsScale() const override; | 196   bool AffectsScale() const override; | 
| 199   bool IsTranslation() const override; | 197   bool IsTranslation() const override; | 
| 200   bool MaximumTargetScale(bool forward_direction, | 198   bool MaximumTargetScale(bool forward_direction, | 
| 201                           float* max_scale) const override; | 199                           float* max_scale) const override; | 
| 202 | 200 | 
| 203  private: | 201  private: | 
| 204   KeyframedTransformAnimationCurve(); | 202   KeyframedTransformAnimationCurve(); | 
| 205 | 203 | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 222   void AddKeyframe(scoped_ptr<FilterKeyframe> keyframe); | 220   void AddKeyframe(scoped_ptr<FilterKeyframe> keyframe); | 
| 223   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 221   void SetTimingFunction(scoped_ptr<TimingFunction> timing_function) { | 
| 224     timing_function_ = timing_function.Pass(); | 222     timing_function_ = timing_function.Pass(); | 
| 225   } | 223   } | 
| 226 | 224 | 
| 227   // AnimationCurve implementation | 225   // AnimationCurve implementation | 
| 228   base::TimeDelta Duration() const override; | 226   base::TimeDelta Duration() const override; | 
| 229   scoped_ptr<AnimationCurve> Clone() const override; | 227   scoped_ptr<AnimationCurve> Clone() const override; | 
| 230 | 228 | 
| 231   // FilterAnimationCurve implementation | 229   // FilterAnimationCurve implementation | 
| 232   FilterOperations GetValue(double t) const override; | 230   FilterOperations GetValue(base::TimeDelta t) const override; | 
| 233   bool HasFilterThatMovesPixels() const override; | 231   bool HasFilterThatMovesPixels() const override; | 
| 234 | 232 | 
| 235  private: | 233  private: | 
| 236   KeyframedFilterAnimationCurve(); | 234   KeyframedFilterAnimationCurve(); | 
| 237 | 235 | 
| 238   // Always sorted in order of increasing time. No two keyframes have the | 236   // Always sorted in order of increasing time. No two keyframes have the | 
| 239   // same time. | 237   // same time. | 
| 240   ScopedPtrVector<FilterKeyframe> keyframes_; | 238   ScopedPtrVector<FilterKeyframe> keyframes_; | 
| 241   scoped_ptr<TimingFunction> timing_function_; | 239   scoped_ptr<TimingFunction> timing_function_; | 
| 242 | 240 | 
| 243   DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve); | 241   DISALLOW_COPY_AND_ASSIGN(KeyframedFilterAnimationCurve); | 
| 244 }; | 242 }; | 
| 245 | 243 | 
| 246 }  // namespace cc | 244 }  // namespace cc | 
| 247 | 245 | 
| 248 #endif  // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | 246 #endif  // CC_ANIMATION_KEYFRAMED_ANIMATION_CURVE_H_ | 
| OLD | NEW | 
|---|