From 0940834c8cc024985f20bbdd19fb32c73ccb25f2 Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Tue, 29 Nov 2016 13:04:49 -0800 Subject: [PATCH] Fix LUTInterpolator lookup table position calc BUG: 32830741 Test: running progress bar at 5x duration scale, no flickering Change-Id: Ie484bdbfdf18bacc4586e36c5142e4523d08bdaa --- libs/hwui/Interpolator.cpp | 3 ++- .../animation/NativeInterpolatorFactoryHelper_Delegate.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/hwui/Interpolator.cpp b/libs/hwui/Interpolator.cpp index cc47f0052b731..bddb01b97865a 100644 --- a/libs/hwui/Interpolator.cpp +++ b/libs/hwui/Interpolator.cpp @@ -97,7 +97,8 @@ LUTInterpolator::~LUTInterpolator() { } float LUTInterpolator::interpolate(float input) { - float lutpos = input * mSize; + // lut position should only be at the end of the table when input is 1f. + float lutpos = input * (mSize - 1); if (lutpos >= (mSize - 1)) { return mValues[mSize - 1]; } diff --git a/tools/layoutlib/bridge/src/com/android/internal/view/animation/NativeInterpolatorFactoryHelper_Delegate.java b/tools/layoutlib/bridge/src/com/android/internal/view/animation/NativeInterpolatorFactoryHelper_Delegate.java index 0f39e8042883f..ffce1a0496d97 100644 --- a/tools/layoutlib/bridge/src/com/android/internal/view/animation/NativeInterpolatorFactoryHelper_Delegate.java +++ b/tools/layoutlib/bridge/src/com/android/internal/view/animation/NativeInterpolatorFactoryHelper_Delegate.java @@ -104,7 +104,7 @@ public class NativeInterpolatorFactoryHelper_Delegate { @Override public float getInterpolation(float input) { - float lutpos = input * mSize; + float lutpos = input * (mSize - 1); if (lutpos >= (mSize - 1)) { return mValues[mSize - 1]; }