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

Commit 9791a5a7 authored by Omprakash Dhyade's avatar Omprakash Dhyade Committed by Linux Build Service Account
Browse files

Perf: Add cpu boost for overscroller fling.

Use perflock api's to add cpu boost for
overscroller fling. 2 Cores are made online
with minumum 1.1GHz nominal cpu freq for the
duration of the fling.
Cpu boost will be controlled by
config_enableCpuBoostForOverScrollerFling.
Default value of config is false and to turn
on use device specific overlay files.

Change-Id: If0a545e126d157d7e2fdaecc1108d41469172cd6
parent cfc33da2
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
@@ -602,6 +603,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;
@@ -646,6 +656,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) {
@@ -693,6 +706,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.
@@ -763,6 +781,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, 0x1E01, 0x20B, 0x30B, 0x1C00);
                }
            }

            mSplineDistance = (int) (totalDistance * Math.signum(velocity));
+5 −0
Original line number Diff line number Diff line
@@ -1966,5 +1966,10 @@
        <item>Trying to delete contacts</item>
        <item>Trying to delete call log</item>
        <item>Trying to turn on mobile data</item>

    </string-array>

    <!-- Whether cpu boost is enabled for overscroller fling. -->
    <bool name="config_enableCpuBoostForOverScrollerFling">false</bool>

</resources>
+4 −0
Original line number Diff line number Diff line
@@ -2122,4 +2122,8 @@
  <!-- Data Connectivity Error Configurations -->
  <java-symbol type="bool" name="config_reject_ggsn_perm_failure" />
  <java-symbol type="bool" name="config_protocol_errors_perm_failure" />

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

</resources>