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

Commit f152673f authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Automerger Merge Worker
Browse files

Merge "Set mSyncBuffer to true when VRI did not initiate the sync request"...

Merge "Set mSyncBuffer to true when VRI did not initiate the sync request" into tm-dev am: 700cdec4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17746204



Change-Id: I89417774466b95cefcdb64b1035dde490327c62d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e6bb8e25 700cdec4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -967,7 +967,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                final boolean redrawNeeded = sizeChanged || creating || hintChanged
                        || (mVisible && !mDrawFinished);
                boolean shouldSyncBuffer =
                        redrawNeeded && viewRoot.wasRelayoutRequested() && viewRoot.isInSync();
                        redrawNeeded && viewRoot.wasRelayoutRequested() && viewRoot.isInLocalSync();
                SyncBufferTransactionCallback syncBufferTransactionCallback = null;
                if (shouldSyncBuffer) {
                    syncBufferTransactionCallback = new SyncBufferTransactionCallback();
+24 −16
Original line number Diff line number Diff line
@@ -319,6 +319,8 @@ public final class ViewRootImpl implements ViewParent,
     */
    private static final int SCROLL_CAPTURE_REQUEST_TIMEOUT_MILLIS = 2500;

    private static final int UNSET_SYNC_ID = -1;

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>();

@@ -815,7 +817,7 @@ public final class ViewRootImpl implements ViewParent,
    }

    private final SurfaceSyncer mSurfaceSyncer = new SurfaceSyncer();
    private int mLastSyncId = -1;
    private int mSyncId = UNSET_SYNC_ID;
    private SurfaceSyncer.SyncBufferCallback mSyncBufferCallback;
    private int mNumSyncsInProgress = 0;

@@ -3463,21 +3465,21 @@ public final class ViewRootImpl implements ViewParent,
            mReportNextDraw = false;
            mSyncBufferCallback = null;
            mSyncBuffer = false;
            if (mLastSyncId != -1) {
                mSurfaceSyncer.markSyncReady(mLastSyncId);
                mLastSyncId = -1;
            if (isInLocalSync()) {
                mSurfaceSyncer.markSyncReady(mSyncId);
                mSyncId = UNSET_SYNC_ID;
            }
        }
    }

    private void createSyncIfNeeded() {
        // Started a sync already or there's nothing needing to sync
        if (mLastSyncId != -1 || !mReportNextDraw) {
        if (isInLocalSync() || !mReportNextDraw) {
            return;
        }

        final int seqId = mSyncSeqId;
        mLastSyncId = mSurfaceSyncer.setupSync(transaction -> {
        mSyncId = mSurfaceSyncer.setupSync(transaction -> {
            // Callback will be invoked on executor thread so post to main thread.
            mHandler.postAtFrontOfQueue(() -> {
                mSurfaceChangedTransaction.merge(transaction);
@@ -3485,9 +3487,9 @@ public final class ViewRootImpl implements ViewParent,
            });
        });
        if (DEBUG_BLAST) {
            Log.d(mTag, "Setup new sync id=" + mLastSyncId);
            Log.d(mTag, "Setup new sync id=" + mSyncId);
        }
        mSurfaceSyncer.addToSync(mLastSyncId, mSyncTarget);
        mSurfaceSyncer.addToSync(mSyncId, mSyncTarget);
    }

    private void notifyContentCatpureEvents() {
@@ -4123,17 +4125,19 @@ public final class ViewRootImpl implements ViewParent,
        return mAttachInfo.mThreadedRenderer != null && mAttachInfo.mThreadedRenderer.isEnabled();
    }

    boolean addToSync(SurfaceSyncer.SyncTarget syncable) {
        if (mLastSyncId == -1) {
            return false;
    void addToSync(SurfaceSyncer.SyncTarget syncable) {
        if (!isInLocalSync()) {
            return;
        }
        mSurfaceSyncer.addToSync(mLastSyncId, syncable);
        return true;
        mSurfaceSyncer.addToSync(mSyncId, syncable);
    }


    public boolean isInSync() {
        return mLastSyncId != -1;
    /**
     * This VRI is currently in the middle of a sync request, but specifically one initiated from
     * within VRI.
     */
    public boolean isInLocalSync() {
        return mSyncId != UNSET_SYNC_ID;
    }

    private void addFrameCommitCallbackIfNeeded() {
@@ -10895,6 +10899,10 @@ public final class ViewRootImpl implements ViewParent,

    private void readyToSync(SurfaceSyncer.SyncBufferCallback syncBufferCallback) {
        mNumSyncsInProgress++;
        if (!isInLocalSync()) {
            // Always sync the buffer if the sync request did not come from VRI.
            mSyncBuffer = true;
        }
        if (mAttachInfo.mThreadedRenderer != null) {
            HardwareRenderer.setRtAnimationsEnabled(false);
        }