blob: dfa0a85bce416d0c524b57c4bd2f7e3ee1a46085 [file] [log] [blame]
John Recke45b1fd2014-04-15 09:50:16 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef INTERPOLATOR_H
17#define INTERPOLATOR_H
18
John Reck315c3292014-05-09 19:21:04 -070019#include <stddef.h>
20
21#include <cutils/compiler.h>
22
John Recke45b1fd2014-04-15 09:50:16 -070023namespace android {
24namespace uirenderer {
25
26class Interpolator {
27public:
28 virtual ~Interpolator() {}
29
30 virtual float interpolate(float input) = 0;
31
32 static Interpolator* createDefaultInterpolator();
33
34protected:
35 Interpolator() {}
36};
37
John Reck315c3292014-05-09 19:21:04 -070038class ANDROID_API AccelerateDecelerateInterpolator : public Interpolator {
John Recke45b1fd2014-04-15 09:50:16 -070039public:
John Recke45b1fd2014-04-15 09:50:16 -070040 virtual float interpolate(float input);
41};
42
John Reckc8ac7752014-05-12 16:39:41 -070043class ANDROID_API AccelerateInterpolator : public Interpolator {
44public:
45 AccelerateInterpolator(float factor) : mFactor(factor), mDoubleFactor(factor*2) {}
46 virtual float interpolate(float input);
47private:
48 const float mFactor;
49 const float mDoubleFactor;
50};
51
52class ANDROID_API AnticipateInterpolator : public Interpolator {
53public:
54 AnticipateInterpolator(float tension) : mTension(tension) {}
55 virtual float interpolate(float input);
56private:
57 const float mTension;
58};
59
60class ANDROID_API AnticipateOvershootInterpolator : public Interpolator {
61public:
62 AnticipateOvershootInterpolator(float tension) : mTension(tension) {}
63 virtual float interpolate(float input);
64private:
65 const float mTension;
66};
67
68class ANDROID_API BounceInterpolator : public Interpolator {
69public:
70 virtual float interpolate(float input);
71};
72
73class ANDROID_API CycleInterpolator : public Interpolator {
74public:
75 CycleInterpolator(float cycles) : mCycles(cycles) {}
76 virtual float interpolate(float input);
77private:
78 const float mCycles;
79};
80
81class ANDROID_API DecelerateInterpolator : public Interpolator {
82public:
83 DecelerateInterpolator(float factor) : mFactor(factor) {}
84 virtual float interpolate(float input);
85private:
86 const float mFactor;
87};
88
89class ANDROID_API LinearInterpolator : public Interpolator {
90public:
91 virtual float interpolate(float input) { return input; }
92};
93
94class ANDROID_API OvershootInterpolator : public Interpolator {
95public:
96 OvershootInterpolator(float tension) : mTension(tension) {}
97 virtual float interpolate(float input);
98private:
99 const float mTension;
100};
101
John Reck315c3292014-05-09 19:21:04 -0700102class ANDROID_API LUTInterpolator : public Interpolator {
103public:
104 LUTInterpolator(float* values, size_t size);
105 ~LUTInterpolator();
106
107 virtual float interpolate(float input);
108
109private:
110 float* mValues;
111 size_t mSize;
112};
113
John Recke45b1fd2014-04-15 09:50:16 -0700114} /* namespace uirenderer */
115} /* namespace android */
116
117#endif /* INTERPOLATOR_H */