Use current rotation for snapshot of canceling fixed rotation

The display rotation doesn't change in the case (the app is rotated).
So use the identity matrix for the snapshot surface.

Also fix a potential case of app freeze timeout:
(e.g. from AR#onCancelFixedRotationTransform)
1. Previous states: allDrawn=true, mLastAllDrawn=true.
2. Request redraw:
   AR#clearAllDrawn -> allDrawn=false, mLastAllDrawn=true
3. App reported drawn:
   AR#updateAllDrawn -> allDrawn=true, mLastAllDrawn=true
4. AR#checkAppWindowsReadyToShow skipped by allDrawn==mLastAllDrawn
   that missed to unfreeze even allDrawn was changed to true.

Bug: 188615885
Test: Auto rotation enabled. Put device in landscape. Launch a
      rotatable app from portrait launcher and rotate the device
      to portrait immediately. The snapshot should keep the same
      rotation for animation.

Change-Id: If9fe8e317669d3d9ef57af9acdbdbf53cd575efe
This commit is contained in:
Riddle Hsu
2021-05-19 18:49:53 +08:00
parent 21f0b70da5
commit 717b2a58ef
2 changed files with 11 additions and 1 deletions

View File

@@ -4213,6 +4213,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
void clearAllDrawn() {
allDrawn = false;
mLastAllDrawn = false;
}
/**

View File

@@ -253,7 +253,16 @@ class ScreenRotationAnimation {
ProtoLog.i(WM_SHOW_SURFACE_ALLOC,
" FREEZE %s: CREATE", mScreenshotLayer);
setRotation(t, realOriginalRotation);
if (originalRotation == realOriginalRotation) {
setRotation(t, realOriginalRotation);
} else {
// If the given original rotation is different from real original display rotation,
// this is playing non-zero degree rotation animation without display rotation change,
// so the snapshot doesn't need to be transformed.
mCurRotation = realOriginalRotation;
mSnapshotInitialMatrix.reset();
setRotationTransform(t, mSnapshotInitialMatrix);
}
t.apply();
}