Merge "Add background blur in WindowManager"

This commit is contained in:
Galia Peycheva
2020-10-21 09:09:04 +00:00
committed by Android (Google) Code Review
5 changed files with 59 additions and 24 deletions

View File

@@ -1620,6 +1620,16 @@ public final class SurfaceControl implements Parcelable {
}
}
/**
* @hide
*/
public void setBackgroundBlurRadius(int blur) {
checkNotReleased();
synchronized (SurfaceControl.class) {
sGlobalTransaction.setBackgroundBlurRadius(this, blur);
}
}
/**
* @hide
*/

View File

@@ -2931,6 +2931,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
@@ -3255,6 +3262,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);
@@ -3322,6 +3330,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];
@@ -3374,6 +3383,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;
@@ -3559,6 +3570,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;
@@ -3722,6 +3738,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));

View File

@@ -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",
@@ -2677,6 +2659,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",
@@ -2809,12 +2797,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",

View File

@@ -859,6 +859,7 @@ class WindowStateAnimator {
if (displayed) {
w.mToken.hasVisible = true;
mSurfaceController.setBackgroundBlurRadius(w.mAttrs.backgroundBlurRadius);
}
}

View File

@@ -63,6 +63,8 @@ class WindowSurfaceController {
private float mLastDsdy = 0;
private float mLastDtdy = 1;
private int mLastBackgroundBlurRadius = 0;
private float mSurfaceAlpha = 0;
private int mSurfaceLayer = 0;
@@ -268,6 +270,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);