Yearly Window Manager spring cleaning #2

- Cache WPC
- Use iteration instead of recursion to check animating

Test: RelayoutPerfTest
Bug: 159056748
Change-Id: Ia7d9514e14568b1aabc08e3b9f9106673e588f2d
This commit is contained in:
Jorim Jaggi
2020-06-18 23:44:02 +02:00
parent bfa95a71fb
commit 268bf68882
2 changed files with 38 additions and 22 deletions

View File

@@ -179,6 +179,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
* Applied as part of the animation pass in "prepareSurfaces".
*/
protected final SurfaceAnimator mSurfaceAnimator;
private boolean mAnyParentAnimating;
final SurfaceFreezer mSurfaceFreezer;
protected final WindowManagerService mWmService;
@@ -2459,21 +2461,16 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
*/
@Nullable
WindowContainer getAnimatingContainer(int flags, int typesToCheck) {
int animationType = mSurfaceAnimator.getAnimationType();
if (mSurfaceAnimator.isAnimating() && (animationType & typesToCheck) > 0) {
return this;
}
if ((flags & TRANSITION) != 0 && isWaitingForTransitionStart()) {
if (isSelfAnimating(flags, typesToCheck)) {
return this;
}
if ((flags & PARENTS) != 0) {
final WindowContainer parent = getParent();
if (parent != null) {
final WindowContainer wc = parent.getAnimatingContainer(
flags & ~CHILDREN, typesToCheck);
if (wc != null) {
return wc;
WindowContainer parent = getParent();
while (parent != null) {
if (parent.isSelfAnimating(flags, typesToCheck)) {
return parent;
}
parent = parent.getParent();
}
}
if ((flags & CHILDREN) != 0) {
@@ -2488,6 +2485,21 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return null;
}
/**
* Internal method only to be used during {@link #getAnimatingContainer(int, int)}.DO NOT CALL
* FROM OUTSIDE.
*/
protected boolean isSelfAnimating(int flags, int typesToCheck) {
if (mSurfaceAnimator.isAnimating()
&& (mSurfaceAnimator.getAnimationType() & typesToCheck) > 0) {
return true;
}
if ((flags & TRANSITION) != 0 && isWaitingForTransitionStart()) {
return true;
}
return false;
}
/**
* @deprecated Use {@link #getAnimatingContainer(int, int)} instead.
*/

View File

@@ -705,6 +705,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
static final int BLAST_TIMEOUT_DURATION = 5000; /* milliseconds */
private final WindowProcessController mWpcForDisplayConfigChanges;
/**
* @return The insets state as requested by the client, i.e. the dispatched insets state
* for which the visibilities are overridden with what the client requested.
@@ -873,6 +875,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mSubLayer = 0;
mInputWindowHandle = null;
mWinAnimator = null;
mWpcForDisplayConfigChanges = null;
return;
}
mDeathRecipient = deathRecipient;
@@ -928,6 +931,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
ProtoLog.v(WM_DEBUG_ADD_REMOVE, "Adding %s to %s", this, parentWindow);
parentWindow.addChild(this, sWindowSubLayerComparator);
}
// System process or invalid process cannot register to display config change.
mWpcForDisplayConfigChanges = (s.mPid == MY_PID || s.mPid < 0)
? null
: service.mAtmService.getProcessController(s.mPid, s.mUid);
}
void attach() {
@@ -3501,13 +3509,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
/** @return {@code true} if the process registered to a display as a config listener. */
private boolean registeredForDisplayConfigChanges() {
final WindowState parentWindow = getParentWindow();
final Session session = parentWindow != null ? parentWindow.mSession : mSession;
// System process or invalid process cannot register to display config change.
if (session.mPid == MY_PID || session.mPid < 0) return false;
WindowProcessController app =
mWmService.mAtmService.getProcessController(session.mPid, session.mUid);
if (app == null || !app.registeredForDisplayConfigChanges()) return false;
return true;
final WindowProcessController wpc = parentWindow != null
? parentWindow.mWpcForDisplayConfigChanges
: mWpcForDisplayConfigChanges;
return wpc != null && wpc.registeredForDisplayConfigChanges();
}
void reportResized() {
@@ -5090,13 +5095,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mWindowFrames.updateLastInsetValues();
}
@Nullable
@Override
WindowContainer<WindowState> getAnimatingContainer(int flags, int typesToCheck) {
protected boolean isSelfAnimating(int flags, int typesToCheck) {
if (mControllableInsetProvider != null) {
return null;
return false;
}
return super.getAnimatingContainer(flags, typesToCheck);
return super.isSelfAnimating(flags, typesToCheck);
}
void startAnimation(Animation anim) {