- add sources.
[platform/framework/web/crosswalk.git] / src / cc / animation / timing_function.h
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   // The smallest and largest values returned by GetValue for inputs in
23   // [0, 1].
24   virtual void Range(float* min, float* max) const = 0;
25
26  protected:
27   TimingFunction();
28
29  private:
30   DISALLOW_ASSIGN(TimingFunction);
31 };
32
33 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction {
34  public:
35   static scoped_ptr<CubicBezierTimingFunction> Create(double x1, double y1,
36                                                       double x2, double y2);
37   virtual ~CubicBezierTimingFunction();
38
39   // Partial implementation of FloatAnimationCurve.
40   virtual float GetValue(double time) const OVERRIDE;
41   virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
42
43   virtual void Range(float* min, float* max) const OVERRIDE;
44
45  protected:
46   CubicBezierTimingFunction(double x1, double y1, double x2, double y2);
47
48   double x1_;
49   double y1_;
50   double x2_;
51   double y2_;
52
53  private:
54   DISALLOW_ASSIGN(CubicBezierTimingFunction);
55 };
56
57 class CC_EXPORT EaseTimingFunction {
58  public:
59   static scoped_ptr<TimingFunction> Create();
60
61  private:
62   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseTimingFunction);
63 };
64
65 class CC_EXPORT EaseInTimingFunction {
66  public:
67   static scoped_ptr<TimingFunction> Create();
68
69  private:
70   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInTimingFunction);
71 };
72
73 class CC_EXPORT EaseOutTimingFunction {
74  public:
75   static scoped_ptr<TimingFunction> Create();
76
77  private:
78   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseOutTimingFunction);
79 };
80
81 class CC_EXPORT EaseInOutTimingFunction {
82  public:
83   static scoped_ptr<TimingFunction> Create();
84
85  private:
86   DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInOutTimingFunction);
87 };
88
89 }  // namespace cc
90
91 #endif  // CC_ANIMATION_TIMING_FUNCTION_H_