Merge "Apply depth even when surface is null" into sc-dev am: 818ed4b794

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

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