diff options
Diffstat (limited to 'libs/hwui/Interpolator.cpp')
-rw-r--r-- | libs/hwui/Interpolator.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/libs/hwui/Interpolator.cpp b/libs/hwui/Interpolator.cpp index d740c038f36d..7bdca2ee0f00 100644 --- a/libs/hwui/Interpolator.cpp +++ b/libs/hwui/Interpolator.cpp @@ -54,8 +54,10 @@ static float o(float t, float s) { } float AnticipateOvershootInterpolator::interpolate(float t) { - if (t < 0.5f) return 0.5f * a(t * 2.0f, mTension); - else return 0.5f * (o(t * 2.0f - 2.0f, mTension) + 2.0f); + if (t < 0.5f) + return 0.5f * a(t * 2.0f, mTension); + else + return 0.5f * (o(t * 2.0f - 2.0f, mTension) + 2.0f); } static float bounce(float t) { @@ -64,10 +66,14 @@ static float bounce(float t) { float BounceInterpolator::interpolate(float t) { t *= 1.1226f; - if (t < 0.3535f) return bounce(t); - else if (t < 0.7408f) return bounce(t - 0.54719f) + 0.7f; - else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f; - else return bounce(t - 1.0435f) + 0.95f; + if (t < 0.3535f) + return bounce(t); + else if (t < 0.7408f) + return bounce(t - 0.54719f) + 0.7f; + else if (t < 0.9644f) + return bounce(t - 0.8526f) + 0.9f; + else + return bounce(t - 1.0435f) + 0.95f; } float CycleInterpolator::interpolate(float input) { @@ -119,16 +125,11 @@ float PathInterpolator::interpolate(float t) { float startY = mY[startIndex]; float endY = mY[endIndex]; return startY + (fraction * (endY - startY)); - } -LUTInterpolator::LUTInterpolator(float* values, size_t size) - : mValues(values) - , mSize(size) { -} +LUTInterpolator::LUTInterpolator(float* values, size_t size) : mValues(values), mSize(size) {} -LUTInterpolator::~LUTInterpolator() { -} +LUTInterpolator::~LUTInterpolator() {} float LUTInterpolator::interpolate(float input) { // lut position should only be at the end of the table when input is 1f. @@ -140,10 +141,12 @@ float LUTInterpolator::interpolate(float input) { float ipart, weight; weight = modff(lutpos, &ipart); - int i1 = (int) ipart; - int i2 = std::min(i1 + 1, (int) mSize - 1); + int i1 = (int)ipart; + int i2 = std::min(i1 + 1, (int)mSize - 1); - LOG_ALWAYS_FATAL_IF(i1 < 0 || i2 < 0, "negatives in interpolation!" + LOG_ALWAYS_FATAL_IF( + i1 < 0 || i2 < 0, + "negatives in interpolation!" " i1=%d, i2=%d, input=%f, lutpos=%f, size=%zu, values=%p, ipart=%f, weight=%f", i1, i2, input, lutpos, mSize, mValues.get(), ipart, weight); @@ -153,6 +156,5 @@ float LUTInterpolator::interpolate(float input) { return MathUtils::lerp(v1, v2, weight); } - } /* namespace uirenderer */ } /* namespace android */ |