Merge changes Ieefeb843,Ic2a94b09 into nyc-dev
am: 3fb1c81
* commit '3fb1c81394f98b025b488774916b7580f9e31dab':
Update surface insets on window elevation changes.
Fixed bug with cropping out drop shadow for pinned stack.
Change-Id: If788ed4af5292b76576c7abd728633f20cc6eb93
This commit is contained in:
@@ -549,8 +549,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
// Compute surface insets required to draw at specified Z value.
|
||||
// TODO: Use real shadow insets for a constant max Z.
|
||||
if (!attrs.hasManualSurfaceInsets) {
|
||||
final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
|
||||
attrs.surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset);
|
||||
attrs.setSurfaceInsets(view, false /*manual*/, true /*preservePrevious*/);
|
||||
}
|
||||
|
||||
CompatibilityInfo compatibilityInfo = mDisplayAdjustments.getCompatibilityInfo();
|
||||
@@ -883,10 +882,12 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
mWindowAttributes.privateFlags |= compatibleWindowFlag;
|
||||
|
||||
// Restore old surface insets.
|
||||
mWindowAttributes.surfaceInsets.set(
|
||||
oldInsetLeft, oldInsetTop, oldInsetRight, oldInsetBottom);
|
||||
mWindowAttributes.hasManualSurfaceInsets = oldHasManualSurfaceInsets;
|
||||
if (mWindowAttributes.preservePreviousSurfaceInsets) {
|
||||
// Restore old surface insets.
|
||||
mWindowAttributes.surfaceInsets.set(
|
||||
oldInsetLeft, oldInsetTop, oldInsetRight, oldInsetBottom);
|
||||
mWindowAttributes.hasManualSurfaceInsets = oldHasManualSurfaceInsets;
|
||||
}
|
||||
|
||||
applyKeepScreenOnFlag(mWindowAttributes);
|
||||
|
||||
|
||||
@@ -1481,6 +1481,16 @@ public interface WindowManager extends ViewManager {
|
||||
*/
|
||||
public boolean hasManualSurfaceInsets;
|
||||
|
||||
/**
|
||||
* Whether the previous surface insets should be used vs. what is currently set. When set
|
||||
* to {@code true}, the view root will ignore surfaces insets in this object and use what
|
||||
* it currently has.
|
||||
*
|
||||
* @see #surfaceInsets
|
||||
* @hide
|
||||
*/
|
||||
public boolean preservePreviousSurfaceInsets = true;
|
||||
|
||||
/**
|
||||
* The desired bitmap format. May be one of the constants in
|
||||
* {@link android.graphics.PixelFormat}. Default is OPAQUE.
|
||||
@@ -1771,6 +1781,17 @@ public interface WindowManager extends ViewManager {
|
||||
return mTitle != null ? mTitle : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the surface insets based on the elevation (visual z position) of the input view.
|
||||
* @hide
|
||||
*/
|
||||
public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) {
|
||||
final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
|
||||
surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset);
|
||||
hasManualSurfaceInsets = manual;
|
||||
preservePreviousSurfaceInsets = preservePrevious;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public final void setUserActivityTimeout(long timeout) {
|
||||
@@ -1822,6 +1843,7 @@ public interface WindowManager extends ViewManager {
|
||||
out.writeInt(surfaceInsets.right);
|
||||
out.writeInt(surfaceInsets.bottom);
|
||||
out.writeInt(hasManualSurfaceInsets ? 1 : 0);
|
||||
out.writeInt(preservePreviousSurfaceInsets ? 1 : 0);
|
||||
out.writeInt(needsMenuKey);
|
||||
out.writeInt(accessibilityIdOfAnchor);
|
||||
TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
|
||||
@@ -1874,6 +1896,7 @@ public interface WindowManager extends ViewManager {
|
||||
surfaceInsets.right = in.readInt();
|
||||
surfaceInsets.bottom = in.readInt();
|
||||
hasManualSurfaceInsets = in.readInt() != 0;
|
||||
preservePreviousSurfaceInsets = in.readInt() != 0;
|
||||
needsMenuKey = in.readInt();
|
||||
accessibilityIdOfAnchor = in.readInt();
|
||||
accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
@@ -2075,6 +2098,11 @@ public interface WindowManager extends ViewManager {
|
||||
changes |= SURFACE_INSETS_CHANGED;
|
||||
}
|
||||
|
||||
if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) {
|
||||
preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets;
|
||||
changes |= SURFACE_INSETS_CHANGED;
|
||||
}
|
||||
|
||||
if (needsMenuKey != o.needsMenuKey) {
|
||||
needsMenuKey = o.needsMenuKey;
|
||||
changes |= NEEDS_MENU_KEY_CHANGED;
|
||||
@@ -2200,11 +2228,15 @@ public interface WindowManager extends ViewManager {
|
||||
sb.append(" userActivityTimeout=").append(userActivityTimeout);
|
||||
}
|
||||
if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 ||
|
||||
surfaceInsets.bottom != 0 || hasManualSurfaceInsets) {
|
||||
surfaceInsets.bottom != 0 || hasManualSurfaceInsets
|
||||
|| !preservePreviousSurfaceInsets) {
|
||||
sb.append(" surfaceInsets=").append(surfaceInsets);
|
||||
if (hasManualSurfaceInsets) {
|
||||
sb.append(" (manual)");
|
||||
}
|
||||
if (!preservePreviousSurfaceInsets) {
|
||||
sb.append(" (!preservePreviousSurfaceInsets)");
|
||||
}
|
||||
}
|
||||
if (needsMenuKey != NEEDS_MENU_UNSET) {
|
||||
sb.append(" needsMenuKey=");
|
||||
|
||||
@@ -1290,9 +1290,7 @@ public class PopupWindow {
|
||||
|
||||
// We may wrap that in another view, so we'll need to manually specify
|
||||
// the surface insets.
|
||||
final int surfaceInset = (int) Math.ceil(mBackgroundView.getZ() * 2);
|
||||
p.surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset);
|
||||
p.hasManualSurfaceInsets = true;
|
||||
p.setSurfaceInsets(mBackgroundView, true /*manual*/, true /*preservePrevious*/);
|
||||
|
||||
mPopupViewInitialLayoutDirectionInherited =
|
||||
(mContentView.getRawLayoutDirection() == View.LAYOUT_DIRECTION_INHERIT);
|
||||
|
||||
@@ -1403,10 +1403,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
@Override
|
||||
public final void setElevation(float elevation) {
|
||||
mElevation = elevation;
|
||||
final WindowManager.LayoutParams attrs = getAttributes();
|
||||
if (mDecor != null) {
|
||||
mDecor.setElevation(elevation);
|
||||
attrs.setSurfaceInsets(mDecor, true /*manual*/, false /*preservePrevious*/);
|
||||
}
|
||||
dispatchWindowAttributesChanged(getAttributes());
|
||||
dispatchWindowAttributesChanged(attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user