Merge "Ensure dim changes are in same transaction; do not wait for token to change visibility" into udc-dev
This commit is contained in:
@@ -215,8 +215,7 @@ class Dimmer {
|
|||||||
return mDimState;
|
return mDimState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dim(SurfaceControl.Transaction t, WindowContainer container, int relativeLayer,
|
private void dim(WindowContainer container, int relativeLayer, float alpha, int blurRadius) {
|
||||||
float alpha, int blurRadius) {
|
|
||||||
final DimState d = getDimState(container);
|
final DimState d = getDimState(container);
|
||||||
|
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
@@ -226,6 +225,7 @@ class Dimmer {
|
|||||||
// The dim method is called from WindowState.prepareSurfaces(), which is always called
|
// The dim method is called from WindowState.prepareSurfaces(), which is always called
|
||||||
// in the correct Z from lowest Z to highest. This ensures that the dim layer is always
|
// in the correct Z from lowest Z to highest. This ensures that the dim layer is always
|
||||||
// relative to the highest Z layer with a dim.
|
// relative to the highest Z layer with a dim.
|
||||||
|
SurfaceControl.Transaction t = mHost.getPendingTransaction();
|
||||||
t.setRelativeLayer(d.mDimLayer, container.getSurfaceControl(), relativeLayer);
|
t.setRelativeLayer(d.mDimLayer, container.getSurfaceControl(), relativeLayer);
|
||||||
t.setAlpha(d.mDimLayer, alpha);
|
t.setAlpha(d.mDimLayer, alpha);
|
||||||
t.setBackgroundBlurRadius(d.mDimLayer, blurRadius);
|
t.setBackgroundBlurRadius(d.mDimLayer, blurRadius);
|
||||||
@@ -238,26 +238,23 @@ class Dimmer {
|
|||||||
* for each call to {@link WindowContainer#prepareSurfaces} the Dim state will be reset
|
* for each call to {@link WindowContainer#prepareSurfaces} the Dim state will be reset
|
||||||
* and the child should call dimAbove again to request the Dim to continue.
|
* and the child should call dimAbove again to request the Dim to continue.
|
||||||
*
|
*
|
||||||
* @param t A transaction in which to apply the Dim.
|
|
||||||
* @param container The container which to dim above. Should be a child of our host.
|
* @param container The container which to dim above. Should be a child of our host.
|
||||||
* @param alpha The alpha at which to Dim.
|
* @param alpha The alpha at which to Dim.
|
||||||
*/
|
*/
|
||||||
void dimAbove(SurfaceControl.Transaction t, WindowContainer container, float alpha) {
|
void dimAbove(WindowContainer container, float alpha) {
|
||||||
dim(t, container, 1, alpha, 0);
|
dim(container, 1, alpha, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link #dimAbove} but places the dim below the given container.
|
* 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 container The container which to dim below. Should be a child of our host.
|
||||||
* @param alpha The alpha at which to Dim.
|
* @param alpha The alpha at which to Dim.
|
||||||
* @param blurRadius The amount of blur added to the Dim.
|
* @param blurRadius The amount of blur added to the Dim.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dimBelow(SurfaceControl.Transaction t, WindowContainer container, float alpha,
|
void dimBelow(WindowContainer container, float alpha, int blurRadius) {
|
||||||
int blurRadius) {
|
dim(container, -1, alpha, blurRadius);
|
||||||
dim(t, container, -1, alpha, blurRadius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5128,7 +5128,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
|
|
||||||
private void applyDims() {
|
private void applyDims() {
|
||||||
if (((mAttrs.flags & FLAG_DIM_BEHIND) != 0 || shouldDrawBlurBehind())
|
if (((mAttrs.flags & FLAG_DIM_BEHIND) != 0 || shouldDrawBlurBehind())
|
||||||
&& isVisibleNow() && !mHidden && mTransitionController.canApplyDim(getTask())) {
|
&& mToken.isVisibleRequested() && isVisibleNow() && !mHidden
|
||||||
|
&& mTransitionController.canApplyDim(getTask())) {
|
||||||
// Only show the Dimmer when the following is satisfied:
|
// Only show the Dimmer when the following is satisfied:
|
||||||
// 1. The window has the flag FLAG_DIM_BEHIND or blur behind is requested
|
// 1. The window has the flag FLAG_DIM_BEHIND or blur behind is requested
|
||||||
// 2. The WindowToken is not hidden so dims aren't shown when the window is exiting.
|
// 2. The WindowToken is not hidden so dims aren't shown when the window is exiting.
|
||||||
@@ -5138,7 +5139,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
|||||||
mIsDimming = true;
|
mIsDimming = true;
|
||||||
final float dimAmount = (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? mAttrs.dimAmount : 0;
|
final float dimAmount = (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? mAttrs.dimAmount : 0;
|
||||||
final int blurRadius = shouldDrawBlurBehind() ? mAttrs.getBlurBehindRadius() : 0;
|
final int blurRadius = shouldDrawBlurBehind() ? mAttrs.getBlurBehindRadius() : 0;
|
||||||
getDimmer().dimBelow(getSyncTransaction(), this, dimAmount, blurRadius);
|
getDimmer().dimBelow(this, dimAmount, blurRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
|
|
||||||
private static class TestWindowContainer extends WindowContainer<TestWindowContainer> {
|
private static class TestWindowContainer extends WindowContainer<TestWindowContainer> {
|
||||||
final SurfaceControl mControl = mock(SurfaceControl.class);
|
final SurfaceControl mControl = mock(SurfaceControl.class);
|
||||||
final SurfaceControl.Transaction mTransaction = spy(StubTransaction.class);
|
final SurfaceControl.Transaction mPendingTransaction = spy(StubTransaction.class);
|
||||||
|
final SurfaceControl.Transaction mSyncTransaction = spy(StubTransaction.class);
|
||||||
|
|
||||||
TestWindowContainer(WindowManagerService wm) {
|
TestWindowContainer(WindowManagerService wm) {
|
||||||
super(wm);
|
super(wm);
|
||||||
@@ -65,12 +66,12 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SurfaceControl.Transaction getSyncTransaction() {
|
public SurfaceControl.Transaction getSyncTransaction() {
|
||||||
return mTransaction;
|
return mSyncTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SurfaceControl.Transaction getPendingTransaction() {
|
public SurfaceControl.Transaction getPendingTransaction() {
|
||||||
return mTransaction;
|
return mPendingTransaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +145,7 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final float alpha = 0.8f;
|
final float alpha = 0.8f;
|
||||||
mDimmer.dimAbove(mTransaction, child, alpha);
|
mDimmer.dimAbove(child, alpha);
|
||||||
|
|
||||||
int width = 100;
|
int width = 100;
|
||||||
int height = 300;
|
int height = 300;
|
||||||
@@ -161,13 +162,13 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final float alpha = 0.8f;
|
final float alpha = 0.8f;
|
||||||
mDimmer.dimAbove(mTransaction, child, alpha);
|
mDimmer.dimAbove(child, alpha);
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
|
|
||||||
assertNotNull("Dimmer should have created a surface", dimLayer);
|
assertNotNull("Dimmer should have created a surface", dimLayer);
|
||||||
|
|
||||||
verify(mTransaction).setAlpha(dimLayer, alpha);
|
verify(mHost.getPendingTransaction()).setAlpha(dimLayer, alpha);
|
||||||
verify(mTransaction).setRelativeLayer(dimLayer, child.mControl, 1);
|
verify(mHost.getPendingTransaction()).setRelativeLayer(dimLayer, child.mControl, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -176,13 +177,13 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final float alpha = 0.8f;
|
final float alpha = 0.8f;
|
||||||
mDimmer.dimBelow(mTransaction, child, alpha, 0);
|
mDimmer.dimBelow(child, alpha, 0);
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
|
|
||||||
assertNotNull("Dimmer should have created a surface", dimLayer);
|
assertNotNull("Dimmer should have created a surface", dimLayer);
|
||||||
|
|
||||||
verify(mTransaction).setAlpha(dimLayer, alpha);
|
verify(mHost.getPendingTransaction()).setAlpha(dimLayer, alpha);
|
||||||
verify(mTransaction).setRelativeLayer(dimLayer, child.mControl, -1);
|
verify(mHost.getPendingTransaction()).setRelativeLayer(dimLayer, child.mControl, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -191,7 +192,7 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final float alpha = 0.8f;
|
final float alpha = 0.8f;
|
||||||
mDimmer.dimAbove(mTransaction, child, alpha);
|
mDimmer.dimAbove(child, alpha);
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
mDimmer.resetDimStates();
|
mDimmer.resetDimStates();
|
||||||
|
|
||||||
@@ -208,10 +209,10 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final float alpha = 0.8f;
|
final float alpha = 0.8f;
|
||||||
mDimmer.dimAbove(mTransaction, child, alpha);
|
mDimmer.dimAbove(child, alpha);
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
mDimmer.resetDimStates();
|
mDimmer.resetDimStates();
|
||||||
mDimmer.dimAbove(mTransaction, child, alpha);
|
mDimmer.dimAbove(child, alpha);
|
||||||
|
|
||||||
mDimmer.updateDims(mTransaction);
|
mDimmer.updateDims(mTransaction);
|
||||||
verify(mTransaction).show(dimLayer);
|
verify(mTransaction).show(dimLayer);
|
||||||
@@ -224,7 +225,7 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final float alpha = 0.8f;
|
final float alpha = 0.8f;
|
||||||
mDimmer.dimAbove(mTransaction, child, alpha);
|
mDimmer.dimAbove(child, alpha);
|
||||||
final Rect bounds = mDimmer.mDimState.mDimBounds;
|
final Rect bounds = mDimmer.mDimState.mDimBounds;
|
||||||
|
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
@@ -245,7 +246,7 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
TestWindowContainer child = new TestWindowContainer(mWm);
|
TestWindowContainer child = new TestWindowContainer(mWm);
|
||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
mDimmer.dimAbove(mTransaction, child, 1);
|
mDimmer.dimAbove(child, 1);
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
mDimmer.updateDims(mTransaction);
|
mDimmer.updateDims(mTransaction);
|
||||||
verify(mTransaction, times(1)).show(dimLayer);
|
verify(mTransaction, times(1)).show(dimLayer);
|
||||||
@@ -266,13 +267,13 @@ public class DimmerTests extends WindowTestsBase {
|
|||||||
mHost.addChild(child, 0);
|
mHost.addChild(child, 0);
|
||||||
|
|
||||||
final int blurRadius = 50;
|
final int blurRadius = 50;
|
||||||
mDimmer.dimBelow(mTransaction, child, 0, blurRadius);
|
mDimmer.dimBelow(child, 0, blurRadius);
|
||||||
SurfaceControl dimLayer = getDimLayer();
|
SurfaceControl dimLayer = getDimLayer();
|
||||||
|
|
||||||
assertNotNull("Dimmer should have created a surface", dimLayer);
|
assertNotNull("Dimmer should have created a surface", dimLayer);
|
||||||
|
|
||||||
verify(mTransaction).setBackgroundBlurRadius(dimLayer, blurRadius);
|
verify(mHost.getPendingTransaction()).setBackgroundBlurRadius(dimLayer, blurRadius);
|
||||||
verify(mTransaction).setRelativeLayer(dimLayer, child.mControl, -1);
|
verify(mHost.getPendingTransaction()).setRelativeLayer(dimLayer, child.mControl, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SurfaceControl getDimLayer() {
|
private SurfaceControl getDimLayer() {
|
||||||
|
|||||||
Reference in New Issue
Block a user