diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 1d9a5d5a67..34c08d6b2e 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -65,7 +65,9 @@ import android.os.Looper; import android.os.SystemProperties; import android.util.Pair; import android.util.Size; +import android.view.SurfaceControl; import android.view.View; +import android.view.ViewRootImpl; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; @@ -97,6 +99,7 @@ import com.android.quickstep.views.FloatingWidgetView; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.ActivityCompat; import com.android.systemui.shared.system.ActivityOptionsCompat; +import com.android.systemui.shared.system.BlurUtils; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.RemoteAnimationAdapterCompat; @@ -920,12 +923,39 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener BACKGROUND_APP.getDepth(mLauncher)) .setDuration(APP_LAUNCH_DURATION); if (allowBlurringLauncher) { - depthController.setSurfaceToApp(RemoteAnimationProvider.findLowestOpaqueLayerTarget( - appTargets, MODE_OPENING)); + final SurfaceControl dimLayer; + if (BlurUtils.supportsBlursOnWindows()) { + // Create a temporary effect layer, that lives on top of launcher, so we can apply + // the blur to it. The EffectLayer will be fullscreen, which will help with caching + // optimizations on the SurfaceFlinger side: + // - Results would be able to be cached as a texture + // - There won't be texture allocation overhead, because EffectLayers don't have + // buffers + ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl(); + SurfaceControl parent = viewRootImpl != null + ? viewRootImpl.getSurfaceControl() + : null; + dimLayer = new SurfaceControl.Builder() + .setName("Blur layer") + .setParent(parent) + .setOpaque(false) + .setHidden(false) + .setEffectLayer() + .build(); + } else { + dimLayer = null; + } + + depthController.setSurface(dimLayer); backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - depthController.setSurfaceToApp(null); + depthController.setSurface(null); + if (dimLayer != null) { + new SurfaceControl.Transaction() + .remove(dimLayer) + .apply(); + } } }); } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index e608885491..46ef6982ff 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -25,7 +25,9 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.os.IBinder; import android.util.FloatProperty; +import android.view.SurfaceControl; import android.view.View; +import android.view.ViewRootImpl; import android.view.ViewTreeObserver; import com.android.launcher3.BaseActivity; @@ -37,9 +39,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.statemanager.StateManager.StateHandler; import com.android.launcher3.states.StateAnimationConfig; import com.android.systemui.shared.system.BlurUtils; -import com.android.systemui.shared.system.RemoteAnimationTargetCompat; -import com.android.systemui.shared.system.SurfaceControlCompat; -import com.android.systemui.shared.system.TransactionCompat; import com.android.systemui.shared.system.WallpaperManagerCompat; /** @@ -91,7 +90,8 @@ public class DepthController implements StateHandler, @Override public void onDraw() { View view = mLauncher.getDragLayer(); - setSurface(new SurfaceControlCompat(view)); + ViewRootImpl viewRootImpl = view.getViewRootImpl(); + setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null); view.post(() -> view.getViewTreeObserver().removeOnDrawListener(this)); } }; @@ -102,7 +102,7 @@ public class DepthController implements StateHandler, */ private int mMaxBlurRadius; private WallpaperManagerCompat mWallpaperManager; - private SurfaceControlCompat mSurface; + private SurfaceControl mSurface; /** * Ratio from 0 to 1, where 0 is fully zoomed out, and 1 is zoomed in. * @see android.service.wallpaper.WallpaperService.Engine#onZoomChanged(float) @@ -157,11 +157,7 @@ public class DepthController implements StateHandler, /** * Sets the specified app target surface to apply the blur to. */ - public void setSurfaceToApp(RemoteAnimationTargetCompat target) { - setSurface(target == null ? null : target.leash); - } - - private void setSurface(SurfaceControlCompat surface) { + public void setSurface(SurfaceControl surface) { if (mSurface != surface) { mSurface = surface; if (surface != null) { @@ -219,7 +215,7 @@ public class DepthController implements StateHandler, if (supportsBlur) { boolean isOpaque = mLauncher.getScrimView().isFullyOpaque(); int blur = isOpaque ? 0 : (int) (mDepth * mMaxBlurRadius); - new TransactionCompat() + new SurfaceControl.Transaction() .setBackgroundBlurRadius(mSurface, blur) .setOpaque(mSurface, isOpaque) .apply();