Home | History | Annotate | Download | only in hwui
      1 /*
      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 
     19 #include <stddef.h>
     20 
     21 #include <cutils/compiler.h>
     22 
     23 namespace android {
     24 namespace uirenderer {
     25 
     26 class Interpolator {
     27 public:
     28     virtual ~Interpolator() {}
     29 
     30     virtual float interpolate(float input) = 0;
     31 
     32     static Interpolator* createDefaultInterpolator();
     33 
     34 protected:
     35     Interpolator() {}
     36 };
     37 
     38 class ANDROID_API AccelerateDecelerateInterpolator : public Interpolator {
     39 public:
     40     virtual float interpolate(float input);
     41 };
     42 
     43 class ANDROID_API AccelerateInterpolator : public Interpolator {
     44 public:
     45     AccelerateInterpolator(float factor) : mFactor(factor), mDoubleFactor(factor*2) {}
     46     virtual float interpolate(float input);
     47 private:
     48     const float mFactor;
     49     const float mDoubleFactor;
     50 };
     51 
     52 class ANDROID_API AnticipateInterpolator : public Interpolator {
     53 public:
     54     AnticipateInterpolator(float tension) : mTension(tension) {}
     55     virtual float interpolate(float input);
     56 private:
     57     const float mTension;
     58 };
     59 
     60 class ANDROID_API AnticipateOvershootInterpolator : public Interpolator {
     61 public:
     62     AnticipateOvershootInterpolator(float tension) : mTension(tension) {}
     63     virtual float interpolate(float input);
     64 private:
     65     const float mTension;
     66 };
     67 
     68 class ANDROID_API BounceInterpolator : public Interpolator {
     69 public:
     70     virtual float interpolate(float input);
     71 };
     72 
     73 class ANDROID_API CycleInterpolator : public Interpolator {
     74 public:
     75     CycleInterpolator(float cycles) : mCycles(cycles) {}
     76     virtual float interpolate(float input);
     77 private:
     78     const float mCycles;
     79 };
     80 
     81 class ANDROID_API DecelerateInterpolator : public Interpolator {
     82 public:
     83     DecelerateInterpolator(float factor) : mFactor(factor) {}
     84     virtual float interpolate(float input);
     85 private:
     86     const float mFactor;
     87 };
     88 
     89 class ANDROID_API LinearInterpolator : public Interpolator {
     90 public:
     91     virtual float interpolate(float input) { return input; }
     92 };
     93 
     94 class ANDROID_API OvershootInterpolator : public Interpolator {
     95 public:
     96     OvershootInterpolator(float tension) : mTension(tension) {}
     97     virtual float interpolate(float input);
     98 private:
     99     const float mTension;
    100 };
    101 
    102 class ANDROID_API LUTInterpolator : public Interpolator {
    103 public:
    104     LUTInterpolator(float* values, size_t size);
    105     ~LUTInterpolator();
    106 
    107     virtual float interpolate(float input);
    108 
    109 private:
    110     float* mValues;
    111     size_t mSize;
    112 };
    113 
    114 } /* namespace uirenderer */
    115 } /* namespace android */
    116 
    117 #endif /* INTERPOLATOR_H */
    118