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

Commit 1a13e050 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

Merge "Performance optimizations for new insets" into rvc-dev am: 367257cf am: 728adc03

Change-Id: I2549eb1a1accbb6f63733bad4b91da63bc5d1983
parents ccd026b8 728adc03
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -318,8 +318,7 @@ interface IWindowSession {
     * Called when the client has changed the local insets state, and now the server should reflect
     * that new state.
     */
    void insetsModified(IWindow window, in InsetsState state);

    oneway void insetsModified(IWindow window, in InsetsState state);

    /**
     * Called when the system gesture exclusion has changed.
+0 −1
Original line number Diff line number Diff line
@@ -258,7 +258,6 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        return state.calculateInsets(frame, null /* ignoringVisibilityState */,
                false /* isScreenRound */,
                false /* alwaysConsumeSystemBars */, null /* displayCutout */,
                null /* legacyContentInsets */, null /* legacyStableInsets */,
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
                0 /* legacySystemUiFlags */, typeSideMap)
               .getInsets(mTypes);
+14 −18
Original line number Diff line number Diff line
@@ -363,9 +363,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    private final Runnable mAnimCallback;

    private final Rect mLastLegacyContentInsets = new Rect();
    private final Rect mLastLegacyStableInsets = new Rect();

    /** Pending control request that is waiting on IME to be ready to be shown */
    private PendingControlRequest mPendingImeControlRequest;

@@ -435,8 +432,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

            WindowInsets insets = state.calculateInsets(mFrame, mState /* ignoringVisibilityState*/,
                    mLastInsets.isRound(), mLastInsets.shouldAlwaysConsumeSystemBars(),
                    mLastDisplayCutout, mLastLegacyContentInsets, mLastLegacyStableInsets,
                    mLastLegacySoftInputMode, mLastLegacySystemUiFlags, null /* typeSideMap */);
                    mLastDisplayCutout, mLastLegacySoftInputMode, mLastLegacySystemUiFlags,
                    null /* typeSideMap */);
            mViewRoot.mView.dispatchWindowInsetsAnimationProgress(insets,
                    mUnmodifiableTmpRunningAnims);

