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

Commit f30a6ab6 authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Add background blur in WindowManager

The CL adds background blur to the WindowManager LayoutParams as a
hidden API. The background blur is then passed on to the SurfaceControl
in WindowStateAnimator.prepareSurfaces.

Bug: 167166562
Test: m && flash && start app that requests background blur && verify it
works

Change-Id: I5dad3d8d5c75e1feff8fa035452dfe5c90efaa88
parent 56df9323
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1632,6 +1632,16 @@ public final class SurfaceControl implements Parcelable {
        }
    }

    /**
     * @hide
     */
    public void setBackgroundBlurRadius(int blur) {
        checkNotReleased();
        synchronized (SurfaceControl.class) {
            sGlobalTransaction.setBackgroundBlurRadius(this, blur);
        }
    }

    /**
     * @hide
     */
+20 −0
Original line number Diff line number Diff line
@@ -2938,6 +2938,13 @@ public interface WindowManager extends ViewManager {
         */
        public boolean preferMinimalPostProcessing = false;

        /**
         * Indicates that this window wants to have blurred content behind it.
         *
         * @hide
         */
        public int backgroundBlurRadius = 0;

        /**
         * The color mode requested by this window. The target display may
         * not be able to honor the request. When the color mode is not set
@@ -3262,6 +3269,7 @@ public interface WindowManager extends ViewManager {
            out.writeInt(mFitInsetsSides);
            out.writeBoolean(mFitInsetsIgnoringVisibility);
            out.writeBoolean(preferMinimalPostProcessing);
            out.writeInt(backgroundBlurRadius);
            if (providesInsetsTypes != null) {
                out.writeInt(providesInsetsTypes.length);
                out.writeIntArray(providesInsetsTypes);
@@ -3329,6 +3337,7 @@ public interface WindowManager extends ViewManager {
            mFitInsetsSides = in.readInt();
            mFitInsetsIgnoringVisibility = in.readBoolean();
            preferMinimalPostProcessing = in.readBoolean();
            backgroundBlurRadius = in.readInt();
            int insetsTypesLength = in.readInt();
            if (insetsTypesLength > 0) {
                providesInsetsTypes = new int[insetsTypesLength];
@@ -3381,6 +3390,8 @@ public interface WindowManager extends ViewManager {
        public static final int INSET_FLAGS_CHANGED = 1 << 27;
        /** {@hide} */
        public static final int MINIMAL_POST_PROCESSING_PREFERENCE_CHANGED = 1 << 28;
        /** {@hide} */
        public static final int BACKGROUND_BLUR_RADIUS_CHANGED = 1 << 29;

        // internal buffer to backup/restore parameters under compatibility mode.
        private int[] mCompatibilityParamsBackup = null;
@@ -3566,6 +3577,11 @@ public interface WindowManager extends ViewManager {
                changes |= MINIMAL_POST_PROCESSING_PREFERENCE_CHANGED;
            }

            if (backgroundBlurRadius != o.backgroundBlurRadius) {
                backgroundBlurRadius = o.backgroundBlurRadius;
                changes |= BACKGROUND_BLUR_RADIUS_CHANGED;
            }

            // This can't change, it's only set at window creation time.
            hideTimeoutMilliseconds = o.hideTimeoutMilliseconds;

@@ -3729,6 +3745,10 @@ public interface WindowManager extends ViewManager {
                sb.append(" preferMinimalPostProcessing=");
                sb.append(preferMinimalPostProcessing);
            }
            if (backgroundBlurRadius != 0) {
                sb.append(" backgroundBlurRadius=");
                sb.append(backgroundBlurRadius);
            }
            sb.append(System.lineSeparator());
            sb.append(prefix).append("  fl=").append(
                    ViewDebug.flagsToString(LayoutParams.class, "flags", flags));
+6 −24
Original line number Diff line number Diff line
@@ -1405,12 +1405,6 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimationController.java"
    },
    "-444624452": {
      "message": "REPARENT from: %s to: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "-443173857": {
      "message": "Moving pending starting from %s to %s",
      "level": "VERBOSE",
@@ -1519,12 +1513,6 @@
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/Task.java"
    },
    "-324085783": {
      "message": "SURFACE CROP %s: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "-322743468": {
      "message": "setInputMethodInputTarget %s",
      "level": "INFO",
@@ -1711,12 +1699,6 @@
      "group": "WM_DEBUG_APP_TRANSITIONS_ANIM",
      "at": "com\/android\/server\/wm\/WindowContainer.java"
    },
    "-29233992": {
      "message": "SURFACE CLEAR CROP: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "-21399771": {
      "message": "activity %s already destroying, skipping request with reason:%s",
      "level": "VERBOSE",
@@ -2683,6 +2665,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "1035154109": {
      "message": "SURFACE backgroundBlur=%o: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "1040675582": {
      "message": "Can't report activity configuration update - client not running, activityRecord=%s",
      "level": "WARN",
@@ -2815,12 +2803,6 @@
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/WindowToken.java"
    },
    "1220075598": {
      "message": "SURFACE SIZE %dx%d: %s",
      "level": "INFO",
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "1224184681": {
      "message": "No longer Stopped: %s",
      "level": "VERBOSE",
+1 −0
Original line number Diff line number Diff line
@@ -859,6 +859,7 @@ class WindowStateAnimator {

        if (displayed) {
            w.mToken.hasVisible = true;
            mSurfaceController.setBackgroundBlurRadius(w.mAttrs.backgroundBlurRadius);
        }
    }

+22 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ class WindowSurfaceController {
    private float mLastDsdy = 0;
    private float mLastDtdy = 1;

    private int mLastBackgroundBlurRadius = 0;

    private float mSurfaceAlpha = 0;

    private int mSurfaceLayer = 0;
@@ -285,6 +287,26 @@ class WindowSurfaceController {
        }
    }

    void setBackgroundBlurRadius(int radius) {
        ProtoLog.i(WM_SHOW_TRANSACTIONS, "SURFACE backgroundBlur=%o: %s", radius, title);

        if (mSurfaceControl == null || radius == mLastBackgroundBlurRadius) {
            return;
        }
        mLastBackgroundBlurRadius = radius;

        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION setBackgroundBlurRadius");
        mService.openSurfaceTransaction();
        try {
            mSurfaceControl.setBackgroundBlurRadius(radius);
        } finally {
            mService.closeSurfaceTransaction("setBackgroundBlurRadius");
            if (SHOW_LIGHT_TRANSACTIONS) {
                Slog.i(TAG, "<<< CLOSE TRANSACTION setBackgroundBlurRadius");
            }
        }
    }

    void setSecure(boolean isSecure) {
        ProtoLog.i(WM_SHOW_TRANSACTIONS, "SURFACE isSecure=%b: %s", isSecure, title);