Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e508606 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Set blur on effect layer during app launch

Test: manual
Fixes: 189207458
Change-Id: I8fabba92c6831c2fd54fe08156fc9a9b5d141a56
parent 04ef35f8
Loading
Loading
Loading
Loading
+33 −3
Original line number Original line Diff line number Diff line
@@ -61,7 +61,9 @@ import android.os.Looper;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.util.Pair;
import android.util.Pair;
import android.util.Size;
import android.util.Size;
import android.view.SurfaceControl;
import android.view.View;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.animation.Interpolator;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
import android.view.animation.PathInterpolator;


@@ -91,6 +93,7 @@ import com.android.quickstep.views.FloatingWidgetView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.ActivityOptionsCompat;
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.InteractionJankMonitorWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
@@ -902,12 +905,39 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
                BACKGROUND_APP.getDepth(mLauncher))
                BACKGROUND_APP.getDepth(mLauncher))
                .setDuration(APP_LAUNCH_DURATION);
                .setDuration(APP_LAUNCH_DURATION);
        if (allowBlurringLauncher) {
        if (allowBlurringLauncher) {
            depthController.setSurfaceToApp(RemoteAnimationProvider.findLowestOpaqueLayerTarget(
            final SurfaceControl dimLayer;
                    appTargets, MODE_OPENING));
            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() {
            backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() {
                @Override
                @Override
                public void onAnimationEnd(Animator animation) {
                public void onAnimationEnd(Animator animation) {
                    depthController.setSurfaceToApp(null);
                    depthController.setSurface(null);
                    if (dimLayer != null) {
                        new SurfaceControl.Transaction()
                                .remove(dimLayer)
                                .apply();
                    }
                }
                }
            });
            });
        }
        }
+7 −11
Original line number Original line Diff line number Diff line
@@ -25,7 +25,9 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ObjectAnimator;
import android.os.IBinder;
import android.os.IBinder;
import android.util.FloatProperty;
import android.util.FloatProperty;
import android.view.SurfaceControl;
import android.view.View;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver;


import com.android.launcher3.BaseActivity;
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.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.systemui.shared.system.BlurUtils;
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;
import com.android.systemui.shared.system.WallpaperManagerCompat;


/**
/**
@@ -91,7 +90,8 @@ public class DepthController implements StateHandler<LauncherState>,
                @Override
                @Override
                public void onDraw() {
                public void onDraw() {
                    View view = mLauncher.getDragLayer();
                    View view = mLauncher.getDragLayer();
                    setSurface(new SurfaceControlCompat(view));
                    ViewRootImpl viewRootImpl = view.getViewRootImpl();
                    setSurface(viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null);
                    view.post(() -> view.getViewTreeObserver().removeOnDrawListener(this));
                    view.post(() -> view.getViewTreeObserver().removeOnDrawListener(this));
                }
                }
            };
            };
@@ -102,7 +102,7 @@ public class DepthController implements StateHandler<LauncherState>,
     */
     */
    private int mMaxBlurRadius;
    private int mMaxBlurRadius;
    private WallpaperManagerCompat mWallpaperManager;
    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.
     * Ratio from 0 to 1, where 0 is fully zoomed out, and 1 is zoomed in.
     * @see android.service.wallpaper.WallpaperService.Engine#onZoomChanged(float)
     * @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.
     * Sets the specified app target surface to apply the blur to.
     */
     */
    public void setSurfaceToApp(RemoteAnimationTargetCompat target) {
    public void setSurface(SurfaceControl surface) {
        setSurface(target == null ? null : target.leash);
    }

    private void setSurface(SurfaceControlCompat surface) {
        if (mSurface != surface) {
        if (mSurface != surface) {
            mSurface = surface;
            mSurface = surface;
            if (surface != null) {
            if (surface != null) {
@@ -219,7 +215,7 @@ public class DepthController implements StateHandler<LauncherState>,
        if (supportsBlur) {
        if (supportsBlur) {
            boolean isOpaque = mLauncher.getScrimView().isFullyOpaque();
            boolean isOpaque = mLauncher.getScrimView().isFullyOpaque();
            int blur = isOpaque ? 0 : (int) (mDepth * mMaxBlurRadius);
            int blur = isOpaque ? 0 : (int) (mDepth * mMaxBlurRadius);
            new TransactionCompat()
            new SurfaceControl.Transaction()
                    .setBackgroundBlurRadius(mSurface, blur)
                    .setBackgroundBlurRadius(mSurface, blur)
                    .setOpaque(mSurface, isOpaque)
                    .setOpaque(mSurface, isOpaque)
                    .apply();
                    .apply();