mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
Merge "Set blur on effect layer during app launch" into sc-dev
This commit is contained in:
@@ -66,7 +66,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;
|
||||
|
||||
@@ -98,6 +100,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;
|
||||
@@ -921,12 +924,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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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<LauncherState>,
|
||||
@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<LauncherState>,
|
||||
*/
|
||||
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<LauncherState>,
|
||||
/**
|
||||
* 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<LauncherState>,
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user