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

Commit dc5bf6a7 authored by George Mount's avatar George Mount
Browse files

Default to using hardware layer during fade transition.

Bug 17499864

When hasOverlappingRendering() is true, a layer is used to
to fade views because performance can be much worse then.
When hasOverlappingRendering() is false, the performance
is not hurt and a layer is not used.

Change-Id: If3fb1c23ffc8d0bef85c9d16df6c26ff4bbd49ac
parent 61ee1eda
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -145,11 +145,20 @@ public class Fade extends Visibility {
        private final View mView;
        private boolean mCanceled = false;
        private float mPausedAlpha = -1;
        private boolean mLayerTypeChanged = false;

        public FadeAnimatorListener(View view) {
            mView = view;
        }

        @Override
        public void onAnimationStart(Animator animator) {
            if (mView.hasOverlappingRendering() && mView.getLayerType() == View.LAYER_TYPE_NONE) {
                mLayerTypeChanged = true;
                mView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            }
        }

        @Override
        public void onAnimationCancel(Animator animator) {
            mCanceled = true;
@@ -163,6 +172,9 @@ public class Fade extends Visibility {
            if (!mCanceled) {
                mView.setTransitionAlpha(1);
            }
            if (mLayerTypeChanged) {
                mView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }

        @Override