diff options
| author | Shashi Shekar Shankar <ssbang@codeaurora.org> | 2015-07-20 14:35:50 +0530 |
|---|---|---|
| committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:27:24 -0600 |
| commit | 0c3a49a56f827e16d038542b0a81c0e257787995 (patch) | |
| tree | 3a761517bbf210036cd19411679bedac14656d34 /core/java/android/widget | |
| parent | a0c043c88b0abaf53b9b08b5c85776f629a52002 (diff) | |
| download | frameworks_base-0c3a49a56f827e16d038542b0a81c0e257787995.zip frameworks_base-0c3a49a56f827e16d038542b0a81c0e257787995.tar.gz frameworks_base-0c3a49a56f827e16d038542b0a81c0e257787995.tar.bz2 | |
BoostFramework to enchance performance during critical scenarios
Adding Boost APIs which can ensure the best possible resource
availability during critical UX scenarios. These APIs can be
either turned off or dynamically hooked to OEM specific
performance optimizations
Change-Id: Ib1be2400c2c3d2eab9a41667354667557e36605f
Diffstat (limited to 'core/java/android/widget')
| -rw-r--r-- | core/java/android/widget/OverScroller.java | 37 | ||||
| -rw-r--r-- | core/java/android/widget/Scroller.java | 31 |
2 files changed, 68 insertions, 0 deletions
diff --git a/core/java/android/widget/OverScroller.java b/core/java/android/widget/OverScroller.java index 50569d7..4cb1514 100644 --- a/core/java/android/widget/OverScroller.java +++ b/core/java/android/widget/OverScroller.java @@ -22,6 +22,7 @@ import android.util.Log; import android.view.ViewConfiguration; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import android.util.BoostFramework; /** * This class encapsulates scrolling with the ability to overshoot the bounds @@ -599,6 +600,17 @@ public class OverScroller { private static final int CUBIC = 1; private static final int BALLISTIC = 2; + /* + * Perf boost related variables + * Enabled/Disabled using config_enableCpuBoostForOverScrollerFling + * true value turns it on, by default will be turned off + */ + private BoostFramework mPerf = null; + private boolean mIsPerfLockAcquired = false; + private boolean mIsPerfBoostEnabled = false; + private int fBoostTimeOut = 0; + private int fBoostParamVal[]; + static { float x_min = 0.0f; float y_min = 0.0f; @@ -643,6 +655,15 @@ public class OverScroller { * 39.37f // inch/meter * ppi * 0.84f; // look and feel tuning + + mIsPerfBoostEnabled = context.getResources().getBoolean( + com.android.internal.R.bool.config_enableCpuBoostForOverScrollerFling); + if (mIsPerfBoostEnabled) { + fBoostTimeOut = context.getResources().getInteger( + com.android.internal.R.integer.flingboost_timeout_param); + fBoostParamVal = context.getResources().getIntArray( + com.android.internal.R.array.flingboost_param_value); + } } void updateScroll(float q) { @@ -690,6 +711,11 @@ public class OverScroller { } void finish() { + if (mIsPerfLockAcquired && mPerf != null) { + mPerf.perfLockRelease(); + mIsPerfLockAcquired = false; + } + mCurrentPosition = mFinal; // Not reset since WebView relies on this value for fast fling. // TODO: restore when WebView uses the fast fling implemented in this class. @@ -760,6 +786,17 @@ public class OverScroller { if (velocity != 0) { mDuration = mSplineDuration = getSplineFlingDuration(velocity); totalDistance = getSplineFlingDistance(velocity); + if (mPerf == null && mIsPerfBoostEnabled) { + mPerf = new BoostFramework(); + } + + if (mPerf != null) { + mIsPerfLockAcquired = true; + if (0 == fBoostTimeOut) { + fBoostTimeOut = mDuration; + } + mPerf.perfLockAcquire(fBoostTimeOut, fBoostParamVal); + } } mSplineDistance = (int) (totalDistance * Math.signum(velocity)); diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java index 357c9c3..96e6b9d 100644 --- a/core/java/android/widget/Scroller.java +++ b/core/java/android/widget/Scroller.java @@ -22,6 +22,7 @@ import android.os.Build; import android.view.ViewConfiguration; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import android.util.BoostFramework; /** @@ -108,6 +109,16 @@ public class Scroller { private float mDeceleration; private final float mPpi; + /* + * Perf boost related variables + * Enabled/Disabled using config_enableCpuBoostForScroller + * true value turns it on, by default will be turned off + */ + private BoostFramework mPerf = null; + boolean bIsPerfBoostEnabled = false; + private int sBoostTimeOut = 0; + private int sBoostParamVal[]; + // A context-specific coefficient adjusted to physical values. private float mPhysicalCoeff; @@ -167,6 +178,7 @@ public class Scroller { * not to support progressive "flywheel" behavior in flinging. */ public Scroller(Context context, Interpolator interpolator, boolean flywheel) { + boolean bIsPerfBoostEnabled = false; mFinished = true; if (interpolator == null) { mInterpolator = new ViscousFluidInterpolator(); @@ -178,6 +190,18 @@ public class Scroller { mFlywheel = flywheel; mPhysicalCoeff = computeDeceleration(0.84f); // look and feel tuning + bIsPerfBoostEnabled = context.getResources().getBoolean( + com.android.internal.R.bool.config_enableCpuBoostForScroller); + if (bIsPerfBoostEnabled) { + sBoostTimeOut = context.getResources().getInteger( + com.android.internal.R.integer.scrollboost_timeout_param); + sBoostParamVal = context.getResources().getIntArray( + com.android.internal.R.array.scrollboost_param_value); + } + if (mPerf == null && bIsPerfBoostEnabled) { + mPerf = new BoostFramework(); + } + } /** @@ -395,6 +419,13 @@ public class Scroller { mDeltaX = dx; mDeltaY = dy; mDurationReciprocal = 1.0f / (float) mDuration; + + if ((mPerf != null) && (duration != 0)) { + if (0 == sBoostTimeOut) { + sBoostTimeOut = mDuration; + } + mPerf.perfLockAcquire(sBoostTimeOut, sBoostParamVal); + } } /** |
