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

Commit e805ccd4 authored by Robert Carr's avatar Robert Carr
Browse files

ViewRootImpl: Always run finishBLASTSync

If we don't have any other commitCallbacks but we need to finish
a BLAST sync operation with SurfaceView, we still have to schedule
a frame complete callback. Also refactor the code a little to
remove some duplication.

Bug: 146598493
Test: Flip BLAST. Test Chrome.
Change-Id: I3475a45884fc13211e40613e316767addc286175
parent 6871767a
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -3683,32 +3683,29 @@ public final class ViewRootImpl implements ViewParent,
        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "draw");

        boolean usingAsyncReport = false;
        boolean reportNextDraw = mReportNextDraw; // Capture the original value
        if (mAttachInfo.mThreadedRenderer != null && mAttachInfo.mThreadedRenderer.isEnabled()) {
            ArrayList<Runnable> commitCallbacks = mAttachInfo.mTreeObserver
                    .captureFrameCommitCallbacks();
            if (mReportNextDraw) {
                usingAsyncReport = true;
            final boolean needFrameCompleteCallback = mNextDrawUseBLASTSyncTransaction ||
                (commitCallbacks != null && commitCallbacks.size() > 0) ||
                mReportNextDraw;
            usingAsyncReport = mReportNextDraw;
            if (needFrameCompleteCallback) {
                final Handler handler = mAttachInfo.mHandler;
                mAttachInfo.mThreadedRenderer.setFrameCompleteCallback((long frameNr) ->
                        handler.postAtFrontOfQueue(() -> {
                            finishBLASTSync();
                            if (reportNextDraw) {
                                // TODO: Use the frame number
                                pendingDrawFinished();
                            }
                            if (commitCallbacks != null) {
                                for (int i = 0; i < commitCallbacks.size(); i++) {
                                    commitCallbacks.get(i).run();
                                }
                            }
                        }));
            } else if (commitCallbacks != null && commitCallbacks.size() > 0) {
                final Handler handler = mAttachInfo.mHandler;
                mAttachInfo.mThreadedRenderer.setFrameCompleteCallback((long frameNr) ->
                        handler.postAtFrontOfQueue(() -> {
                            finishBLASTSync();
                            for (int i = 0; i < commitCallbacks.size(); i++) {
                                commitCallbacks.get(i).run();
                            }
                        }));
            }
        }