summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/SurfaceView.java9
-rw-r--r--core/java/android/view/ViewRootImpl.java15
2 files changed, 17 insertions, 7 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index e3067a664f2e..7b6a4f877d02 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -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);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 35c21c55121f..52357402877a 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -702,6 +702,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) {
@@ -2609,7 +2614,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;
@@ -2704,6 +2709,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
@@ -2712,6 +2718,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);
@@ -9917,4 +9926,8 @@ public final class ViewRootImpl implements ViewParent,
boolean useBLAST() {
return mUseBLASTAdapter && !mForceDisableBLAST;
}
+
+ int getSurfaceSequenceId() {
+ return mSurfaceSequenceId;
+ }
}