// We don't recreate the surface controls but only recreate the adapter. Since the blast layer
// is still alive, the old buffers will continue to be presented until replaced by buffers from
// the new adapter. This means we do not need to track the old surface control and destroy it
// after the client has drawn to avoid any flickers.
private void createBlastSurfaceControls(ViewRootImpl viewRoot, String name,
        Transaction geometryTransaction) {
    if (mSurfaceControl == null) {
        mSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
                .setName(name)
                .setLocalOwnerView(this)
                .setParent(viewRoot.getBoundsLayer())
                .setCallsite("SurfaceView.updateSurface")
                .setContainerLayer()
                .build();
    }

    if (mBlastSurfaceControl == null) {
        mBlastSurfaceControl = new SurfaceControl.Builder(mSurfaceSession)
                .setName(name + "(BLAST)")
                .setLocalOwnerView(this)
                .setParent(mSurfaceControl)
                .setFlags(mSurfaceFlags)
                .setHidden(false)
                .setBLASTLayer()
                .setCallsite("SurfaceView.updateSurface")
                .build();
    } else {
        // update blast layer
        mTmpTransaction
                .setOpaque(mBlastSurfaceControl, (mSurfaceFlags & SurfaceControl.OPAQUE) != 0)
                .setSecure(mBlastSurfaceControl, (mSurfaceFlags & SurfaceControl.SECURE) != 0)
                .show(mBlastSurfaceControl)
                .apply();
    }

    if (mBackgroundControl == null) {
        mBackgroundControl = createBackgroundControl(name);
    }

    // Always recreate the IGBP for compatibility. This can be optimized in the future but
    // the behavior change will need to be gated by SDK version.
    if (mBlastBufferQueue != null) {
        mBlastBufferQueue.destroy();
    }
    mTransformHint = viewRoot.getBufferTransformHint();
    mBlastSurfaceControl.setTransformHint(mTransformHint);
    mBlastBufferQueue = new BLASTBufferQueue(name);
    mBlastBufferQueue.update(mBlastSurfaceControl, mSurfaceWidth, mSurfaceHeight, mFormat,
            geometryTransaction);
}