Merge "Force windows to be scalable during pinned animation." into nyc-dev am: 4e9a9df

am: 1b72363

* commit '1b723638468b99919754820d785c7184575a57ba':
  Force windows to be scalable during pinned animation.

Change-Id: I0761b9ee28b276cab72c055754dd70144590aeb2
This commit is contained in:
Rob Carr
2016-04-19 22:20:52 +00:00
committed by android-build-merger
8 changed files with 79 additions and 16 deletions

View File

@@ -102,13 +102,13 @@ public class Surface implements Parcelable {
public @interface ScalingMode {} public @interface ScalingMode {}
// From system/window.h // From system/window.h
/** @hide */ /** @hide */
static final int SCALING_MODE_FREEZE = 0; public static final int SCALING_MODE_FREEZE = 0;
/** @hide */ /** @hide */
static final int SCALING_MODE_SCALE_TO_WINDOW = 1; public static final int SCALING_MODE_SCALE_TO_WINDOW = 1;
/** @hide */ /** @hide */
static final int SCALING_MODE_SCALE_CROP = 2; public static final int SCALING_MODE_SCALE_CROP = 2;
/** @hide */ /** @hide */
static final int SCALING_MODE_NO_SCALE_CROP = 3; public static final int SCALING_MODE_NO_SCALE_CROP = 3;
/** @hide */ /** @hide */
@IntDef({ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270}) @IntDef({ROTATION_0, ROTATION_90, ROTATION_180, ROTATION_270})

View File

@@ -85,6 +85,8 @@ public class SurfaceControl {
IBinder displayToken, int mode); IBinder displayToken, int mode);
private static native void nativeDeferTransactionUntil(long nativeObject, private static native void nativeDeferTransactionUntil(long nativeObject,
IBinder handle, long frame); IBinder handle, long frame);
private static native void nativeSetOverrideScalingMode(long nativeObject,
int scalingMode);
private static native IBinder nativeGetHandle(long nativeObject); private static native IBinder nativeGetHandle(long nativeObject);
@@ -376,6 +378,11 @@ public class SurfaceControl {
nativeDeferTransactionUntil(mNativeObject, handle, frame); nativeDeferTransactionUntil(mNativeObject, handle, frame);
} }
public void setOverrideScalingMode(int scalingMode) {
checkNotReleased();
nativeSetOverrideScalingMode(mNativeObject, scalingMode);
}
public IBinder getHandle() { public IBinder getHandle() {
return nativeGetHandle(mNativeObject); return nativeGetHandle(mNativeObject);
} }

View File

@@ -597,6 +597,13 @@ static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong nativeO
ctrl->deferTransactionUntil(handle, frameNumber); ctrl->deferTransactionUntil(handle, frameNumber);
} }
static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong nativeObject,
jint scalingMode) {
auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
ctrl->setOverrideScalingMode(scalingMode);
}
static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) { static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
@@ -676,6 +683,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetDisplayPowerMode }, (void*)nativeSetDisplayPowerMode },
{"nativeDeferTransactionUntil", "(JLandroid/os/IBinder;J)V", {"nativeDeferTransactionUntil", "(JLandroid/os/IBinder;J)V",
(void*)nativeDeferTransactionUntil }, (void*)nativeDeferTransactionUntil },
{"nativeSetOverrideScalingMode", "(JI)V",
(void*)nativeSetOverrideScalingMode },
{"nativeGetHandle", "(J)Landroid/os/IBinder;", {"nativeGetHandle", "(J)Landroid/os/IBinder;",
(void*)nativeGetHandle } (void*)nativeGetHandle }
}; };

View File

@@ -129,13 +129,16 @@ public class BoundsAnimationController {
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget
+ " mReplacement=" + mReplacement); + " mReplacement=" + mReplacement);
if (animatingToLargerSize()) {
mTarget.setPinnedStackSize(mFrom, mTo);
}
if (!mReplacement) { if (!mReplacement) {
mTarget.onAnimationStart(); mTarget.onAnimationStart();
} }
// Ensure that we have prepared the target for animation before
// we trigger any size changes, so it can swap surfaces
// in to appropriate modes, or do as it wishes otherwise.
if (animatingToLargerSize()) {
mTarget.setPinnedStackSize(mFrom, mTo);
}
} }
@Override @Override

View File

@@ -600,7 +600,8 @@ class Task implements DimLayer.DimLayerUser {
// //
// Anyway we don't need to synchronize position and content updates for these // Anyway we don't need to synchronize position and content updates for these
// windows since they aren't at the base layer and could be moved around anyway. // windows since they aren't at the base layer and could be moved around anyway.
if (!win.computeDragResizing() && win.mAttrs.type == TYPE_BASE_APPLICATION) { if (!win.computeDragResizing() && win.mAttrs.type == TYPE_BASE_APPLICATION &&
!mStack.getBoundsAnimating()) {
win.mResizedWhileNotDragResizing = true; win.mResizedWhileNotDragResizing = true;
} }
} }

