Merge "Fixed some issues with fullscreen dimming" into nyc-dev
am: e208bd4cbe
* commit 'e208bd4cbea7468c989d25ef582e5a9ed7ecabf1':
Fixed some issues with fullscreen dimming
Change-Id: Ibf06c08daca76f47a7a3cd8baf94aaf0b4d8adc2
This commit is contained in:
@@ -73,8 +73,8 @@ public class DimLayer {
|
||||
|
||||
/** Interface implemented by users of the dim layer */
|
||||
interface DimLayerUser {
|
||||
/** Returns true if the user of the dim layer is fullscreen. */
|
||||
boolean isFullscreen();
|
||||
/** Returns true if the dim should be fullscreen. */
|
||||
boolean dimFullscreen();
|
||||
/** Returns the display info. of the dim layer user. */
|
||||
DisplayInfo getDisplayInfo();
|
||||
/** Gets the bounds of the dim layer user. */
|
||||
@@ -188,33 +188,40 @@ public class DimLayer {
|
||||
* NOTE: Must be called with Surface transaction open.
|
||||
*/
|
||||
private void adjustBounds() {
|
||||
final int dw, dh;
|
||||
final float xPos, yPos;
|
||||
if (!mUser.isFullscreen()) {
|
||||
dw = mBounds.width();
|
||||
dh = mBounds.height();
|
||||
xPos = mBounds.left;
|
||||
yPos = mBounds.top;
|
||||
} else {
|
||||
// Set surface size to screen size.
|
||||
final DisplayInfo info = mUser.getDisplayInfo();
|
||||
// Multiply by 1.5 so that rotating a frozen surface that includes this does not expose
|
||||
// a corner.
|
||||
dw = (int) (info.logicalWidth * 1.5);
|
||||
dh = (int) (info.logicalHeight * 1.5);
|
||||
// back off position so 1/4 of Surface is before and 1/4 is after.
|
||||
xPos = -1 * dw / 6;
|
||||
yPos = -1 * dh / 6;
|
||||
if (mUser.dimFullscreen()) {
|
||||
getBoundsForFullscreen(mBounds);
|
||||
}
|
||||
|
||||
if (mDimSurface != null) {
|
||||
mDimSurface.setPosition(xPos, yPos);
|
||||
mDimSurface.setSize(dw, dh);
|
||||
mDimSurface.setPosition(mBounds.left, mBounds.top);
|
||||
mDimSurface.setSize(mBounds.width(), mBounds.height());
|
||||
if (DEBUG_DIM_LAYER) Slog.v(TAG,
|
||||
"adjustBounds user=" + mUser.toShortString() + " mBounds=" + mBounds);
|
||||
}
|
||||
|
||||
mLastBounds.set(mBounds);
|
||||
}
|
||||
|
||||
private void getBoundsForFullscreen(Rect outBounds) {
|
||||
final int dw, dh;
|
||||
final float xPos, yPos;
|
||||
// Set surface size to screen size.
|
||||
final DisplayInfo info = mUser.getDisplayInfo();
|
||||
// Multiply by 1.5 so that rotating a frozen surface that includes this does not expose
|
||||
// a corner.
|
||||
dw = (int) (info.logicalWidth * 1.5);
|
||||
dh = (int) (info.logicalHeight * 1.5);
|
||||
// back off position so 1/4 of Surface is before and 1/4 is after.
|
||||
xPos = -1 * dw / 6;
|
||||
yPos = -1 * dh / 6;
|
||||
outBounds.set((int) xPos, (int) yPos, (int) xPos + dw, (int) yPos + dh);
|
||||
}
|
||||
|
||||
void setBoundsForFullscreen() {
|
||||
getBoundsForFullscreen(mBounds);
|
||||
setBounds(mBounds);
|
||||
}
|
||||
|
||||
/** @param bounds The new bounds to set */
|
||||
void setBounds(Rect bounds) {
|
||||
mBounds.set(bounds);
|
||||
|
||||
@@ -48,14 +48,15 @@ class DimLayerController {
|
||||
|
||||
/** Updates the dim layer bounds, recreating it if needed. */
|
||||
void updateDimLayer(DimLayer.DimLayerUser dimLayerUser) {
|
||||
DimLayerState state = getOrCreateDimLayerState(dimLayerUser);
|
||||
final DimLayerState state = getOrCreateDimLayerState(dimLayerUser);
|
||||
final boolean previousFullscreen = state.dimLayer != null
|
||||
&& state.dimLayer == mSharedFullScreenDimLayer;
|
||||
DimLayer newDimLayer;
|
||||
final int displayId = mDisplayContent.getDisplayId();
|
||||
if (dimLayerUser.isFullscreen()) {
|
||||
if (previousFullscreen) {
|
||||
// Nothing to do here...
|
||||
if (dimLayerUser.dimFullscreen()) {
|
||||
if (previousFullscreen && mSharedFullScreenDimLayer != null) {
|
||||
// Update the bounds for fullscreen in case of rotation.
|
||||
mSharedFullScreenDimLayer.setBoundsForFullscreen();
|
||||
return;
|
||||
}
|
||||
// Use shared fullscreen dim layer
|
||||
@@ -146,7 +147,7 @@ class DimLayerController {
|
||||
|| !state.animator.getShown()
|
||||
|| state.animator.mAnimLayer <= newWinAnimator.mAnimLayer)) {
|
||||
state.animator = newWinAnimator;
|
||||
if (state.animator.mWin.mAppToken == null && !dimLayerUser.isFullscreen()) {
|
||||
if (state.animator.mWin.mAppToken == null && !dimLayerUser.dimFullscreen()) {
|
||||
// Dim should cover the entire screen for system windows.
|
||||
mDisplayContent.getLogicalDisplayRect(mTmpBounds);
|
||||
} else {
|
||||
@@ -190,11 +191,11 @@ class DimLayerController {
|
||||
for (int i = mState.size() - 1; i >= 0; i--) {
|
||||
DimLayer.DimLayerUser user = mState.keyAt(i);
|
||||
DimLayerState state = mState.valueAt(i);
|
||||
// We have to check that we are acutally the shared fullscreen layer
|
||||
// We have to check that we are actually the shared fullscreen layer
|
||||
// for this path. If we began as non fullscreen and became fullscreen
|
||||
// (e.g. Docked stack closing), then we may not be the shared layer
|
||||
// and we have to make sure we always animate the layer.
|
||||
if (user.isFullscreen() && state.dimLayer == mSharedFullScreenDimLayer) {
|
||||
if (user.dimFullscreen() && state.dimLayer == mSharedFullScreenDimLayer) {
|
||||
fullScreen = i;
|
||||
if (mState.valueAt(i).continueDimming) {
|
||||
fullScreenAndDimming = i;
|
||||
@@ -337,15 +338,18 @@ class DimLayerController {
|
||||
|
||||
void dump(String prefix, PrintWriter pw) {
|
||||
pw.println(prefix + "DimLayerController");
|
||||
for (int i = 0, n = mState.size(); i < n; i++) {
|
||||
pw.println(prefix + " " + mState.keyAt(i).toShortString());
|
||||
pw.print(prefix + " ");
|
||||
DimLayerState state = mState.valueAt(i);
|
||||
pw.print("dimLayer=" + (state.dimLayer == mSharedFullScreenDimLayer ? "shared" :
|
||||
state.dimLayer));
|
||||
pw.print(", animator=" + state.animator);
|
||||
pw.println(", continueDimming=" + state.continueDimming + "}");
|
||||
final String doubleSpace = " ";
|
||||
final String prefixPlusDoubleSpace = prefix + doubleSpace;
|
||||
|
||||
for (int i = 0, n = mState.size(); i < n; i++) {
|
||||
pw.println(prefixPlusDoubleSpace + mState.keyAt(i).toShortString());
|
||||
DimLayerState state = mState.valueAt(i);
|
||||
pw.println(prefixPlusDoubleSpace + doubleSpace + "dimLayer="
|
||||
+ (state.dimLayer == mSharedFullScreenDimLayer ? "shared" : state.dimLayer)
|
||||
+ ", animator=" + state.animator + ", continueDimming=" + state.continueDimming);
|
||||
if (state.dimLayer != null) {
|
||||
state.dimLayer.printTo(prefixPlusDoubleSpace + doubleSpace, pw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,7 +765,7 @@ public class DockedStackDividerController implements DimLayerUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullscreen() {
|
||||
public boolean dimFullscreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -750,7 +750,11 @@ class Task implements DimLayer.DimLayerUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullscreen() {
|
||||
public boolean dimFullscreen() {
|
||||
return isHomeTask() || isFullscreen();
|
||||
}
|
||||
|
||||
boolean isFullscreen() {
|
||||
if (useCurrentBounds()) {
|
||||
return mFullscreen;
|
||||
}
|
||||
|
||||
@@ -515,7 +515,11 @@ class TaskPositioner implements DimLayer.DimLayerUser {
|
||||
}
|
||||
|
||||
@Override /** {@link DimLayer.DimLayerUser} */
|
||||
public boolean isFullscreen() {
|
||||
public boolean dimFullscreen() {
|
||||
return isFullscreen();
|
||||
}
|
||||
|
||||
boolean isFullscreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1155,7 +1155,11 @@ public class TaskStack implements DimLayer.DimLayerUser,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullscreen() {
|
||||
public boolean dimFullscreen() {
|
||||
return mStackId == HOME_STACK_ID || isFullscreen();
|
||||
}
|
||||
|
||||
boolean isFullscreen() {
|
||||
if (useCurrentBounds()) {
|
||||
return mFullscreen;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user