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

Commit ebb2d8d7 authored by Jeff Brown's avatar Jeff Brown
Browse files

Enable vsync traversals by default.

Improved how the various callbacks are managed and sequenced
to reduce code duplication.

Added a heuristic to avoid postponing traversals until
the next vsync frame if we did not actually do any drawing during
the previous frame.  This helps in the very common case where
drawing occurs in response to input.

Change-Id: I277d9eeaf50408f8745a3cfd181db1d140770658
parent 70825161
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -647,7 +647,7 @@ public class ValueAnimator extends Animator {
            // onAnimate to process the next frame of the animations.
            if (!mAnimationScheduled
                    && (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty())) {
                mChoreographer.postAnimationCallback(this, null);
                mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, this, null);
                mAnimationScheduled = true;
            }
        }
+166 −214

File changed.

Preview size limit exceeded, changes collapsed.

+13 −8
Original line number Diff line number Diff line
@@ -8981,7 +8981,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    public void postOnAnimation(Runnable action) {
        final AttachInfo attachInfo = mAttachInfo;
        if (attachInfo != null) {
            attachInfo.mViewRootImpl.mChoreographer.postAnimationCallback(action, null);
            attachInfo.mViewRootImpl.mChoreographer.postCallback(
                    Choreographer.CALLBACK_ANIMATION, action, null);
        } else {
            // Assume that post will succeed later
            ViewRootImpl.getRunQueue().post(action);
@@ -9005,8 +9006,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    public void postOnAnimationDelayed(Runnable action, long delayMillis) {
        final AttachInfo attachInfo = mAttachInfo;
        if (attachInfo != null) {
            attachInfo.mViewRootImpl.mChoreographer.postAnimationCallbackDelayed(
                    action, null, delayMillis);
            attachInfo.mViewRootImpl.mChoreographer.postCallbackDelayed(
                    Choreographer.CALLBACK_ANIMATION, action, null, delayMillis);
        } else {
            // Assume that post will succeed later
            ViewRootImpl.getRunQueue().postDelayed(action, delayMillis);
@@ -9031,7 +9032,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
            final AttachInfo attachInfo = mAttachInfo;
            if (attachInfo != null) {
                attachInfo.mHandler.removeCallbacks(action);
                attachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(action, null);
                attachInfo.mViewRootImpl.mChoreographer.removeCallbacks(
                        Choreographer.CALLBACK_ANIMATION, action, null);
            } else {
                // Assume that post will succeed later
                ViewRootImpl.getRunQueue().removeCallbacks(action);
@@ -12226,8 +12228,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        if (verifyDrawable(who) && what != null) {
            final long delay = when - SystemClock.uptimeMillis();
            if (mAttachInfo != null) {
                mAttachInfo.mViewRootImpl.mChoreographer.postAnimationCallbackDelayed(
                        what, who, Choreographer.subtractFrameDelay(delay));
                mAttachInfo.mViewRootImpl.mChoreographer.postCallbackDelayed(
                        Choreographer.CALLBACK_ANIMATION, what, who,
                        Choreographer.subtractFrameDelay(delay));
            } else {
                ViewRootImpl.getRunQueue().postDelayed(what, delay);
            }
@@ -12243,7 +12246,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    public void unscheduleDrawable(Drawable who, Runnable what) {
        if (verifyDrawable(who) && what != null) {
            if (mAttachInfo != null) {
                mAttachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(what, who);
                mAttachInfo.mViewRootImpl.mChoreographer.removeCallbacks(
                        Choreographer.CALLBACK_ANIMATION, what, who);
            } else {
                ViewRootImpl.getRunQueue().removeCallbacks(what);
            }
@@ -12261,7 +12265,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
    public void unscheduleDrawable(Drawable who) {
        if (mAttachInfo != null && who != null) {
            mAttachInfo.mViewRootImpl.mChoreographer.removeAnimationCallbacks(null, who);
            mAttachInfo.mViewRootImpl.mChoreographer.removeCallbacks(
                    Choreographer.CALLBACK_ANIMATION, null, who);
        }
    }
+114 −84

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -8749,7 +8749,7 @@ public class WindowManagerService extends IWindowManager.Stub

    void scheduleAnimationLocked() {
        if (!mAnimationScheduled) {
            mChoreographer.postAnimationCallback(mAnimationRunnable, null);
            mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, mAnimationRunnable, null);
            mAnimationScheduled = true;
        }
    }