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

Commit ab4c4f4f authored by Romain Guy's avatar Romain Guy
Browse files

Remove unnecessary framework allocations

These allocations were frequently triggered by the home screen. This change
removes dozens of allocations during page scrolls on home.

Change-Id: I7289efa28ecf5bd62459042b10062aa9cf0432dd
parent d0c66f6a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -9187,7 +9187,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    }
    public final boolean getLocalVisibleRect(Rect r) {
        Point offset = new Point();
        final Point offset = mAttachInfo != null ? mAttachInfo.mPoint : new Point();
        if (getGlobalVisibleRect(r, offset)) {
            r.offset(-offset.x, -offset.y); // make r local
            return true;
@@ -17006,6 +17006,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
         */
        final boolean mDebugLayout = SystemProperties.getBoolean(DEBUG_LAYOUT_PROPERTY, false);
        /**
         * Point used to compute visible regions.
         */
        final Point mPoint = new Point();
        /**
         * Creates a new set of attachment information with the specified
         * events handler and thread.
+22 −14
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ public class ProgressBar extends View {
    private boolean mOnlyIndeterminate;
    private Transformation mTransformation;
    private AlphaAnimation mAnimation;
    private boolean mHasAnimation;
    private Drawable mIndeterminateDrawable;
    private Drawable mProgressDrawable;
    private Drawable mCurrentDrawable;
@@ -670,18 +671,14 @@ public class ProgressBar extends View {
        if (mUiThreadId == Thread.currentThread().getId()) {
            doRefreshProgress(id, progress, fromUser, true);
        } else {
            RefreshProgressRunnable r;
            if (mRefreshProgressRunnable != null) {
                // Use cached RefreshProgressRunnable if available
                r = mRefreshProgressRunnable;
            } else {
                // Make a new one
                r = new RefreshProgressRunnable();
            if (mRefreshProgressRunnable == null) {
                mRefreshProgressRunnable = new RefreshProgressRunnable();
            }

            final RefreshData rd = RefreshData.obtain(id, progress, fromUser);
            mRefreshData.add(rd);
            if (mAttached && !mRefreshIsPosted) {
                post(r);
                post(mRefreshProgressRunnable);
                mRefreshIsPosted = true;
            }
        }
@@ -860,14 +857,26 @@ public class ProgressBar extends View {

        if (mIndeterminateDrawable instanceof Animatable) {
            mShouldStartAnimationDrawable = true;
            mAnimation = null;
            mHasAnimation = false;
        } else {
            mHasAnimation = true;

            if (mInterpolator == null) {
                mInterpolator = new LinearInterpolator();
            }
    
            if (mTransformation == null) {
                mTransformation = new Transformation();
            } else {
                mTransformation.clear();
            }
            
            if (mAnimation == null) {
                mAnimation = new AlphaAnimation(0.0f, 1.0f);
            } else {
                mAnimation.reset();
            }

            mAnimation.setRepeatMode(mBehavior);
            mAnimation.setRepeatCount(Animation.INFINITE);
            mAnimation.setDuration(mDuration);
@@ -881,8 +890,7 @@ public class ProgressBar extends View {
     * <p>Stop the indeterminate progress animation.</p>
     */
    void stopAnimation() {
        mAnimation = null;
        mTransformation = null;
        mHasAnimation = false;
        if (mIndeterminateDrawable instanceof Animatable) {
            ((Animatable) mIndeterminateDrawable).stop();
            mShouldStartAnimationDrawable = false;
@@ -1030,7 +1038,7 @@ public class ProgressBar extends View {
            canvas.save();
            canvas.translate(mPaddingLeft, mPaddingTop);
            long time = getDrawingTime();
            if (mAnimation != null) {
            if (mHasAnimation) {
                mAnimation.getTransformation(time, mTransformation);
                float scale = mTransformation.getAlpha();
                try {