@@ -466,13 +463,16 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    @VisibleForTesting
    public boolean onStateChanged(InsetsState state) {
        if (mState.equals(state) && mLastDispachedState.equals(state)) {
        boolean localStateChanged = !mState.equals(state);
        if (!localStateChanged && mLastDispachedState.equals(state)) {
            return false;
        }
        mState.set(state);
        mLastDispachedState.set(state, true /* copySources */);
        applyLocalVisibilityOverride();
        if (localStateChanged) {
            mViewRoot.notifyInsetsChanged();
        }
        if (!mState.equals(mLastDispachedState)) {
            sendStateToWindowManager();
        }
@@ -484,26 +484,23 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
     */
    @VisibleForTesting
    public WindowInsets calculateInsets(boolean isScreenRound,
            boolean alwaysConsumeSystemBars, DisplayCutout cutout, Rect legacyContentInsets,
            Rect legacyStableInsets, int legacySoftInputMode, int legacySystemUiFlags) {
        mLastLegacyContentInsets.set(legacyContentInsets);
        mLastLegacyStableInsets.set(legacyStableInsets);
            boolean alwaysConsumeSystemBars, DisplayCutout cutout,
            int legacySoftInputMode, int legacySystemUiFlags) {
        mLastLegacySoftInputMode = legacySoftInputMode;
        mLastLegacySystemUiFlags = legacySystemUiFlags;
        mLastDisplayCutout = cutout;
        mLastInsets = mState.calculateInsets(mFrame, null /* ignoringVisibilityState*/,
                isScreenRound, alwaysConsumeSystemBars, cutout, legacyContentInsets,
                legacyStableInsets, legacySoftInputMode, legacySystemUiFlags,
                isScreenRound, alwaysConsumeSystemBars, cutout,
                legacySoftInputMode, legacySystemUiFlags,
                null /* typeSideMap */);
        return mLastInsets;
    }

    /**
     * @see InsetsState#calculateVisibleInsets(Rect, Rect, int)
     * @see InsetsState#calculateVisibleInsets(Rect, int)
     */
    public Rect calculateVisibleInsets(Rect legacyVisibleInsets,
            @SoftInputModeFlags int softInputMode) {
        return mState.calculateVisibleInsets(mFrame, legacyVisibleInsets, softInputMode);
    public Rect calculateVisibleInsets(@SoftInputModeFlags int softInputMode) {
        return mState.calculateVisibleInsets(mFrame, softInputMode);
    }

    /**
@@ -954,7 +951,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            }
        }

        // TODO: Put this on a dispatcher thread.
        try {
            mViewRoot.mWindowSession.insetsModified(mViewRoot.mWindow, tmpState);
        } catch (RemoteException e) {
+1 −12
Original line number Diff line number Diff line
@@ -160,7 +160,6 @@ public class InsetsState implements Parcelable {
     */
    public WindowInsets calculateInsets(Rect frame, @Nullable InsetsState ignoringVisibilityState,
            boolean isScreenRound, boolean alwaysConsumeSystemBars, DisplayCutout cutout,
            @Nullable Rect legacyContentInsets, @Nullable Rect legacyStableInsets,
            int legacySoftInputMode, int legacySystemUiFlags,
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
        Insets[] typeInsetsMap = new Insets[Type.SIZE];
@@ -168,11 +167,6 @@ public class InsetsState implements Parcelable {
        boolean[] typeVisibilityMap = new boolean[SIZE];
        final Rect relativeFrame = new Rect(frame);
        final Rect relativeFrameMax = new Rect(frame);
        if (ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
                && legacyContentInsets != null && legacyStableInsets != null) {
            WindowInsets.assignCompatInsets(typeInsetsMap, legacyContentInsets);
            WindowInsets.assignCompatInsets(typeMaxInsetsMap, legacyStableInsets);
        }
        for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
            InsetsSource source = mSources.get(type);
            if (source == null) {
@@ -217,12 +211,7 @@ public class InsetsState implements Parcelable {
                        && (legacySystemUiFlags & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0);
    }

    public Rect calculateVisibleInsets(Rect frame, Rect legacyVisibleInsets,
            @SoftInputModeFlags int softInputMode) {
        if (sNewInsetsMode == NEW_INSETS_MODE_NONE) {
            return legacyVisibleInsets;
        }

    public Rect calculateVisibleInsets(Rect frame, @SoftInputModeFlags int softInputMode) {
        Insets insets = Insets.NONE;
        for (int type = FIRST_TYPE; type <= LAST_TYPE; type++) {
            InsetsSource source = mSources.get(type);
+7 −3
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import android.graphics.drawable.GradientDrawable;
import android.hardware.display.DisplayManagerGlobal;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -28745,7 +28746,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         * of the screen decorations, these are the current insets for the
         * content of the window.
         */
        @UnsupportedAppUsage
        @UnsupportedAppUsage(maxTargetSdk = VERSION_CODES.Q,
                publicAlternatives = "Use {@link WindowInsets#getInsets(int)}")
        final Rect mContentInsets = new Rect();
        /**
@@ -28753,7 +28755,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         * of the screen decorations, these are the current insets for the
         * actual visible parts of the window.
         */
        @UnsupportedAppUsage
        @UnsupportedAppUsage(maxTargetSdk = VERSION_CODES.Q,
                publicAlternatives = "Use {@link WindowInsets#getInsets(int)}")
        final Rect mVisibleInsets = new Rect();
        /**
@@ -28761,7 +28764,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         * of the screen decorations, these are the current insets for the
         * stable system windows.
         */
        @UnsupportedAppUsage
        @UnsupportedAppUsage(maxTargetSdk = VERSION_CODES.Q,
                publicAlternatives = "Use {@link WindowInsets#getInsets(int)}")
        final Rect mStableInsets = new Rect();
        final DisplayCutout.ParcelableWrapper mDisplayCutout =
Loading