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

Commit dbf44cc8 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Only increment seqId when a new draw is actualy needed" into main

parents 65725ece e9ef42de
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -2303,16 +2303,18 @@ public final class ViewRootImpl implements ViewParent,
        if (alwaysSeqIdLayout()) {
            reportDraw = seqId > mSeqId;
        }
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
            Trace.instant(Trace.TRACE_TAG_VIEW, TextUtils.formatSimple("%s handleResized "
                            + "frameChanged=%b configChanged=%b seqId=%d mSeqId=%d buf=%b "
                            + "displayChanged=%b compatScaleChanged=%b attachedFrameChanged=%b",
                    mTag, frameChanged, configChanged, seqId, mSeqId, syncWithBuffers,
                    displayChanged, compatScaleChanged, attachedFrameChanged));
        }
        if (!reportDraw && !frameChanged && !configChanged && !attachedFrameChanged
                && !displayChanged && !forceLayout
                && !compatScaleChanged && !dragResizingChanged) {
            return;
        }
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
            Trace.instant(Trace.TRACE_TAG_VIEW, TextUtils.formatSimple("%s handleResized "
                            + "frameChanged=%b configChanged=%b seqId=%d mSeqId=%d buf=%b",
                    mTag, frameChanged, configChanged, seqId, mSeqId, syncWithBuffers));
        }
        mPendingDragResizing = dragResizing;
        mTmpFrames.compatScale = compatScale;
@@ -4604,6 +4606,11 @@ public final class ViewRootImpl implements ViewParent,
        }
        final int seqId = alwaysSeqIdLayout() ? mSeqId : mSyncSeqId;
        if (alwaysSeqIdLayout()) {
            // If WM asks for a redraw or sync without actually changing config, we won't have run
            // relayout but still need to track that we have drawn the associated frame.
            mLastSeqId = Math.max(mSeqId, mLastSeqId);
        }
        mWmsRequestSyncGroupState = WMS_SYNC_PENDING;
        mWmsRequestSyncGroup = new SurfaceSyncGroup("wmsSync-" + mTag, t -> {
            mWmsRequestSyncGroupState = WMS_SYNC_MERGED;
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class WindowFrames {
    /**
     * @return true if the width or height has changed since last reported to the client.
     */
    boolean isFrameSizeChangeReported() {
    boolean isFrameSizeChanged() {
        return mFrameSizeChanged || didFrameSizeChange();
    }

+3 −3
Original line number Diff line number Diff line
@@ -2812,9 +2812,9 @@ public class WindowManagerService extends IWindowManager.Stub
                win.mActivityRecord.updateReportedVisibilityLocked();
            }

            if (outFrames != null && outMergedConfiguration != null) {
                final boolean shouldReportActivityWindowInfo = outRelayoutResult != null
                            && win.mLastReportedActivityWindowInfo != null;
            if (outRelayoutResult != null) {
                final boolean shouldReportActivityWindowInfo =
                        win.mLastReportedActivityWindowInfo != null;
                final ActivityWindowInfo outActivityWindowInfo = shouldReportActivityWindowInfo
                        ? new ActivityWindowInfo()
                        : null;
+11 −14
Original line number Diff line number Diff line
@@ -3726,13 +3726,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            ProtoLog.i(WM_DEBUG_ORIENTATION, "Resizing %s WITH DRAW PENDING", this);
        }

        // Always reset these states first, so if {@link IWindow#resized} fails, this
        // window won't be added to {@link WindowManagerService#mResizingWindows} and set
        // {@link #mOrientationChanging} to true again by {@link #updateResizingWindowIfNeeded}
        // that may cause WINDOW_FREEZE_TIMEOUT because resizing the client keeps failing.
        mDragResizingChangeReported = true;
        mWindowFrames.clearReportResizeHints();

        final int prevRotation = mLastReportedConfiguration
                .getMergedConfiguration().windowConfiguration.getRotation();
        fillClientWindowFramesAndConfiguration(mLastReportedFrames, mLastReportedConfiguration,
@@ -3749,6 +3742,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            seqIdToSend = syncWithBuffers ? mSyncSeqId : -1;
        } else {
            reportDraw = false;
            // If a sync is open (not-ready), or was open when this resize was queued, then we need
            // now wait for this new resize to report back.
            if (mSyncState == SYNC_STATE_READY && (mPendingSyncResize || !getSyncGroup().mReady)) {
                mSyncState = SYNC_STATE_WAITING_FOR_DRAW;
            }
            syncWithBuffers = mBufferSeqId > mSyncSeqId;
            if (syncWithBuffers) {
                if (mSyncState != SYNC_STATE_NONE) {
@@ -3760,14 +3758,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    dropBufferFrom(mSyncTransaction);
                }
                mSyncSeqId = mBufferSeqId;
            } else {
            } else if (!mLastConfigReportedToClient
                    || mWindowFrames.isFrameSizeChanged()
                    || mSyncState == SYNC_STATE_WAITING_FOR_DRAW) {
                ++mSyncSeqId;
            }
            // If a sync is open (not-ready), or was open when this resize was queued, then we need
            // now wait for this new resize to report back.
            if (mSyncState == SYNC_STATE_READY && (mPendingSyncResize || !getSyncGroup().mReady)) {
                mSyncState = SYNC_STATE_WAITING_FOR_DRAW;
            }
            mPendingSyncResize = false;
            seqIdToSend = mSyncSeqId;
            if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
@@ -3785,6 +3780,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
        final boolean isDragResizing = isDragResizing();

        mDragResizingChangeReported = true;
        mWindowFrames.clearReportResizeHints();
        if (!Flags.alwaysSeqIdLayout()) {
            markRedrawForSyncReported();
        }
@@ -5280,7 +5277,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }

        if (!mSurfaceAnimator.hasLeash() && !mLastSurfacePosition.equals(mSurfacePosition)) {
            final boolean frameSizeChanged = mWindowFrames.isFrameSizeChangeReported();
            final boolean frameSizeChanged = mWindowFrames.isFrameSizeChanged();
            final boolean surfaceInsetsChanged = surfaceInsetsChanging();
            final boolean surfaceSizeChanged = frameSizeChanged || surfaceInsetsChanged;
            mLastSurfacePosition.set(mSurfacePosition.x, mSurfacePosition.y);