View File

@@ -42,6 +42,7 @@ import android.util.SparseArray;
import android.view.DisplayInfo; import android.view.DisplayInfo;
import android.view.Surface; import android.view.Surface;
import android.view.animation.PathInterpolator; import android.view.animation.PathInterpolator;
import android.view.SurfaceControl;
import com.android.internal.policy.DividerSnapAlgorithm; import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget; import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget;
@@ -127,10 +128,12 @@ public class TaskStack implements DimLayer.DimLayerUser,
private float mAdjustImeAmount; private float mAdjustImeAmount;
private final int mDockedStackMinimizeThickness; private final int mDockedStackMinimizeThickness;
// If this is true, the task will be down or upscaled // If this is true, we are in the bounds animating mode.
// to perfectly fit the region it would have been cropped // The task will be down or upscaled to perfectly fit the
// to. // region it would have been cropped to. We may also avoid
private boolean mForceScaleToCrop = false; // certain logic we would otherwise apply while resizing,
// while resizing in the bounds animating mode.
private boolean mBoundsAnimating = false;
// By default, movement animations are applied to all // By default, movement animations are applied to all
// window movement. If this is true, animations will not // window movement. If this is true, animations will not
// be applied within this stack. This is useful for example // be applied within this stack. This is useful for example
@@ -1269,11 +1272,36 @@ public class TaskStack implements DimLayer.DimLayerUser,
return true; return true;
} }
void forceWindowsScaleable(boolean force) {
SurfaceControl.openTransaction();
try {
for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
final ArrayList<AppWindowToken> activities = mTasks.get(taskNdx).mAppTokens;
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
final ArrayList<WindowState> windows = activities.get(activityNdx).allAppWindows;
for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
final WindowStateAnimator winAnimator = windows.get(winNdx).mWinAnimator;
if (winAnimator == null || !winAnimator.hasSurface()) {
continue;
}
winAnimator.mSurfaceController.forceScaleableInTransaction(force);
}
}
}
} finally {
SurfaceControl.closeTransaction();
}
}
@Override // AnimatesBounds @Override // AnimatesBounds
public void onAnimationStart() { public void onAnimationStart() {
synchronized (mService.mWindowMap) { synchronized (mService.mWindowMap) {
// We force windows out of SCALING_MODE_FREEZE
// so that we can continue to animate them
// while a resize is pending.
forceWindowsScaleable(true);
mFreezeMovementAnimations = true; mFreezeMovementAnimations = true;
mForceScaleToCrop = true; mBoundsAnimating = true;
} }
} }
@@ -1281,7 +1309,8 @@ public class TaskStack implements DimLayer.DimLayerUser,
public void onAnimationEnd() { public void onAnimationEnd() {
synchronized (mService.mWindowMap) { synchronized (mService.mWindowMap) {
mFreezeMovementAnimations = false; mFreezeMovementAnimations = false;
mForceScaleToCrop = false; mBoundsAnimating = false;
forceWindowsScaleable(false);
mService.requestTraversal(); mService.requestTraversal();
} }
if (mStackId == PINNED_STACK_ID) { if (mStackId == PINNED_STACK_ID) {
@@ -1312,6 +1341,10 @@ public class TaskStack implements DimLayer.DimLayerUser,
} }
public boolean getForceScaleToCrop() { public boolean getForceScaleToCrop() {
return mForceScaleToCrop; return mBoundsAnimating;
}
public boolean getBoundsAnimating() {
return mBoundsAnimating;
} }
} }

View File

@@ -562,6 +562,7 @@ class WindowStateAnimator {
Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState=" Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState="
+ drawStateToString()); + drawStateToString());
} }
if (mWin.mAppToken != null && mWin.mAppToken.mAnimatingWithSavedSurface) { if (mWin.mAppToken != null && mWin.mAppToken.mAnimatingWithSavedSurface) {
// App has drawn something to its windows, we're no longer animating with // App has drawn something to its windows, we're no longer animating with
// the saved surfaces. If the user exits now, we only want to save again // the saved surfaces. If the user exits now, we only want to save again

View File

@@ -23,6 +23,8 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SURFACE_TRACE
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static android.view.Surface.SCALING_MODE_FREEZE;
import static android.view.Surface.SCALING_MODE_SCALE_TO_WINDOW;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
@@ -392,6 +394,13 @@ class WindowSurfaceController {
mSurfaceControl.deferTransactionUntil(handle, frame); mSurfaceControl.deferTransactionUntil(handle, frame);
} }
void forceScaleableInTransaction(boolean force) {
// -1 means we don't override the default or client specified
// scaling mode.
int scalingMode = force ? SCALING_MODE_SCALE_TO_WINDOW : -1;
mSurfaceControl.setOverrideScalingMode(scalingMode);
}
boolean clearWindowContentFrameStats() { boolean clearWindowContentFrameStats() {
if (mSurfaceControl == null) { if (mSurfaceControl == null) {
return false; return false;