Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1d3147c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Perf: Add cpu boost for overscroller fling."

parents 3cb75c65 e5b3253d
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.Log;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import org.codeaurora.Performance;

/**
 * This class encapsulates scrolling with the ability to overshoot the bounds
@@ -601,6 +602,15 @@ 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 Performance mPerf = null;
        private boolean mIsPerfLockAcquired = false;
        private boolean mIsPerfBoostEnabled = false;

        static {
            float x_min = 0.0f;
            float y_min = 0.0f;
@@ -645,6 +655,9 @@ 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);
        }

        void updateScroll(float q) {
@@ -692,6 +705,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.
@@ -762,6 +780,14 @@ public class OverScroller {
            if (velocity != 0) {
                mDuration = mSplineDuration = getSplineFlingDuration(velocity);
                totalDistance = getSplineFlingDistance(velocity);
                if (mPerf == null && mIsPerfBoostEnabled) {
                    mPerf = new Performance();
                }

                if (mPerf != null) {
                    mIsPerfLockAcquired = true;
                    mPerf.perfLockAcquire(mDuration, mPerf.CPUS_ON_2, 0x20B, 0x30B);
                }
            }

            mSplineDistance = (int) (totalDistance * Math.signum(velocity));
+3 −0
Original line number Diff line number Diff line
@@ -1307,4 +1307,7 @@
    <!-- set to false if we dont need to consider data
         service state to display signal strength bars -->
    <bool name="config_combined_signal">true</bool>

    <!-- Whether cpu boost is enabled for overscroller fling. -->
    <bool name="config_enableCpuBoostForOverScrollerFling">false</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -1765,4 +1765,7 @@
  <java-symbol type="dimen" name="subtitle_shadow_radius" />
  <java-symbol type="dimen" name="subtitle_shadow_offset" />
  <java-symbol type="dimen" name="subtitle_outline_width" />

  <!-- cpu boost for overscroller fling -->
  <java-symbol type="bool" name="config_enableCpuBoostForOverScrollerFling" />
</resources>