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

Commit 381cd723 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Don't compare configs during layout

Config.equals is expensive - instead, we keep track of whether it
has changed or not.

Bug: 129389526
Change-Id: I109cead72f4736803aa1e25cdc0f1340699535f4
parent 91d382a3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -656,7 +656,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        if (DEBUG_LAYOUT && !w.mLayoutAttached) {
            Slog.v(TAG, "1ST PASS " + w + ": gone=" + gone + " mHaveFrame=" + w.mHaveFrame
                    + " mLayoutAttached=" + w.mLayoutAttached
                    + " screen changed=" + w.isConfigChanged());
                    + " config reported=" + w.isLastConfigReportedToClient());
            final AppWindowToken atoken = w.mAppToken;
            if (gone) Slog.v(TAG, "  GONE: mViewVisibility=" + w.mViewVisibility
                    + " mRelayoutCalled=" + w.mRelayoutCalled + " hidden=" + w.mToken.isHidden()
+17 −4
Original line number Diff line number Diff line
@@ -307,6 +307,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
     */
    private final MergedConfiguration mLastReportedConfiguration = new MergedConfiguration();

    /** @see #isLastConfigReportedToClient() */
    private boolean mLastConfigReportedToClient;

    private final Configuration mTempConfiguration = new Configuration();

    /**
@@ -1200,7 +1203,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }

        boolean didFrameInsetsChange = setReportResizeHints();
        boolean configChanged = isConfigChanged();
        boolean configChanged = !isLastConfigReportedToClient();
        if (DEBUG_CONFIGURATION && configChanged) {
            Slog.v(TAG_WM, "Win " + this + " config changed: " + getConfiguration());
        }
@@ -1780,9 +1783,18 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return getDisplayContent().getBounds().equals(getBounds());
    }

    /** Returns true if last applied config was not yet requested by client. */
    boolean isConfigChanged() {
        return !getLastReportedConfiguration().equals(getConfiguration());
    /**
     * @return {@code true} if last applied config was reported to the client already, {@code false}
     *         otherwise.
     */
    boolean isLastConfigReportedToClient() {
        return mLastConfigReportedToClient;
    }

    @Override
    void onMergedOverrideConfigurationChanged() {
        super.onMergedOverrideConfigurationChanged();
        mLastConfigReportedToClient = false;
    }

    void onWindowReplacementTimeout() {
@@ -2365,6 +2377,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    void setLastReportedMergedConfiguration(MergedConfiguration config) {
        mLastReportedConfiguration.setTo(config);
        mLastConfigReportedToClient = true;
    }

    void getLastReportedMergedConfiguration(MergedConfiguration config) {