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

Commit 15d0ac57 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce relayoutWindow when requestTransparentRegion

The pixel format should only need to apply once if the private
flags is actually changed. The subsequent request doesn't change
the window attributes. The most common case is from
SurfaceView#onAttachedToWindow and performDrawFinished.

Also remove mWindowAttributesChangesFlag which is never checked.
It was added in commit f21c9b0f and its functionality was replaced
by commit 40e0383d.

Bug: 140407614
Test: Enable log of relayoutWindow in WindowManagerService.
      Launch a sample app with a button which will add a
      SurfaceView if clicked. The relayoutWindow log won't
      appear after the second time pressing the button.

Change-Id: I13d36e390faad17a8e39a8c17c95fee5d3111960
parent 87617a9b
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -468,7 +468,6 @@ public final class ViewRootImpl implements ViewParent,
    private final UnhandledKeyManager mUnhandledKeyManager = new UnhandledKeyManager();

    boolean mWindowAttributesChanged = false;
    int mWindowAttributesChangesFlag = 0;

    // These can be accessed by any thread, must be protected with a lock.
    // Surface can never be reassigned or cleared (use Surface.clear()).
@@ -865,7 +864,6 @@ public final class ViewRootImpl implements ViewParent,

                mSoftInputMode = attrs.softInputMode;
                mWindowAttributesChanged = true;
                mWindowAttributesChangesFlag = WindowManager.LayoutParams.EVERYTHING_CHANGED;
                mAttachInfo.mRootView = view;
                mAttachInfo.mScalingRequired = mTranslator != null;
                mAttachInfo.mApplicationScale =
@@ -1269,14 +1267,12 @@ public final class ViewRootImpl implements ViewParent,
            attrs.systemUiVisibility = mWindowAttributes.systemUiVisibility;
            attrs.subtreeSystemUiVisibility = mWindowAttributes.subtreeSystemUiVisibility;

            mWindowAttributesChangesFlag = mWindowAttributes.copyFrom(attrs);
            if ((mWindowAttributesChangesFlag
                    & WindowManager.LayoutParams.TRANSLUCENT_FLAGS_CHANGED) != 0) {
            final int changes = mWindowAttributes.copyFrom(attrs);
            if ((changes & WindowManager.LayoutParams.TRANSLUCENT_FLAGS_CHANGED) != 0) {
                // Recompute system ui visibility.
                mAttachInfo.mRecomputeGlobalAttributes = true;
            }
            if ((mWindowAttributesChangesFlag
                    & WindowManager.LayoutParams.LAYOUT_CHANGED) != 0) {
            if ((changes & WindowManager.LayoutParams.LAYOUT_CHANGED) != 0) {
                // Request to update light center.
                mAttachInfo.mNeedsUpdateLightCenter = true;
            }
@@ -2037,8 +2033,6 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        mWindowAttributesChangesFlag = 0;

        Rect frame = mWinFrame;
        if (mFirst) {
            mFullRedrawNeeded = true;
@@ -3313,14 +3307,19 @@ public final class ViewRootImpl implements ViewParent,
    public void requestTransparentRegion(View child) {
        // the test below should not fail unless someone is messing with us
        checkThread();
        if (mView == child) {
        if (mView != child) {
            return;
        }

        if ((mView.mPrivateFlags & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) == 0) {
            mView.mPrivateFlags |= View.PFLAG_REQUEST_TRANSPARENT_REGIONS;
            // Need to make sure we re-evaluate the window attributes next
            // time around, to ensure the window has the correct format.
            mWindowAttributesChanged = true;
            mWindowAttributesChangesFlag = 0;
            requestLayout();
        }

        // Always request layout to apply the latest transparent region.
        requestLayout();
    }

    /**
+0 −2
Original line number Diff line number Diff line
@@ -2891,8 +2891,6 @@ public interface WindowManager extends ViewManager {
        public static final int COLOR_MODE_CHANGED = 1 << 26;
        /** {@hide} */
        public static final int INSET_FLAGS_CHANGED = 1 << 27;
        /** {@hide} */
        public static final int EVERYTHING_CHANGED = 0xffffffff;

        // internal buffer to backup/restore parameters under compatibility mode.
        private int[] mCompatibilityParamsBackup = null;