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.
5 #ifndef CC_ANIMATION_TIMING_FUNCTION_H_
6 #define CC_ANIMATION_TIMING_FUNCTION_H_
8 #include "cc/base/cc_export.h"
9 #include "ui/gfx/geometry/cubic_bezier.h"
13 // See http://www.w3.org/TR/css3-transitions/.
14 class CC_EXPORT TimingFunction {
16 virtual ~TimingFunction();
18 virtual float GetValue(double t) const = 0;
19 virtual float Velocity(double time) const = 0;
20 // The smallest and largest values returned by GetValue for inputs in [0, 1].
21 virtual void Range(float* min, float* max) const = 0;
22 virtual scoped_ptr<TimingFunction> Clone() const = 0;
28 DISALLOW_ASSIGN(TimingFunction);
31 class CC_EXPORT CubicBezierTimingFunction : public TimingFunction {
33 static scoped_ptr<CubicBezierTimingFunction> Create(double x1, double y1,
34 double x2, double y2);
35 ~CubicBezierTimingFunction() override;
37 // TimingFunction implementation.
38 float GetValue(double time) const override;
39 float Velocity(double time) const override;
40 void Range(float* min, float* max) const override;
41 scoped_ptr<TimingFunction> Clone() const override;
44 CubicBezierTimingFunction(double x1, double y1, double x2, double y2);
46 gfx::CubicBezier bezier_;
49 DISALLOW_ASSIGN(CubicBezierTimingFunction);
52 class CC_EXPORT EaseTimingFunction {
54 static scoped_ptr<TimingFunction> Create();
57 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseTimingFunction);
60 class CC_EXPORT EaseInTimingFunction {
62 static scoped_ptr<TimingFunction> Create();
65 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInTimingFunction);
68 class CC_EXPORT EaseOutTimingFunction {
70 static scoped_ptr<TimingFunction> Create();
73 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseOutTimingFunction);
76 class CC_EXPORT EaseInOutTimingFunction {
78 static scoped_ptr<TimingFunction> Create();
81 DISALLOW_IMPLICIT_CONSTRUCTORS(EaseInOutTimingFunction);
86 #endif // CC_ANIMATION_TIMING_FUNCTION_H_