Home | History | Annotate | Download | only in animation
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_
      6 #define CC_ANIMATION_TIMING_FUNCTION_H_
      7 
      8 #include "cc/animation/animation_curve.h"
      9 #include "cc/base/cc_export.h"
     10 #include "third_party/skia/include/core/SkScalar.h"
     11 
     12 namespace cc {
     13 
     14 // See http://www.w3.org/TR/css3-transitions/.
     15 class CC_EXPORT TimingFunction : public FloatAnimationCurve {
     16  public:
     17   virtual ~TimingFunction();
     18 
     19   // Partial implementation of FloatAnimationCurve.
     20   virtual double Duration() const OVERRIDE;
     21 
     22  protected:
     23   TimingFunction();
     24 
     25  private:
     26   DISALLOW_ASSIGN(TimingFunction);
     27 };
     28 
     29 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction {
     30  public:
     31   static scoped_ptr<CubicBezierTimingFunction> Create(double x1, double y1,
     32                                                       double x2, double y2);
     33   virtual ~CubicBezierTimingFunction();
     34 
     35   // Partial implementation of FloatAnimationCurve.
     36   virtual float GetValue(double time) const OVERRIDE;
     37   virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
     38 
     39  protected:
     40   CubicBezierTimingFunction(double x1, double y1, double x2, double y2);
     41 
     42   double x1_;
     43   double y1_;
     44   double x2_;
     45   double y2_;
     46 
     47  private:
     48   DISALLOW_ASSIGN(CubicBezierTimingFunction);
     49 };
     50 
     51 class CC_EXPORT EaseTimingFunction {
     52  public:
     53   static scoped_ptr<TimingFunction> Create();
     54 
     55  private:
     56   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseTimingFunction);
     57 };
     58 
     59 class CC_EXPORT EaseInTimingFunction {
     60  public:
     61   static scoped_ptr<TimingFunction> Create();
     62 
     63  private:
     64   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInTimingFunction);
     65 };
     66 
     67 class CC_EXPORT EaseOutTimingFunction {
     68  public:
     69   static scoped_ptr<TimingFunction> Create();
     70 
     71  private:
     72   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseOutTimingFunction);
     73 };
     74 
     75 class CC_EXPORT EaseInOutTimingFunction {
     76  public:
     77   static scoped_ptr<TimingFunction> Create();
     78 
     79  private:
     80   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInOutTimingFunction);
     81 };
     82 
     83 }  // namespace cc
     84 
     85 #endif  // CC_ANIMATION_TIMING_FUNCTION_H_
     86