Merge "BLAST: Two start-up optimizations" into rvc-dev

This commit is contained in:
Rob Carr
2020-04-27 17:20:42 +00:00
committed by Android (Google) Code Review
6 changed files with 45 additions and 22 deletions

View File

@@ -327,6 +327,8 @@ public final class ViewRootImpl implements ViewParent,
private boolean mForceNextConfigUpdate;
private boolean mUseBLASTAdapter;
private boolean mForceDisableBLAST;
private boolean mEnableTripleBuffering;
/**
* Signals that compatibility booleans have been initialized according to
@@ -784,7 +786,6 @@ public final class ViewRootImpl implements ViewParent,
loadSystemProperties();
mImeFocusController = new ImeFocusController(this);
mUseBLASTAdapter = WindowManagerGlobal.useBLAST();
}
public static void addFirstDrawHandler(Runnable callback) {
@@ -925,10 +926,9 @@ public final class ViewRootImpl implements ViewParent,
if (mWindowAttributes.packageName == null) {
mWindowAttributes.packageName = mBasePackageName;
}
if (mUseBLASTAdapter) {
mWindowAttributes.privateFlags |=
mWindowAttributes.privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_USE_BLAST;
}
attrs = mWindowAttributes;
setTag();
@@ -1102,6 +1102,13 @@ public final class ViewRootImpl implements ViewParent,
"Unable to add window -- unknown error code " + res);
}
if ((res & WindowManagerGlobal.ADD_FLAG_USE_BLAST) != 0) {
mUseBLASTAdapter = true;
}
if ((res & WindowManagerGlobal.ADD_FLAG_USE_TRIPLE_BUFFERING) != 0) {
mEnableTripleBuffering = true;
}
if (view instanceof RootViewSurfaceTaker) {
mInputQueueCallback =
((RootViewSurfaceTaker)view).willYouTakeTheInputQueue();
@@ -1414,10 +1421,8 @@ public final class ViewRootImpl implements ViewParent,
}
mWindowAttributes.privateFlags |= compatibleWindowFlag;
if (mUseBLASTAdapter) {
mWindowAttributes.privateFlags |=
mWindowAttributes.privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_USE_BLAST;
}
if (mWindowAttributes.preservePreviousSurfaceInsets) {
// Restore old surface insets.
@@ -1784,7 +1789,7 @@ public final class ViewRootImpl implements ViewParent,
Surface ret = null;
if (mBlastBufferQueue == null) {
mBlastBufferQueue = new BLASTBufferQueue(
mBlastSurfaceControl, width, height);
mBlastSurfaceControl, width, height, mEnableTripleBuffering);
// We only return the Surface the first time, as otherwise
// it hasn't changed and there is no need to update.
ret = mBlastBufferQueue.getSurface();
@@ -7393,7 +7398,7 @@ public final class ViewRootImpl implements ViewParent,
mPendingDisplayCutout, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
mTempControls, mSurfaceSize, mBlastSurfaceControl);
if (mSurfaceControl.isValid()) {
if (!mUseBLASTAdapter) {
if (!useBLAST()) {
mSurface.copyFrom(mSurfaceControl);
} else {
final Surface blastSurface = getOrCreateBLASTSurface(mSurfaceSize.x,
@@ -9760,7 +9765,7 @@ public final class ViewRootImpl implements ViewParent,
* @hide
*/
public SurfaceControl getRenderSurfaceControl() {
if (mUseBLASTAdapter) {
if (useBLAST()) {
return mBlastSurfaceControl;
} else {
return mSurfaceControl;
@@ -9777,11 +9782,11 @@ public final class ViewRootImpl implements ViewParent,
* flag. Needs to be called before addView.
*/
void forceDisableBLAST() {
mUseBLASTAdapter = false;
mForceDisableBLAST = true;
}
boolean useBLAST() {
return mUseBLASTAdapter;
return mUseBLASTAdapter && !mForceDisableBLAST;
}
/**

View File

@@ -124,8 +124,10 @@ public final class WindowManagerGlobal {
*/
public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2;
public static final int ADD_FLAG_IN_TOUCH_MODE = 0x1;
public static final int ADD_FLAG_APP_VISIBLE = 0x2;
public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE;
public static final int ADD_FLAG_USE_TRIPLE_BUFFERING = 0x4;
public static final int ADD_FLAG_USE_BLAST = 0x8;
/**
* Like {@link #RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS}, but as a "hint" when adding the