Replace MainWindowSizeChange transaction with applyWithNextDraw
It's legacy code from the days of deferred transactions but still has callers because it's convenient in it's own way. It has some details relating to relayout that could get in the way of our plan to remove it and so we refactor the primitive to make use of the applyWithNextDraw primitive to make it easier to port everything to the async system. Bug: 161810301 Bug: 175861051 Bug: 175861127 Bug: 200285149 Bug: 214315611 Change-Id: I369ff2fc8b4c730c4d31d9c1b89970bd295c32a3
This commit is contained in:
@@ -504,13 +504,6 @@ class Task extends TaskFragment {
|
||||
*/
|
||||
boolean mInRemoveTask;
|
||||
|
||||
// When non-null, this is a transaction that will get applied on the next frame returned after
|
||||
// a relayout is requested from the client. While this is only valid on a leaf task; since the
|
||||
// transaction can effect an ancestor task, this also needs to keep track of the ancestor task
|
||||
// that this transaction manipulates because deferUntilFrame acts on individual surfaces.
|
||||
SurfaceControl.Transaction mMainWindowSizeChangeTransaction;
|
||||
Task mMainWindowSizeChangeTask;
|
||||
|
||||
private final AnimatingActivityRegistry mAnimatingActivityRegistry =
|
||||
new AnimatingActivityRegistry();
|
||||
|
||||
@@ -4390,17 +4383,16 @@ class Task extends TaskFragment {
|
||||
leaf.setMainWindowSizeChangeTransaction(t, origin);
|
||||
return;
|
||||
}
|
||||
mMainWindowSizeChangeTransaction = t;
|
||||
mMainWindowSizeChangeTask = t == null ? null : origin;
|
||||
final WindowState w = getTopVisibleAppMainWindow();
|
||||
if (w != null) {
|
||||
w.applyWithNextDraw((d) -> {
|
||||
d.merge(t);
|
||||
});
|
||||
} else {
|
||||
t.apply();
|
||||
}
|
||||
}
|
||||
|
||||
SurfaceControl.Transaction getMainWindowSizeChangeTransaction() {
|
||||
return mMainWindowSizeChangeTransaction;
|
||||
}
|
||||
|
||||
Task getMainWindowSizeChangeTask() {
|
||||
return mMainWindowSizeChangeTask;
|
||||
}
|
||||
|
||||
void setActivityWindowingMode(int windowingMode) {
|
||||
PooledConsumer c = PooledLambda.obtainConsumer(ActivityRecord::setWindowingMode,
|
||||
|
||||
@@ -5987,15 +5987,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
finishDrawing(null);
|
||||
mWmService.mH.removeMessages(WINDOW_STATE_BLAST_SYNC_TIMEOUT, this);
|
||||
if (!useBLASTSync()) return;
|
||||
|
||||
final Task task = getTask();
|
||||
if (task != null) {
|
||||
final SurfaceControl.Transaction t = task.getMainWindowSizeChangeTransaction();
|
||||
if (t != null) {
|
||||
mSyncTransaction.merge(t);
|
||||
}
|
||||
task.setMainWindowSizeChangeTransaction(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6032,10 +6023,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
if (mRedrawForSyncReported) {
|
||||
return false;
|
||||
}
|
||||
final Task task = getTask();
|
||||
if (task != null && task.getMainWindowSizeChangeTransaction() != null) {
|
||||
return true;
|
||||
}
|
||||
return useBLASTSync();
|
||||
}
|
||||
|
||||
|
||||
@@ -442,50 +442,6 @@ class WindowStateAnimator {
|
||||
return mService.useBLASTSync() && mWin.useBLASTSync();
|
||||
}
|
||||
|
||||
private boolean shouldConsumeMainWindowSizeTransaction() {
|
||||
// We only consume the transaction when the client is calling relayout
|
||||
// because this is the only time we know the frameNumber will be valid
|
||||
// due to the client renderer being paused. Put otherwise, only when
|
||||
// mInRelayout is true can we guarantee the next frame will contain
|
||||
// the most recent configuration.
|
||||
if (!mWin.mInRelayout) return false;
|
||||
// Since we can only do this for one window, we focus on the main application window
|
||||
if (mAttrType != TYPE_BASE_APPLICATION) return false;
|
||||
final Task task = mWin.getTask();
|
||||
if (task == null) return false;
|
||||
if (task.getMainWindowSizeChangeTransaction() == null) return false;
|
||||
// Likewise we only focus on the task root, since we can only use one window
|
||||
if (!mWin.mActivityRecord.isRootOfTask()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void setSurfaceBoundariesLocked(SurfaceControl.Transaction t) {
|
||||
if (mSurfaceController == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final WindowState w = mWin;
|
||||
final Task task = w.getTask();
|
||||
if (shouldConsumeMainWindowSizeTransaction()) {
|
||||
if (isInBlastSync()) {
|
||||
// If we're in a sync transaction, there's no need to call defer transaction.
|
||||
// The sync transaction will contain the buffer so the bounds change transaction
|
||||
// will only be applied with the buffer.
|
||||
t.merge(task.getMainWindowSizeChangeTransaction());
|
||||
task.setMainWindowSizeChangeTransaction(null);
|
||||
} else {
|
||||
mWin.applyWithNextDraw(finishedFrame -> {
|
||||
final SurfaceControl.Transaction sizeChangedTransaction =
|
||||
task.getMainWindowSizeChangeTransaction();
|
||||
if (sizeChangedTransaction != null) {
|
||||
finishedFrame.merge(sizeChangedTransaction);
|
||||
task.setMainWindowSizeChangeTransaction(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void prepareSurfaceLocked(SurfaceControl.Transaction t) {
|
||||
final WindowState w = mWin;
|
||||
if (!hasSurface()) {
|
||||
@@ -501,8 +457,6 @@ class WindowStateAnimator {
|
||||
|
||||
computeShownFrameLocked();
|
||||
|
||||
setSurfaceBoundariesLocked(t);
|
||||
|
||||
if (w.isParentWindowHidden() || !w.isOnScreen()) {
|
||||
hide(t, "prepareSurfaceLocked");
|
||||
mWallpaperControllerLocked.hideWallpapers(w);
|
||||
|
||||
Reference in New Issue
Block a user