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

Commit cbb81290 authored by Rob Carr's avatar Rob Carr Committed by Automerger Merge Worker
Browse files

Merge "SyncRtSurfaceTransactionApplier: Improve thread safety" into sc-dev am:...

Merge "SyncRtSurfaceTransactionApplier: Improve thread safety" into sc-dev am: 84c2f5bf am: ed426948

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

Change-Id: I3238d489f0e2e4b31c7e610f171305388d12d26a
parents 0fb23271 ed426948
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -54,20 +54,21 @@ public class SyncRtSurfaceTransactionApplier {
    /**
     * Schedules applying surface parameters on the next frame.
     *
     * @param params The surface parameters to apply. DO NOT MODIFY the list after passing into
     *               this method to avoid synchronization issues.
     * @param params The surface parameters to apply.
     */
    public void scheduleApply(final SurfaceParams... params) {
        if (mTargetViewRootImpl == null) {
            return;
        }
        mTargetSc = mTargetViewRootImpl.getSurfaceControl();
        final Transaction t = new Transaction();
        applyParams(t, params);

        mTargetViewRootImpl.registerRtFrameCallback(frame -> {
            if (mTargetSc == null || !mTargetSc.isValid()) {
                return;
            }
            Transaction t = new Transaction();
            applyParams(t, frame, params);
            applyTransaction(t, frame);
        });

        // Make sure a frame gets scheduled.
@@ -78,15 +79,17 @@ public class SyncRtSurfaceTransactionApplier {
     * Applies surface parameters on the next frame.
     * @param t transaction to apply all parameters in.
     * @param frame frame to synchronize to. Set -1 when sync is not required.
     * @param params The surface parameters to apply. DO NOT MODIFY the list after passing into
     *               this method to avoid synchronization issues.
     * @param params The surface parameters to apply.
     */
     void applyParams(Transaction t, long frame, final SurfaceParams... params) {
     void applyParams(Transaction t, final SurfaceParams... params) {
        for (int i = params.length - 1; i >= 0; i--) {
            SurfaceParams surfaceParams = params[i];
            SurfaceControl surface = surfaceParams.surface;
            applyParams(t, surfaceParams, mTmpFloat9);
        }
    }

    void applyTransaction(Transaction t, long frame) {
        if (mTargetViewRootImpl != null) {
            mTargetViewRootImpl.mergeWithNextTransaction(t, frame);
        } else {
+3 −1
Original line number Diff line number Diff line
@@ -127,7 +127,9 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host {
            // Window doesn't support hardware acceleration, no synchronization for now.
            // TODO(b/149342281): use mViewRoot.mSurface.getNextFrameNumber() to sync on every
            //  frame instead.
            mApplier.applyParams(new SurfaceControl.Transaction(), -1 /* frame */, params);
            final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
            mApplier.applyParams(t, params);
            mApplier.applyTransaction(t, -1);
        }
    }