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

Commit 25c129cc authored by chaviw's avatar chaviw
Browse files

Changed logic about how to check if VRI replaced its surface.

SurfaceView checks if VRI hasn't changed its surface when deciding
whether to call updateRelativeZ in updateSurface. This is to give
surfaceReplaced a chance to send the updateRelativeZ in the same
transaction as swapping the surfaces.

However, SV was only checking generation id, which may not have changed
when using a blast layer. Instead, VRI will increment the sequence id
when the surface has been replaced. SV can check that value and only
do an immediate updateRelativeZ when the sequence id has not changed.

Test: Blast + Split + SV with no flicker
Change-Id: Icdf9f1fbe12fe77052030aa37d808517c5a6cd38
parent ae00abf8
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.AttributeSet;
@@ -225,13 +224,12 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall

    private SurfaceControl.Transaction mRtTransaction = new SurfaceControl.Transaction();
    private SurfaceControl.Transaction mTmpTransaction = new SurfaceControl.Transaction();
    private int mParentSurfaceGenerationId;
    private int mParentSurfaceSequenceId;

    private RemoteAccessibilityController mRemoteAccessibilityController =
        new RemoteAccessibilityController(this);

    private final Matrix mTmpMatrix = new Matrix();
    private final float[] mMatrixValues = new float[9];

    SurfaceControlViewHost.SurfacePackage mSurfacePackage;

@@ -943,11 +941,10 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
            // SurfaceChangedCallback to update the relative z. This is needed so that
            // we do not change the relative z before the server is ready to swap the
            // parent surface.
            if (creating || (mParentSurfaceGenerationId
                    == viewRoot.mSurface.getGenerationId())) {
            if (creating || (mParentSurfaceSequenceId == viewRoot.getSurfaceSequenceId())) {
                updateRelativeZ(mTmpTransaction);
            }
            mParentSurfaceGenerationId = viewRoot.mSurface.getGenerationId();
            mParentSurfaceSequenceId = viewRoot.getSurfaceSequenceId();

            if (mViewVisibility) {
                mTmpTransaction.show(mSurfaceControl);
+14 −1
Original line number Diff line number Diff line
@@ -701,6 +701,11 @@ public final class ViewRootImpl implements ViewParent,

    private HashSet<ScrollCaptureCallback> mRootScrollCaptureCallbacks;

    /**
     * Increment this value when the surface has been replaced.
     */
    private int mSurfaceSequenceId = 0;

    private String mTag = TAG;

    public ViewRootImpl(Context context, Display display) {
@@ -2608,7 +2613,7 @@ public final class ViewRootImpl implements ViewParent,
        boolean surfaceSizeChanged = false;
        boolean surfaceCreated = false;
        boolean surfaceDestroyed = false;
        /* True if surface generation id changes. */
        // True if surface generation id changes or relayout result is RELAYOUT_RES_SURFACE_CHANGED.
        boolean surfaceReplaced = false;

        final boolean windowAttributesChanged = mWindowAttributesChanged;
@@ -2703,6 +2708,7 @@ public final class ViewRootImpl implements ViewParent,
                updateColorModeIfNeeded(lp.getColorMode());
                surfaceCreated = !hadSurface && mSurface.isValid();
                surfaceDestroyed = hadSurface && !mSurface.isValid();

                // When using Blast, the surface generation id may not change when there's a new
                // SurfaceControl. In that case, we also check relayout flag
                // RELAYOUT_RES_SURFACE_CHANGED since it should indicate that WMS created a new
@@ -2711,6 +2717,9 @@ public final class ViewRootImpl implements ViewParent,
                        || (relayoutResult & RELAYOUT_RES_SURFACE_CHANGED)
                        == RELAYOUT_RES_SURFACE_CHANGED)
                        && mSurface.isValid();
                if (surfaceReplaced) {
                    mSurfaceSequenceId++;
                }

                if (cutoutChanged) {
                    mAttachInfo.mDisplayCutout.set(mPendingDisplayCutout);
@@ -9879,4 +9888,8 @@ public final class ViewRootImpl implements ViewParent,
    boolean useBLAST() {
        return mUseBLASTAdapter && !mForceDisableBLAST;
    }

    int getSurfaceSequenceId() {
        return mSurfaceSequenceId;
    }
}