From 4a7acaed3779b9e2666813628e5a0d47da3d53dc Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 26 Jul 2021 11:19:39 -0700 Subject: [PATCH] Request early wake-up when zooming This way we'll be less likely to jank on 120Hz devices. Test: manual Fixes: 194680560 Change-Id: Ieff93f234701649514f8905c20c19cef231c816b --- .../statehandlers/DepthController.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 370fb8ef7c..6cfbf62a86 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -125,6 +125,10 @@ public class DepthController implements StateHandler, * If we're launching and app and should not be blurring the screen for performance reasons. */ private boolean mBlurDisabledForAppLaunch; + /** + * If we requested early wake-up offsets to SurfaceFlinger. + */ + private boolean mInEarlyWakeUp; // Workaround for animating the depth when multiwindow mode changes. private boolean mIgnoreStateChangesDuringMultiWindowAnimation = false; @@ -270,10 +274,21 @@ public class DepthController implements StateHandler, int blur = opaque || isOverview || !mCrossWindowBlursEnabled || mBlurDisabledForAppLaunch ? 0 : (int) (depth * mMaxBlurRadius); - new SurfaceControl.Transaction() + SurfaceControl.Transaction transaction = new SurfaceControl.Transaction() .setBackgroundBlurRadius(mSurface, blur) - .setOpaque(mSurface, opaque) - .apply(); + .setOpaque(mSurface, opaque); + + // Set early wake-up flags when we know we're executing an expensive operation, this way + // SurfaceFlinger will adjust its internal offsets to avoid jank. + boolean wantsEarlyWakeUp = depth > 0 && depth < 1; + if (wantsEarlyWakeUp && !mInEarlyWakeUp) { + transaction.setEarlyWakeupStart(); + mInEarlyWakeUp = true; + } else if (!wantsEarlyWakeUp && mInEarlyWakeUp) { + transaction.setEarlyWakeupEnd(); + mInEarlyWakeUp = false; + } + transaction.apply(); } return true; }