Merge "Remove blur from launcher when in overview" into sc-dev am: 997ac6cddc

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14829892

Change-Id: Ie82910a945ffe7e2d483d49c88602ceb8d0842df
This commit is contained in:
Lucas Dupin
2021-06-04 20:03:51 +00:00
committed by Automerger Merge Worker
@@ -161,7 +161,7 @@ public class DepthController implements StateHandler<LauncherState>,
if (mSurface != surface) { if (mSurface != surface) {
mSurface = surface; mSurface = surface;
if (surface != null) { if (surface != null) {
setDepth(mDepth); dispatchTransactionSurface(mDepth);
} }
} }
} }
@@ -175,6 +175,8 @@ public class DepthController implements StateHandler<LauncherState>,
float toDepth = toState.getDepth(mLauncher); float toDepth = toState.getDepth(mLauncher);
if (Float.compare(mDepth, toDepth) != 0) { if (Float.compare(mDepth, toDepth) != 0) {
setDepth(toDepth); setDepth(toDepth);
} else if (toState == LauncherState.OVERVIEW) {
dispatchTransactionSurface(mDepth);
} }
} }
@@ -200,26 +202,35 @@ public class DepthController implements StateHandler<LauncherState>,
if (Float.compare(mDepth, depthF) == 0) { if (Float.compare(mDepth, depthF) == 0) {
return; return;
} }
if (dispatchTransactionSurface(depthF)) {
mDepth = depthF;
}
}
private boolean dispatchTransactionSurface(float depth) {
boolean supportsBlur = BlurUtils.supportsBlursOnWindows(); boolean supportsBlur = BlurUtils.supportsBlursOnWindows();
if (supportsBlur && (mSurface == null || !mSurface.isValid())) { if (supportsBlur && (mSurface == null || !mSurface.isValid())) {
return; return false;
} }
mDepth = depthF;
ensureDependencies(); ensureDependencies();
IBinder windowToken = mLauncher.getRootView().getWindowToken(); IBinder windowToken = mLauncher.getRootView().getWindowToken();
if (windowToken != null) { if (windowToken != null) {
mWallpaperManager.setWallpaperZoomOut(windowToken, mDepth); mWallpaperManager.setWallpaperZoomOut(windowToken, depth);
} }
if (supportsBlur) { if (supportsBlur) {
boolean isOpaque = mLauncher.getScrimView().isFullyOpaque(); // We cannot mark the window as opaque in overview because there will be an app window
int blur = isOpaque ? 0 : (int) (mDepth * mMaxBlurRadius); // below the launcher layer, and we need to draw it -- without blurs.
boolean isOverview = mLauncher.isInState(LauncherState.OVERVIEW);
boolean opaque = mLauncher.getScrimView().isFullyOpaque() && !isOverview;
int blur = opaque || isOverview ? 0 : (int) (depth * mMaxBlurRadius);
new SurfaceControl.Transaction() new SurfaceControl.Transaction()
.setBackgroundBlurRadius(mSurface, blur) .setBackgroundBlurRadius(mSurface, blur)
.setOpaque(mSurface, isOpaque) .setOpaque(mSurface, opaque)
.apply(); .apply();
} }
return true;
} }
@Override @Override