Move background blur to Dim layer
The way background blur is expected to work is the same as the dim layer - it should be cropped to the task/displayArea bounds and dim layers shouldn't stack on top of each other. This CL makes the background blur benefit from that and sets it on the dim surface control. Bug: 171679369 Test: m && flash Test: atest DimmerTests Change-Id: If64cc585a8a74ab5f3dc0757e25556fd89b5eaec
This commit is contained in:
@@ -204,7 +204,7 @@ class Dimmer {
|
||||
}
|
||||
|
||||
private void dim(SurfaceControl.Transaction t, WindowContainer container, int relativeLayer,
|
||||
float alpha) {
|
||||
float alpha, int blurRadius) {
|
||||
final DimState d = getDimState(container);
|
||||
|
||||
if (d == null) {
|
||||
@@ -220,6 +220,7 @@ class Dimmer {
|
||||
t.setLayer(d.mDimLayer, Integer.MAX_VALUE);
|
||||
}
|
||||
t.setAlpha(d.mDimLayer, alpha);
|
||||
t.setBackgroundBlurRadius(d.mDimLayer, blurRadius);
|
||||
|
||||
d.mDimming = true;
|
||||
}
|
||||
@@ -247,7 +248,7 @@ class Dimmer {
|
||||
* @param alpha The alpha at which to Dim.
|
||||
*/
|
||||
void dimAbove(SurfaceControl.Transaction t, float alpha) {
|
||||
dim(t, null, 1, alpha);
|
||||
dim(t, null, 1, alpha, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,19 +261,21 @@ class Dimmer {
|
||||
* @param alpha The alpha at which to Dim.
|
||||
*/
|
||||
void dimAbove(SurfaceControl.Transaction t, WindowContainer container, float alpha) {
|
||||
dim(t, container, 1, alpha);
|
||||
dim(t, container, 1, alpha, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link #dimAbove} but places the dim below the given container.
|
||||
*
|
||||
* @param t A transaction in which to apply the Dim.
|
||||
* @param container The container which to dim below. Should be a child of our host.
|
||||
* @param alpha The alpha at which to Dim.
|
||||
* @param t A transaction in which to apply the Dim.
|
||||
* @param container The container which to dim below. Should be a child of our host.
|
||||
* @param alpha The alpha at which to Dim.
|
||||
* @param blurRadius The amount of blur added to the Dim.
|
||||
*/
|
||||
|
||||
void dimBelow(SurfaceControl.Transaction t, WindowContainer container, float alpha) {
|
||||
dim(t, container, -1, alpha);
|
||||
void dimBelow(SurfaceControl.Transaction t, WindowContainer container, float alpha,
|
||||
int blurRadius) {
|
||||
dim(t, container, -1, alpha, blurRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5228,14 +5228,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
if (!mAnimatingExit && mAppDied) {
|
||||
mIsDimming = true;
|
||||
getDimmer().dimAbove(getSyncTransaction(), this, DEFAULT_DIM_AMOUNT_DEAD_WINDOW);
|
||||
} else if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0 && isVisibleNow() && !mHidden) {
|
||||
// Only show a dim behind when the following is satisfied:
|
||||
// 1. The window has the flag FLAG_DIM_BEHIND
|
||||
} else if (((mAttrs.flags & FLAG_DIM_BEHIND) != 0 || mAttrs.backgroundBlurRadius != 0)
|
||||
&& isVisibleNow() && !mHidden) {
|
||||
// Only show the Dimmer when the following is satisfied:
|
||||
// 1. The window has the flag FLAG_DIM_BEHIND or background blur is requested
|
||||
// 2. The WindowToken is not hidden so dims aren't shown when the window is exiting.
|
||||
// 3. The WS is considered visible according to the isVisible() method
|
||||
// 4. The WS is not hidden.
|
||||
mIsDimming = true;
|
||||
getDimmer().dimBelow(getSyncTransaction(), this, mAttrs.dimAmount);
|
||||
final float dimAmount = (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? mAttrs.dimAmount : 0;
|
||||
getDimmer().dimBelow(
|
||||
getSyncTransaction(), this, mAttrs.dimAmount, mAttrs.backgroundBlurRadius);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -795,7 +795,6 @@ class WindowStateAnimator {
|
||||
|
||||
if (displayed) {
|
||||
w.mToken.hasVisible = true;
|
||||
mSurfaceController.setBackgroundBlurRadius(w.mAttrs.backgroundBlurRadius);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,6 @@ class WindowSurfaceController {
|
||||
private float mLastDsdy = 0;
|
||||
private float mLastDtdy = 1;
|
||||
|
||||
private int mLastBackgroundBlurRadius = 0;
|
||||
|
||||
private float mSurfaceAlpha = 0;
|
||||
|
||||
private int mSurfaceLayer = 0;
|
||||
@@ -242,26 +240,6 @@ 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 {
|
||||
getGlobalTransaction().setBackgroundBlurRadius(mSurfaceControl, 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);
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ public class DimmerTests extends WindowTestsBase {
|
||||
mHost.addChild(child, 0);
|
||||
|
||||
final float alpha = 0.8f;
|
||||
mDimmer.dimBelow(mTransaction, child, alpha);
|
||||
mDimmer.dimBelow(mTransaction, child, alpha, 0);
|
||||
SurfaceControl dimLayer = getDimLayer();
|
||||
|
||||
assertNotNull("Dimmer should have created a surface", dimLayer);
|
||||
|
||||
@@ -135,6 +135,11 @@ public class StubTransaction extends SurfaceControl.Transaction {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurfaceControl.Transaction setBackgroundBlurRadius(SurfaceControl sc, int radius) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurfaceControl.Transaction setLayerStack(SurfaceControl sc, int layerStack) {
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user