Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 268bf688 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Yearly Window Manager spring cleaning #2

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

Test: RelayoutPerfTest
Bug: 159056748
Change-Id: Ia7d9514e14568b1aabc08e3b9f9106673e588f2d
parent bfa95a71
Loading
Loading
Loading
Loading
+23 −11
Original line number Diff line number Diff line
@@ -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.
     */
+15 −11
Original line number Diff line number Diff line
@@ -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) {