Merge "Sync insets leash position with shell seamless rotation" into tm-qpr-dev am: a8dacea460

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18520827

Change-Id: Icbbf7eaaf7bb8d840631a2f229b5118b2055e788
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-24 12:18:57 +00:00
committed by Automerger Merge Worker
2 changed files with 51 additions and 19 deletions

View File

@@ -144,8 +144,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume
// Legacy animation doesn't need to wait for the start transaction. // Legacy animation doesn't need to wait for the start transaction.
if (mTransitionOp == OP_LEGACY) { if (mTransitionOp == OP_LEGACY) {
mIsStartTransactionCommitted = true; mIsStartTransactionCommitted = true;
} else if (displayContent.mTransitionController.useShellTransitionsRotation() } else if (displayContent.mTransitionController.isCollecting(displayContent)) {
|| displayContent.mTransitionController.isCollecting(displayContent)) {
keepAppearanceInPreviousRotation(); keepAppearanceInPreviousRotation();
} }
} }
@@ -214,10 +213,10 @@ class AsyncRotationController extends FadeAnimationController implements Consume
private void finishOp(WindowToken windowToken) { private void finishOp(WindowToken windowToken) {
final Operation op = mTargetWindowTokens.remove(windowToken); final Operation op = mTargetWindowTokens.remove(windowToken);
if (op == null) return; if (op == null) return;
if (op.mCapturedDrawTransaction != null) { if (op.mDrawTransaction != null) {
// Unblock the window to show its latest content. // Unblock the window to show its latest content.
mDisplayContent.getPendingTransaction().merge(op.mCapturedDrawTransaction); mDisplayContent.getPendingTransaction().merge(op.mDrawTransaction);
op.mCapturedDrawTransaction = null; op.mDrawTransaction = null;
if (DEBUG) Slog.d(TAG, "finishOp merge transaction " + windowToken.getTopChild()); if (DEBUG) Slog.d(TAG, "finishOp merge transaction " + windowToken.getTopChild());
} }
if (op.mAction == Operation.ACTION_FADE) { if (op.mAction == Operation.ACTION_FADE) {
@@ -351,14 +350,34 @@ class AsyncRotationController extends FadeAnimationController implements Consume
} }
/** /**
* Whether the insets animation leash should use previous position when running fade out * Whether the insets animation leash should use previous position when running fade animation
* animation in rotated display. * or seamless transformation in a rotated display.
*/ */
boolean shouldFreezeInsetsPosition(WindowState w) { boolean shouldFreezeInsetsPosition(WindowState w) {
return mTransitionOp == OP_APP_SWITCH && w.mTransitionController.inTransition() return mTransitionOp == OP_APP_SWITCH && w.mTransitionController.inTransition()
&& isTargetToken(w.mToken); && isTargetToken(w.mToken);
} }
/**
* Returns the transaction which will be applied after the window redraws in new rotation.
* This is used to update the position of insets animation leash synchronously.
*/
SurfaceControl.Transaction getDrawTransaction(WindowToken token) {
if (mTransitionOp == OP_LEGACY) {
// Legacy transition uses startSeamlessRotation and finishSeamlessRotation of
// InsetsSourceProvider.
return null;
}
final Operation op = mTargetWindowTokens.get(token);
if (op != null) {
if (op.mDrawTransaction == null) {
op.mDrawTransaction = new SurfaceControl.Transaction();
}
return op.mDrawTransaction;
}
return null;
}
void setOnShowRunnable(Runnable onShowRunnable) { void setOnShowRunnable(Runnable onShowRunnable) {
mOnShowRunnable = onShowRunnable; mOnShowRunnable = onShowRunnable;
} }
@@ -463,10 +482,10 @@ class AsyncRotationController extends FadeAnimationController implements Consume
final boolean keepUntilStartTransaction = final boolean keepUntilStartTransaction =
!mIsStartTransactionCommitted && op.mAction == Operation.ACTION_SEAMLESS; !mIsStartTransactionCommitted && op.mAction == Operation.ACTION_SEAMLESS;
if (!keepUntilTransitionFinish && !keepUntilStartTransaction) return false; if (!keepUntilTransitionFinish && !keepUntilStartTransaction) return false;
if (op.mCapturedDrawTransaction == null) { if (op.mDrawTransaction == null) {
op.mCapturedDrawTransaction = postDrawTransaction; op.mDrawTransaction = postDrawTransaction;
} else { } else {
op.mCapturedDrawTransaction.merge(postDrawTransaction); op.mDrawTransaction.merge(postDrawTransaction);
} }
if (DEBUG) Slog.d(TAG, "Capture draw transaction " + w); if (DEBUG) Slog.d(TAG, "Capture draw transaction " + w);
return true; return true;
@@ -512,7 +531,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume
* the start transaction of transition, so there won't be a flickering such as the window * the start transaction of transition, so there won't be a flickering such as the window
* has redrawn during fading out. * has redrawn during fading out.
*/ */
SurfaceControl.Transaction mCapturedDrawTransaction; SurfaceControl.Transaction mDrawTransaction;
Operation(@Action int action) { Operation(@Action int action) {
mAction = action; mAction = action;

View File

@@ -290,7 +290,22 @@ abstract class InsetsSourceProvider {
&& windowState.mWinAnimator.getShown() && mWindowContainer.okToDisplay()) { && windowState.mWinAnimator.getShown() && mWindowContainer.okToDisplay()) {
windowState.applyWithNextDraw(mSetLeashPositionConsumer); windowState.applyWithNextDraw(mSetLeashPositionConsumer);
} else { } else {
mSetLeashPositionConsumer.accept(mWindowContainer.getSyncTransaction()); Transaction t = mWindowContainer.getSyncTransaction();
if (windowState != null) {
// Make the buffer, token transformation, and leash position to be updated
// together when the window is drawn for new rotation. Otherwise the window
// may be outside the screen by the inconsistent orientations.
final AsyncRotationController rotationController =
mDisplayContent.getAsyncRotationController();
if (rotationController != null) {
final Transaction drawT =
rotationController.getDrawTransaction(windowState.mToken);
if (drawT != null) {
t = drawT;
}
}
}
mSetLeashPositionConsumer.accept(t);
} }
} }
if (mServerVisible && !mLastSourceFrame.equals(mSource.getFrame())) { if (mServerVisible && !mLastSourceFrame.equals(mSource.getFrame())) {
@@ -310,17 +325,15 @@ abstract class InsetsSourceProvider {
} }
private Point getWindowFrameSurfacePosition() { private Point getWindowFrameSurfacePosition() {
WindowState win = mWindowContainer.asWindowState(); final WindowState win = mWindowContainer.asWindowState();
if (mControl != null) { if (win != null && mControl != null) {
final AsyncRotationController controller = final AsyncRotationController controller = mDisplayContent.getAsyncRotationController();
win.mDisplayContent.getAsyncRotationController();
if (controller != null && controller.shouldFreezeInsetsPosition(win)) { if (controller != null && controller.shouldFreezeInsetsPosition(win)) {
// Use previous position because the fade-out animation runs in old rotation. // Use previous position because the window still shows with old rotation.
return mControl.getSurfacePosition(); return mControl.getSurfacePosition();
} }
} }
final Rect frame = mWindowContainer.asWindowState() != null final Rect frame = win != null ? win.getFrame() : mWindowContainer.getBounds();
? mWindowContainer.asWindowState().getFrame() : mWindowContainer.getBounds();
final Point position = new Point(); final Point position = new Point();
mWindowContainer.transformFrameToSurfacePosition(frame.left, frame.top, position); mWindowContainer.transformFrameToSurfacePosition(frame.left, frame.top, position);
return position; return position;