diff options
| author | Hak Matsuda <hakuro@google.com> | 2013-09-26 20:58:00 -0700 |
|---|---|---|
| committer | Andrew Hsieh <andrewhsieh@google.com> | 2013-10-28 11:41:58 +0800 |
| commit | 5d1c91fb75468fb6daad8aa66de64c5d177f3158 (patch) | |
| tree | 28e6875a55605a20ceb317c7e94d7fb3a51602a4 /ndk/sources/android/helper/interpolator.h | |
| parent | 122d194b36e41ca6291efe6c27e02fc73d2a1683 (diff) | |
| download | android_development-5d1c91fb75468fb6daad8aa66de64c5d177f3158.tar.gz android_development-5d1c91fb75468fb6daad8aa66de64c5d177f3158.tar.bz2 android_development-5d1c91fb75468fb6daad8aa66de64c5d177f3158.zip | |
cleaned code, added pinch gesture detector, better opengl context handling, fixed issues
Change-Id: I26a28374ae74391204586b4584d03cf0c58772c2
Diffstat (limited to 'ndk/sources/android/helper/interpolator.h')
| -rw-r--r-- | ndk/sources/android/helper/interpolator.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ndk/sources/android/helper/interpolator.h b/ndk/sources/android/helper/interpolator.h new file mode 100644 index 000000000..66e887ba6 --- /dev/null +++ b/ndk/sources/android/helper/interpolator.h @@ -0,0 +1,78 @@ +/* + * Copyright 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INTERPOLATOR_H_ +#define INTERPOLATOR_H_ + +#include <jni.h> +#include <errno.h> +#include <time.h> +#include "JNIHelper.h" +#include "perfMonitor.h" +#include <list> + +enum INTERPOLATOR_TYPE +{ + INTERPOLATOR_TYPE_LINEAR, + INTERPOLATOR_TYPE_EASEINQUAD, + INTERPOLATOR_TYPE_EASEOUTQUAD, + INTERPOLATOR_TYPE_EASEINOUTQUAD, + INTERPOLATOR_TYPE_EASEINCUBIC, + INTERPOLATOR_TYPE_EASEOUTCUBIC, + INTERPOLATOR_TYPE_EASEINOUTCUBIC, + INTERPOLATOR_TYPE_EASEINQUART, + INTERPOLATOR_TYPE_EASEINEXPO, + INTERPOLATOR_TYPE_EASEOUTEXPO, +}; + +struct interpolatorParam { + float fDestValue; + INTERPOLATOR_TYPE type; + double dDuration; +}; + +/****************************************************************** + * Interpolates values with several interpolation methods + */ +class interpolator { +private: + double _dStartTime; + double _dDestTime; + INTERPOLATOR_TYPE _type; + + float _fStartValue; + float _fDestValue; + std::list< interpolatorParam > m_listParams; + + float getFormula(INTERPOLATOR_TYPE type, float t, float b, float d, float c); +public: + interpolator(); + ~interpolator(); + + interpolator& set(const float start, + const float dest, + INTERPOLATOR_TYPE type, double duration); + + interpolator& add(const float dest, + INTERPOLATOR_TYPE type, double duration); + + bool update( const double currentTime, float& p ); + + void clear(); +}; + + +#endif /* INTERPOLATOR_H_ */ |
