Merge "Call preserveSurfaces when detaching children." into rvc-dev

This commit is contained in:
Chavi Weingarten
2020-06-05 00:05:03 +00:00
committed by Android (Google) Code Review

View File

@@ -418,25 +418,25 @@ class WindowStateAnimator {
if (!mDestroyPreservedSurfaceUponRedraw) { if (!mDestroyPreservedSurfaceUponRedraw) {
return; return;
} }
if (mSurfaceController != null) {
if (mPendingDestroySurface != null) { // If we are preserving a surface but we aren't relaunching that means
// If we are preserving a surface but we aren't relaunching that means // we are just doing an in-place switch. In that case any SurfaceFlinger side
// we are just doing an in-place switch. In that case any SurfaceFlinger side // child layers need to be reparented to the new surface to make this
// child layers need to be reparented to the new surface to make this // transparent to the app.
// transparent to the app. // If the children are detached, we don't want to reparent them to the new surface.
if (mWin.mActivityRecord == null || mWin.mActivityRecord.isRelaunching() == false) { // Instead let the children get removed when the old surface is deleted.
mPostDrawTransaction.reparentChildren( if (mSurfaceController != null && mPendingDestroySurface != null && !mChildrenDetached
mPendingDestroySurface.getClientViewRootSurface(), && (mWin.mActivityRecord == null || !mWin.mActivityRecord.isRelaunching())) {
mSurfaceController.mSurfaceControl).apply(); mPostDrawTransaction.reparentChildren(
} mPendingDestroySurface.getClientViewRootSurface(),
} mSurfaceController.mSurfaceControl).apply();
} }
destroyDeferredSurfaceLocked(); destroyDeferredSurfaceLocked();
mDestroyPreservedSurfaceUponRedraw = false; mDestroyPreservedSurfaceUponRedraw = false;
} }
void markPreservedSurfaceForDestroy() { private void markPreservedSurfaceForDestroy() {
if (mDestroyPreservedSurfaceUponRedraw if (mDestroyPreservedSurfaceUponRedraw
&& !mService.mDestroyPreservedSurface.contains(mWin)) { && !mService.mDestroyPreservedSurface.contains(mWin)) {
mService.mDestroyPreservedSurface.add(mWin); mService.mDestroyPreservedSurface.add(mWin);
@@ -1363,9 +1363,13 @@ class WindowStateAnimator {
if (mPendingDestroySurface != null && mDestroyPreservedSurfaceUponRedraw) { if (mPendingDestroySurface != null && mDestroyPreservedSurfaceUponRedraw) {
final SurfaceControl pendingSurfaceControl = mPendingDestroySurface.mSurfaceControl; final SurfaceControl pendingSurfaceControl = mPendingDestroySurface.mSurfaceControl;
mPostDrawTransaction.reparent(pendingSurfaceControl, null); mPostDrawTransaction.reparent(pendingSurfaceControl, null);
mPostDrawTransaction.reparentChildren( // If the children are detached, we don't want to reparent them to the new surface.
mPendingDestroySurface.getClientViewRootSurface(), // Instead let the children get removed when the old surface is deleted.
mSurfaceController.mSurfaceControl); if (!mChildrenDetached) {
mPostDrawTransaction.reparentChildren(
mPendingDestroySurface.getClientViewRootSurface(),
mSurfaceController.mSurfaceControl);
}
} }
SurfaceControl.mergeToGlobalTransaction(mPostDrawTransaction); SurfaceControl.mergeToGlobalTransaction(mPostDrawTransaction);
@@ -1593,6 +1597,12 @@ class WindowStateAnimator {
mSurfaceController.detachChildren(); mSurfaceController.detachChildren();
} }
mChildrenDetached = true; mChildrenDetached = true;
// If the children are detached, it means the app is exiting. We don't want to tear the
// content down too early, otherwise we could end up with a flicker. By preserving the
// current surface, we ensure the content remains on screen until the window is completely
// removed. It also ensures that the old surface is cleaned up when started again since it
// forces mSurfaceController to be set to null.
preserveSurfaceLocked();
} }
void setOffsetPositionForStackResize(boolean offsetPositionForStackResize) { void setOffsetPositionForStackResize(boolean offsetPositionForStackResize) {