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

Commit 6d354163 authored by Riley Andrews's avatar Riley Andrews
Browse files

[wip] Make the window animator rely on frameTime.

The window animator is looking at cpu time difference
whilst updating animations. Using the choreographer display frame
time will be a much more consistent way of estimating
the time between frames for animation.

Change-Id: If5c4034c6e1b017749d6f4ca727d564805672c39
parent 5208c59a
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.view.SurfaceControl;
import android.view.WindowManagerPolicy;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.Choreographer;

import com.android.server.wm.WindowManagerService.LayoutFields;

@@ -63,7 +64,7 @@ public class WindowAnimator {

    boolean mAnimating;

    final Runnable mAnimationRunnable;
    final Choreographer.FrameCallback mAnimationFrameCallback;

    /** Time of current animation step. Reset on each iteration */
    long mCurrentTime;
@@ -118,12 +119,11 @@ public class WindowAnimator {
        mContext = service.mContext;
        mPolicy = service.mPolicy;

        mAnimationRunnable = new Runnable() {
            @Override
            public void run() {
        mAnimationFrameCallback = new Choreographer.FrameCallback() {
            public void doFrame(long frameTimeNs) {
                synchronized (mService.mWindowMap) {
                    mService.mAnimationScheduled = false;
                    animateLocked();
                    animateLocked(frameTimeNs);
                }
            }
        };
@@ -623,12 +623,12 @@ public class WindowAnimator {


    /** Locked on mService.mWindowMap. */
    private void animateLocked() {
    private void animateLocked(long frameTimeNs) {
        if (!mInitialized) {
            return;
        }

        mCurrentTime = SystemClock.uptimeMillis();
        mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
        mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
        boolean wasAnimating = mAnimating;
        mAnimating = false;
+1 −2
Original line number Diff line number Diff line
@@ -10197,8 +10197,7 @@ public class WindowManagerService extends IWindowManager.Stub
    void scheduleAnimationLocked() {
        if (!mAnimationScheduled) {
            mAnimationScheduled = true;
            mChoreographer.postCallback(
                    Choreographer.CALLBACK_ANIMATION, mAnimator.mAnimationRunnable, null);
            mChoreographer.postFrameCallback(mAnimator.mAnimationFrameCallback);
        }
    }