From c5887ea7a0b82cc5909743ce14cbda1dcf1dfc82 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Fri, 13 May 2016 18:21:48 -0700 Subject: [PATCH] Fix janky multi-window entry animation - Add tracing when drawing ImageWallpaper. - Don't force a redraw in onSurfaceRedrawNeeded. This only adds another unnecessary draw and doesn't do anything useful. onSurfaceRedrawNeeded is only here so the client can block. - Delay entrance animation by one frame so wallpaper can be drawn before the transition is starting. - Add some delay for animating the tasks up in recents to match that delay (it wasn't matched before at all). - Fix an issue where launchedFromHome was wrong while docking. Bug: 28769940 Change-Id: I2b763ed40078541328a1e04ffecf5b0a520fe019 --- .../src/com/android/systemui/ImageWallpaper.java | 5 +++-- .../com/android/systemui/recents/RecentsImpl.java | 2 +- .../recents/views/TaskStackAnimationHelper.java | 3 ++- .../android/systemui/stackdivider/DividerView.java | 12 +++++++----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index a0d9dfe1c1c18..f76a68c9fec0f 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -31,6 +31,7 @@ import android.graphics.Region.Op; import android.opengl.GLUtils; import android.os.AsyncTask; import android.os.SystemProperties; +import android.os.Trace; import android.renderscript.Matrix4f; import android.service.wallpaper.WallpaperService; import android.util.Log; @@ -310,8 +311,6 @@ public class ImageWallpaper extends WallpaperService { Log.d(TAG, "onSurfaceRedrawNeeded"); } super.onSurfaceRedrawNeeded(holder); - - mLastSurfaceHeight = mLastSurfaceWidth = -1; drawFrame(); } @@ -325,6 +324,7 @@ public class ImageWallpaper extends WallpaperService { return; } try { + Trace.traceBegin(Trace.TRACE_TAG_VIEW, "drawWallpaper"); DisplayInfo displayInfo = getDefaultDisplayInfo(); int newRotation = displayInfo.rotation; @@ -419,6 +419,7 @@ public class ImageWallpaper extends WallpaperService { drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels); } } finally { + Trace.traceEnd(Trace.TRACE_TAG_VIEW); if (FIXED_SIZED_SURFACE && !mIsHwAccelerated) { // If the surface is fixed-size, we should only need to // draw it once and then we'll let the window manager diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 611f9f201f1ed..cfc6c52e608b5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -826,7 +826,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks; // Update the launch state that we need in updateHeaderBarLayout() - launchState.launchedFromHome = !useThumbnailTransition; + launchState.launchedFromHome = !useThumbnailTransition && !mLaunchedWhileDocking; launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking; launchState.launchedViaDockGesture = mLaunchedWhileDocking; launchState.launchedViaDragGesture = mDraggingInRecents; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java index cc8e83242fb4d..f4c13d7b8cdce 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java @@ -276,12 +276,13 @@ public class TaskStackAnimationHelper { tv.onStartFrontTaskEnterAnimation(mStackView.mScreenPinningEnabled); } } else if (launchState.launchedViaDockGesture) { - // Animate the tasks up + // Animate the tasks up - add some delay to match the divider animation AnimationProps taskAnimation = new AnimationProps() .setDuration(AnimationProps.BOUNDS, dockGestureAnimDuration + (taskIndexFromBack * DOUBLE_FRAME_OFFSET_MS)) .setInterpolator(AnimationProps.BOUNDS, ENTER_WHILE_DOCKING_INTERPOLATOR) + .setStartDelay(AnimationProps.BOUNDS, 48) .setListener(postAnimationTrigger.decrementOnAnimationEnd()); postAnimationTrigger.increment(); mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation); diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java index 3fc66dd2f62bb..a220f2ed70ec5 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java @@ -1075,11 +1075,13 @@ public class DividerView extends FrameLayout implements OnTouchListener, mAnimateAfterRecentsDrawn = false; updateDockSide(); - // Delay switching resizing mode because this might cause jank in recents animation - // that's long than this animation. - stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), - mLongPressEntraceAnimDuration, Interpolators.FAST_OUT_SLOW_IN, - 200 /* endDelay */); + post(() -> { + // Delay switching resizing mode because this might cause jank in recents animation + // that's longer than this animation. + stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), + mLongPressEntraceAnimDuration, Interpolators.FAST_OUT_SLOW_IN, + 200 /* endDelay */); + }); } if (mGrowAfterRecentsDrawn) { mGrowAfterRecentsDrawn = false;