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

Commit 0ac60d47 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Move the checking of mWindowAttributesChanged closer to relayoutWindow

It prevents additional relayoutWindow after the first performTraversals
if there is a SurfaceView in the view tree. It happens from
host.dispatchAttachedToWindow to SurfaceView#onAttachedToWindow
and then requestTransparentRegion that changes mWindowAttributesChanged
to true. So it is useless to clear mWindowAttributesChanged before the
path in the case.

Bug: 140407614
Test: The ViewRootImpl#relayoutWindow is only called once when
      launching a simple activity which contains a SurfaceView.

Change-Id: Id49226cab0e9407e6d76e6446f490145b0929594
parent e18cb098
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -1997,7 +1997,6 @@ public final class ViewRootImpl implements ViewParent,
        mIsInTraversal = true;
        mWillDrawSoon = true;
        boolean windowSizeMayChange = false;
        final boolean windowAttributesChanged = mWindowAttributesChanged;
        WindowManager.LayoutParams lp = mWindowAttributes;

        int desiredWindowWidth;
@@ -2014,10 +2013,6 @@ public final class ViewRootImpl implements ViewParent,
                ((mViewVisibility == View.VISIBLE) != (viewVisibility == View.VISIBLE));

        WindowManager.LayoutParams params = null;
        if (mWindowAttributesChanged) {
            mWindowAttributesChanged = false;
            params = lp;
        }
        CompatibilityInfo compatibilityInfo =
                mDisplay.getDisplayAdjustments().getCompatibilityInfo();
        if (compatibilityInfo.supportsScreen() == mLastInCompatMode) {
@@ -2194,16 +2189,6 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        if (params != null) {
            if ((host.mPrivateFlags & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) {
                if (!PixelFormat.formatHasAlpha(params.format)) {
                    params.format = PixelFormat.TRANSLUCENT;
                }
            }
            mAttachInfo.mOverscanRequested = (params.flags
                    & WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN) != 0;
        }

        if (mApplyInsetsRequested) {
            mApplyInsetsRequested = false;
            mLastOverscanRequested = mAttachInfo.mOverscanRequested;
@@ -2259,6 +2244,21 @@ public final class ViewRootImpl implements ViewParent,
        /* True if surface generation id changes. */
        boolean surfaceReplaced = false;

        final boolean windowAttributesChanged = mWindowAttributesChanged;
        if (windowAttributesChanged) {
            mWindowAttributesChanged = false;
            params = lp;
        }

        if (params != null) {
            if ((host.mPrivateFlags & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0
                    && !PixelFormat.formatHasAlpha(params.format)) {
                params.format = PixelFormat.TRANSLUCENT;
            }
            mAttachInfo.mOverscanRequested =
                    (params.flags & WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN) != 0;
        }

        if (mFirst || windowShouldResize || insetsChanged ||
                viewVisibilityChanged || params != null || mForceNextWindowRelayout) {
            mForceNextWindowRelayout = false;