summaryrefslogtreecommitdiff
path: root/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
diff options
context:
space:
mode:
Diffstat (limited to 'quickstep/src/com/android/launcher3/statehandlers/DepthController.java')
-rw-r--r--quickstep/src/com/android/launcher3/statehandlers/DepthController.java105
1 files changed, 16 insertions, 89 deletions
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
index eda08239d6..8c9ac12bd4 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
+++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
@@ -23,7 +23,6 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_DEPTH_CONTR
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
-import android.app.WallpaperManager;
import android.os.IBinder;
import android.os.SystemProperties;
import android.util.FloatProperty;
@@ -43,8 +42,8 @@ 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.WallpaperManagerCompat;
-import java.io.PrintWriter;
import java.util.function.Consumer;
/**
@@ -53,7 +52,6 @@ import java.util.function.Consumer;
public class DepthController implements StateHandler<LauncherState>,
BaseActivity.MultiWindowModeChangedListener {
- private static final boolean OVERLAY_SCROLL_ENABLED = false;
public static final FloatProperty<DepthController> DEPTH =
new FloatProperty<DepthController>("depth") {
@Override
@@ -98,11 +96,7 @@ public class DepthController implements StateHandler<LauncherState>,
public void onDraw() {
View view = mLauncher.getDragLayer();
ViewRootImpl viewRootImpl = view.getViewRootImpl();
- boolean applied = setSurface(
- viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
- if (!applied) {
- dispatchTransactionSurface(mDepth);
- }
+ setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
view.post(() -> view.getViewTreeObserver().removeOnDrawListener(this));
}
};
@@ -128,38 +122,21 @@ public class DepthController implements StateHandler<LauncherState>,
*/
private int mMaxBlurRadius;
private boolean mCrossWindowBlursEnabled;
- private WallpaperManager mWallpaperManager;
+ private WallpaperManagerCompat mWallpaperManager;
private SurfaceControl mSurface;
/**
- * How visible the -1 overlay is, from 0 to 1.
- */
- private float mOverlayScrollProgress;
- /**
* Ratio from 0 to 1, where 0 is fully zoomed out, and 1 is zoomed in.
* @see android.service.wallpaper.WallpaperService.Engine#onZoomChanged(float)
*/
private float mDepth;
/**
- * Last blur value, in pixels, that was applied.
- * For debugging purposes.
- */
- private int mCurrentBlur;
- /**
* 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;
- // Hints that there is potentially content behind Launcher and that we shouldn't optimize by
- // marking the launcher surface as opaque. Only used in certain Launcher states.
- private boolean mHasContentBehindLauncher;
-
private View.OnAttachStateChangeListener mOnAttachListener;
public DepthController(Launcher l) {
@@ -169,7 +146,7 @@ public class DepthController implements StateHandler<LauncherState>,
private void ensureDependencies() {
if (mWallpaperManager == null) {
mMaxBlurRadius = mLauncher.getResources().getInteger(R.integer.max_depth_blur_radius);
- mWallpaperManager = mLauncher.getSystemService(WallpaperManager.class);
+ mWallpaperManager = new WallpaperManagerCompat(mLauncher);
}
if (mLauncher.getRootView() != null && mOnAttachListener == null) {
@@ -203,10 +180,6 @@ public class DepthController implements StateHandler<LauncherState>,
mLauncher.getScrimView().addOpaquenessListener(mOpaquenessListener);
}
- public void setHasContentBehindLauncher(boolean hasContentBehindLauncher) {
- mHasContentBehindLauncher = hasContentBehindLauncher;
- }
-
/**
* Sets if the underlying activity is started or not
*/
@@ -221,22 +194,20 @@ public class DepthController implements StateHandler<LauncherState>,
/**
* Sets the specified app target surface to apply the blur to.
- * @return true when surface was valid and transaction was dispatched.
*/
- public boolean setSurface(SurfaceControl surface) {
+ public void setSurface(SurfaceControl surface) {
// Set launcher as the SurfaceControl when we don't need an external target anymore.
if (surface == null) {
ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl();
surface = viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null;
}
+
if (mSurface != surface) {
mSurface = surface;
if (surface != null) {
dispatchTransactionSurface(mDepth);
- return true;
}
}
- return false;
}
@Override
@@ -250,8 +221,6 @@ public class DepthController implements StateHandler<LauncherState>,
setDepth(toDepth);
} else if (toState == LauncherState.OVERVIEW) {
dispatchTransactionSurface(mDepth);
- } else if (toState == LauncherState.BACKGROUND_APP) {
- mLauncher.getDragLayer().getViewTreeObserver().addOnDrawListener(mOnDrawListener);
}
}
@@ -290,27 +259,9 @@ public class DepthController implements StateHandler<LauncherState>,
if (Float.compare(mDepth, depthF) == 0) {
return;
}
- dispatchTransactionSurface(depthF);
- mDepth = depthF;
- }
-
- public void onOverlayScrollChanged(float progress) {
- if (!OVERLAY_SCROLL_ENABLED) {
- return;
- }
- // Add some padding to the progress, such we don't change the depth on the last frames of
- // the animation. It's possible that a user flinging the feed quickly would scroll
- // horizontally by accident, causing the device to enter client composition unnecessarily.
- progress = Math.min(progress * 1.1f, 1f);
-
- // Round out the progress to dedupe frequent, non-perceptable updates
- int progressI = (int) (progress * 256);
- float progressF = Utilities.boundToRange(progressI / 256f, 0f, 1f);
- if (Float.compare(mOverlayScrollProgress, progressF) == 0) {
- return;
+ if (dispatchTransactionSurface(depthF)) {
+ mDepth = depthF;
}
- mOverlayScrollProgress = progressF;
- dispatchTransactionSurface(mDepth);
}
private boolean dispatchTransactionSurface(float depth) {
@@ -319,32 +270,22 @@ public class DepthController implements StateHandler<LauncherState>,
return false;
}
ensureDependencies();
- depth = Math.max(depth, mOverlayScrollProgress);
IBinder windowToken = mLauncher.getRootView().getWindowToken();
if (windowToken != null) {
mWallpaperManager.setWallpaperZoomOut(windowToken, depth);
}
if (supportsBlur) {
- boolean hasOpaqueBg = mLauncher.getScrimView().isFullyOpaque();
- boolean isSurfaceOpaque = !mHasContentBehindLauncher && hasOpaqueBg;
+ // 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.
+ boolean isOverview = mLauncher.isInState(LauncherState.OVERVIEW);
+ boolean opaque = mLauncher.getScrimView().isFullyOpaque() && !isOverview;
- mCurrentBlur = !mCrossWindowBlursEnabled || mBlurDisabledForAppLaunch || hasOpaqueBg
- ? 0 : (int) (depth * mMaxBlurRadius);
+ int blur = opaque || isOverview || !mCrossWindowBlursEnabled
+ || mBlurDisabledForAppLaunch ? 0 : (int) (depth * mMaxBlurRadius);
SurfaceControl.Transaction transaction = new SurfaceControl.Transaction()
- .setBackgroundBlurRadius(mSurface, mCurrentBlur)
- .setOpaque(mSurface, isSurfaceOpaque);
-
- // 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;
- }
+ .setBackgroundBlurRadius(mSurface, blur)
+ .setOpaque(mSurface, opaque);
AttachedSurfaceControl rootSurfaceControl =
mLauncher.getRootView().getRootSurfaceControl();
@@ -371,18 +312,4 @@ public class DepthController implements StateHandler<LauncherState>,
mwAnimation.setAutoCancel(true);
mwAnimation.start();
}
-
- public void dump(String prefix, PrintWriter writer) {
- writer.println(prefix + this.getClass().getSimpleName());
- writer.println(prefix + "\tmMaxBlurRadius=" + mMaxBlurRadius);
- writer.println(prefix + "\tmCrossWindowBlursEnabled=" + mCrossWindowBlursEnabled);
- writer.println(prefix + "\tmSurface=" + mSurface);
- writer.println(prefix + "\tmOverlayScrollProgress=" + mOverlayScrollProgress);
- writer.println(prefix + "\tmDepth=" + mDepth);
- writer.println(prefix + "\tmCurrentBlur=" + mCurrentBlur);
- writer.println(prefix + "\tmBlurDisabledForAppLaunch=" + mBlurDisabledForAppLaunch);
- writer.println(prefix + "\tmInEarlyWakeUp=" + mInEarlyWakeUp);
- writer.println(prefix + "\tmIgnoreStateChangesDuringMultiWindowAnimation="
- + mIgnoreStateChangesDuringMultiWindowAnimation);
- }
}