mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Fixing surface blur when using multiple surfaces
Separating the depth controller logic into a base class so that different controllers can be used for different surfaces Bug: 236780815 Test: Verified locally Change-Id: I2bd7ed50438453d6e41c73c8001a0d6a73091653
This commit is contained in:
@@ -80,6 +80,7 @@ import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Size;
|
||||
import android.view.CrossWindowBlurListeners;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.View;
|
||||
import android.view.ViewRootImpl;
|
||||
@@ -95,6 +96,7 @@ import androidx.core.graphics.ColorUtils;
|
||||
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
|
||||
import com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorListeners;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.shortcuts.DeepShortcutView;
|
||||
@@ -145,8 +147,6 @@ import java.util.List;
|
||||
*/
|
||||
public class QuickstepTransitionManager implements OnDeviceProfileChangeListener {
|
||||
|
||||
private static final String TAG = "QuickstepTransition";
|
||||
|
||||
private static final boolean ENABLE_SHELL_STARTING_SURFACE =
|
||||
SystemProperties.getBoolean("persist.debug.shell_starting_surface", true);
|
||||
|
||||
@@ -1066,54 +1066,37 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
private ObjectAnimator getBackgroundAnimator() {
|
||||
// When launching an app from overview that doesn't map to a task, we still want to just
|
||||
// blur the wallpaper instead of the launcher surface as well
|
||||
boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW;
|
||||
DepthController depthController = mLauncher.getDepthController();
|
||||
boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW
|
||||
&& BlurUtils.supportsBlursOnWindows();
|
||||
|
||||
MyDepthController depthController = new MyDepthController(mLauncher);
|
||||
ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, DEPTH,
|
||||
BACKGROUND_APP.getDepth(mLauncher))
|
||||
BACKGROUND_APP.getDepth(mLauncher))
|
||||
.setDuration(APP_LAUNCH_DURATION);
|
||||
|
||||
if (allowBlurringLauncher) {
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
SurfaceControl dimLayer = new SurfaceControl.Builder()
|
||||
.setName("Blur layer")
|
||||
.setParent(parent)
|
||||
.setOpaque(false)
|
||||
.setHidden(false)
|
||||
.setEffectLayer()
|
||||
.build();
|
||||
|
||||
depthController.setSurface(dimLayer);
|
||||
backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
depthController.setIsInLaunchTransition(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
depthController.setIsInLaunchTransition(false);
|
||||
depthController.setSurface(null);
|
||||
if (dimLayer != null) {
|
||||
new SurfaceControl.Transaction()
|
||||
.remove(dimLayer)
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
});
|
||||
backgroundRadiusAnim.addListener(AnimatorListeners.forEndCallback(() ->
|
||||
new SurfaceControl.Transaction().remove(dimLayer).apply()));
|
||||
}
|
||||
|
||||
return backgroundRadiusAnim;
|
||||
}
|
||||
|
||||
@@ -1958,4 +1941,17 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
return Utilities.mapToRange(progress, start, end, 1, 0, ACCEL_1_5);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyDepthController extends DepthController {
|
||||
MyDepthController(Launcher l) {
|
||||
super(l);
|
||||
setCrossWindowBlursEnabled(
|
||||
CrossWindowBlurListeners.getInstance().isCrossWindowBlurEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSurface(SurfaceControl surface) {
|
||||
super.setSurface(surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user