From 6d16c8c340eace35b0ea40496918edae47082f85 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Fri, 21 Feb 2020 12:04:31 -0800 Subject: RESTRICT AUTOMERGE - Explicitly disable BLAST for SurfaceControlViewHost surfaces Right now it crashes because the ViewRoot expects to receive a BLAST surface but the WindowlessWindowManager doesn't support it. Adding support should be relatively trivial (coming in a follow-up) but we haven't tested it yet so suggesting merging this patch for today. Bug: 150000636 Test: Existing tests pass Change-Id: I4b36d190c8f4f022dada656e02452034113a4000 (cherry picked from commit b4727e0f55a83dae0dff09dcdcde92d9eabc71a5) --- core/java/android/view/SurfaceView.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'core/java/android/view/SurfaceView.java') diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 341cf397a38f..fb7c04afeab0 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -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 * be protected by a lock. */ - final boolean useBLAST = WindowManagerGlobal.useBLAST(); + final boolean useBLAST = viewRoot.useBLAST(); viewRoot.registerRtFrameCallback(frame -> { try { final SurfaceControl.Transaction t = useBLAST ? @@ -930,7 +930,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall mSurfaceHeight); } } else if ((layoutSizeChanged || positionChanged) && - WindowManagerGlobal.useBLAST()) { + viewRoot.useBLAST()) { viewRoot.setUseBLASTSyncTransaction(); } mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius); @@ -1132,9 +1132,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall private void applySurfaceTransforms(SurfaceControl surface, SurfaceControl.Transaction t, 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(), frameNumber); } @@ -1150,8 +1149,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall } private void setParentSpaceRectangle(Rect position, long frameNumber) { - final boolean useBLAST = WindowManagerGlobal.useBLAST(); final ViewRootImpl viewRoot = getViewRootImpl(); + final boolean useBLAST = viewRoot.useBLAST(); final SurfaceControl.Transaction t = useBLAST ? viewRoot.getBLASTSyncTransaction() : mRtTransaction; @@ -1211,7 +1210,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall @Override public void positionLost(long frameNumber) { - boolean useBLAST = WindowManagerGlobal.useBLAST(); + final ViewRootImpl viewRoot = getViewRootImpl(); + boolean useBLAST = viewRoot != null && viewRoot.useBLAST(); if (DEBUG) { Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d", System.identityHashCode(this), frameNumber)); @@ -1222,8 +1222,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall return; } - final ViewRootImpl viewRoot = getViewRootImpl(); - final SurfaceControl.Transaction t = useBLAST ? (viewRoot != null ? viewRoot.getBLASTSyncTransaction() : mRtTransaction) : mRtTransaction; -- cgit v1.2.3