/**
* 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
* #getBoundsLayer()}. By parenting to this bounds surface, child surfaces can ensure they do
* not draw into the surface inset region set by the parent window.
*/
private SurfaceControl mBoundsLayer;
mBoundsLayer
是子 layer 的容器,它的边界与父相同但调用 setBoundsLayerCrop()
做了裁剪。通过建立父子关系,可以确保子 surface 不会绘制到 insets 区域。
- SurfaceView 的 surface 就是与
mBoundsLayer
建立了父子关系。
public SurfaceControl getBoundsLayer() {
if (mBoundsLayer == null) {
mBoundsLayer = new SurfaceControl.Builder(mSurfaceSession)
.setContainerLayer()
.setName("Bounds for - " + getTitle().toString())
.setParent(getRenderSurfaceControl())
.setCallsite("ViewRootImpl.getBoundsLayer")
.build();
setBoundsLayerCrop();
mTransaction.show(mBoundsLayer).apply();
}
return mBoundsLayer;
}
- 当调用
getBoundsLayer()
时创建。