Merge "Use passed in Transaction when creating bounds layer in VRI" into udc-qpr-dev

This commit is contained in:
Chavi Weingarten
2023-07-07 13:19:41 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 8 deletions

View File

@@ -1340,7 +1340,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
mSurfaceControl = new SurfaceControl.Builder(mSurfaceSession) mSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
.setName(name) .setName(name)
.setLocalOwnerView(this) .setLocalOwnerView(this)
.setParent(viewRoot.getBoundsLayer()) .setParent(viewRoot.updateAndGetBoundsLayer(surfaceUpdateTransaction))
.setCallsite("SurfaceView.updateSurface") .setCallsite("SurfaceView.updateSurface")
.setContainerLayer() .setContainerLayer()
.build(); .build();

View File

@@ -716,9 +716,9 @@ public final class ViewRootImpl implements ViewParent,
/** /**
* Child container layer of {@code mSurface} with the same bounds as its parent, and cropped to * Child container layer of {@code mSurface} with the same bounds as its parent, and cropped to
* the surface insets. This surface is created only if a client requests it via {@link * the surface insets. This surface is created only if a client requests it via
* #getBoundsLayer()}. By parenting to this bounds surface, child surfaces can ensure they do * {@link #updateAndGetBoundsLayer(Transaction)}. By parenting to this bounds surface, child
* not draw into the surface inset region set by the parent window. * surfaces can ensure they do not draw into the surface inset region set by the parent window.
*/ */
private SurfaceControl mBoundsLayer; private SurfaceControl mBoundsLayer;
private final SurfaceSession mSurfaceSession = new SurfaceSession(); private final SurfaceSession mSurfaceSession = new SurfaceSession();
@@ -2262,7 +2262,7 @@ public final class ViewRootImpl implements ViewParent,
* <p>Parenting to this layer will ensure that its children are cropped by the view's surface * <p>Parenting to this layer will ensure that its children are cropped by the view's surface
* insets. * insets.
*/ */
public SurfaceControl getBoundsLayer() { public SurfaceControl updateAndGetBoundsLayer(Transaction t) {
if (mBoundsLayer == null) { if (mBoundsLayer == null) {
mBoundsLayer = new SurfaceControl.Builder(mSurfaceSession) mBoundsLayer = new SurfaceControl.Builder(mSurfaceSession)
.setContainerLayer() .setContainerLayer()
@@ -2270,8 +2270,8 @@ public final class ViewRootImpl implements ViewParent,
.setParent(getSurfaceControl()) .setParent(getSurfaceControl())
.setCallsite("ViewRootImpl.getBoundsLayer") .setCallsite("ViewRootImpl.getBoundsLayer")
.build(); .build();
setBoundsLayerCrop(mTransaction); setBoundsLayerCrop(t);
mTransaction.show(mBoundsLayer).apply(); t.show(mBoundsLayer);
} }
return mBoundsLayer; return mBoundsLayer;
} }
@@ -11188,7 +11188,8 @@ public final class ViewRootImpl implements ViewParent,
@Nullable public SurfaceControl.Transaction buildReparentTransaction( @Nullable public SurfaceControl.Transaction buildReparentTransaction(
@NonNull SurfaceControl child) { @NonNull SurfaceControl child) {
if (mSurfaceControl.isValid()) { if (mSurfaceControl.isValid()) {
return new SurfaceControl.Transaction().reparent(child, getBoundsLayer()); Transaction t = new Transaction();
return t.reparent(child, updateAndGetBoundsLayer(t));
} }
return null; return null;
} }