Merge "RESTRICT AUTOMERGE - Explicitly disable BLAST for SurfaceControlViewHost surfaces" into rvc-dev

This commit is contained in:
Valerie Hau
2020-02-24 18:52:13 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 10 deletions

View File

@@ -111,6 +111,7 @@ public class SurfaceControlViewHost {
@NonNull WindowlessWindowManager wwm) { @NonNull WindowlessWindowManager wwm) {
mWm = wwm; mWm = wwm;
mViewRoot = new ViewRootImpl(c, d, mWm); mViewRoot = new ViewRootImpl(c, d, mWm);
mViewRoot.forceDisableBLAST();
mAccessibilityEmbeddedConnection = mViewRoot.getAccessibilityEmbeddedConnection(); mAccessibilityEmbeddedConnection = mViewRoot.getAccessibilityEmbeddedConnection();
} }
@@ -135,6 +136,7 @@ public class SurfaceControlViewHost {
mWm = new WindowlessWindowManager(context.getResources().getConfiguration(), mWm = new WindowlessWindowManager(context.getResources().getConfiguration(),
mSurfaceControl, hostToken); mSurfaceControl, hostToken);
mViewRoot = new ViewRootImpl(context, display, mWm); mViewRoot = new ViewRootImpl(context, display, mWm);
mViewRoot.forceDisableBLAST();
mAccessibilityEmbeddedConnection = mViewRoot.getAccessibilityEmbeddedConnection(); mAccessibilityEmbeddedConnection = mViewRoot.getAccessibilityEmbeddedConnection();
} }

View File

@@ -392,7 +392,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
* This gets called on a RenderThread worker thread, so members accessed here must * This gets called on a RenderThread worker thread, so members accessed here must
* be protected by a lock. * be protected by a lock.
*/ */
final boolean useBLAST = WindowManagerGlobal.useBLAST(); final boolean useBLAST = viewRoot.useBLAST();
viewRoot.registerRtFrameCallback(frame -> { viewRoot.registerRtFrameCallback(frame -> {
try { try {
final SurfaceControl.Transaction t = useBLAST ? final SurfaceControl.Transaction t = useBLAST ?
@@ -930,7 +930,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
mSurfaceHeight); mSurfaceHeight);
} }
} else if ((layoutSizeChanged || positionChanged) && } else if ((layoutSizeChanged || positionChanged) &&
WindowManagerGlobal.useBLAST()) { viewRoot.useBLAST()) {
viewRoot.setUseBLASTSyncTransaction(); viewRoot.setUseBLASTSyncTransaction();
} }
mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius); mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius);
@@ -1132,9 +1132,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
private void applySurfaceTransforms(SurfaceControl surface, SurfaceControl.Transaction t, private void applySurfaceTransforms(SurfaceControl surface, SurfaceControl.Transaction t,
Rect position, long frameNumber) { Rect position, long frameNumber) {
if (frameNumber > 0 && !WindowManagerGlobal.useBLAST()) { final ViewRootImpl viewRoot = getViewRootImpl();
final ViewRootImpl viewRoot = getViewRootImpl(); if (frameNumber > 0 && viewRoot != null && !viewRoot.useBLAST()) {
t.deferTransactionUntil(surface, viewRoot.getRenderSurfaceControl(), t.deferTransactionUntil(surface, viewRoot.getRenderSurfaceControl(),
frameNumber); frameNumber);
} }
@@ -1150,8 +1149,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
} }
private void setParentSpaceRectangle(Rect position, long frameNumber) { private void setParentSpaceRectangle(Rect position, long frameNumber) {
final boolean useBLAST = WindowManagerGlobal.useBLAST();
final ViewRootImpl viewRoot = getViewRootImpl(); final ViewRootImpl viewRoot = getViewRootImpl();
final boolean useBLAST = viewRoot.useBLAST();
final SurfaceControl.Transaction t = useBLAST ? viewRoot.getBLASTSyncTransaction() : final SurfaceControl.Transaction t = useBLAST ? viewRoot.getBLASTSyncTransaction() :
mRtTransaction; mRtTransaction;
@@ -1211,7 +1210,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
@Override @Override
public void positionLost(long frameNumber) { public void positionLost(long frameNumber) {
boolean useBLAST = WindowManagerGlobal.useBLAST(); final ViewRootImpl viewRoot = getViewRootImpl();
boolean useBLAST = viewRoot != null && viewRoot.useBLAST();
if (DEBUG) { if (DEBUG) {
Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d", Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
System.identityHashCode(this), frameNumber)); System.identityHashCode(this), frameNumber));
@@ -1222,8 +1222,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
return; return;
} }
final ViewRootImpl viewRoot = getViewRootImpl();
final SurfaceControl.Transaction t = useBLAST ? final SurfaceControl.Transaction t = useBLAST ?
(viewRoot != null ? viewRoot.getBLASTSyncTransaction() : mRtTransaction) : (viewRoot != null ? viewRoot.getBLASTSyncTransaction() : mRtTransaction) :
mRtTransaction; mRtTransaction;

View File

@@ -322,7 +322,7 @@ public final class ViewRootImpl implements ViewParent,
*/ */
private boolean mForceNextConfigUpdate; private boolean mForceNextConfigUpdate;
private final boolean mUseBLASTAdapter; private boolean mUseBLASTAdapter;
/** /**
* Signals that compatibility booleans have been initialized according to * Signals that compatibility booleans have been initialized according to
@@ -9639,4 +9639,16 @@ public final class ViewRootImpl implements ViewParent,
public void onDescendantUnbufferedRequested() { public void onDescendantUnbufferedRequested() {
mUnbufferedInputSource = mView.mUnbufferedInputSource; mUnbufferedInputSource = mView.mUnbufferedInputSource;
} }
/**
* Force disabling use of the BLAST adapter regardless of the system
* flag. Needs to be called before addView.
*/
void forceDisableBLAST() {
mUseBLASTAdapter = false;
}
boolean useBLAST() {
return mUseBLASTAdapter;
}
} }