diff options
| author | Robert Carr <racarr@google.com> | 2019-07-16 14:28:47 -0700 |
|---|---|---|
| committer | Robert Carr <racarr@google.com> | 2019-10-08 14:36:38 -0700 |
| commit | 48ec4e0b5ca7d5fb65645e06c92b0fd29c974b27 (patch) | |
| tree | b4ee7e9f1dceab909516e4d460f71277036623b1 /core/java/android | |
| parent | 62296e3ddf8cc785e3a68a12e81b2c4ba13799b0 (diff) | |
ViewRootImpl: Add USE_BLAST flag.
Add support for ViewRootImpl submitting buffers using
BLAST and put this support behind a disabled-by-default
FLAG.
Bug: 135786080
Change-Id: Ia3f205e34db9f9aa574c9c2e2c499dd3046af220
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 23 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 54 | ||||
| -rw-r--r-- | core/java/android/view/WindowManager.java | 7 |
3 files changed, 78 insertions, 6 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index b685cf098b33..abc878af7502 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -200,7 +200,10 @@ public final class SurfaceControl implements Parcelable { private final CloseGuard mCloseGuard = CloseGuard.get(); private String mName; - long mNativeObject; // package visibility only for Surface.java access + /** + * @hide + */ + public long mNativeObject; // TODO: Move this to native. private final Object mSizeLock = new Object(); @@ -319,6 +322,11 @@ public final class SurfaceControl implements Parcelable { public static final int FX_SURFACE_CONTAINER = 0x00080000; /** + * @hide + */ + public static final int FX_SURFACE_BLAST = 0x00040000; + + /** * Mask used for FX values above. * * @hide @@ -694,6 +702,14 @@ public final class SurfaceControl implements Parcelable { } /** + * @hide + */ + public Builder setBLASTLayer() { + unsetBufferSize(); + return setFlags(FX_SURFACE_BLAST, FX_SURFACE_MASK); + } + + /** * Indicates whether a 'ContainerLayer' is to be constructed. * * Container layers will not be rendered in any fashion and instead are used @@ -2066,7 +2082,10 @@ public final class SurfaceControl implements Parcelable { public static final NativeAllocationRegistry sRegistry = new NativeAllocationRegistry( Transaction.class.getClassLoader(), nativeGetNativeTransactionFinalizer(), 512); - private long mNativeObject; + /** + * @hide + */ + public long mNativeObject; private final ArrayMap<SurfaceControl, Point> mResizedSurfaces = new ArrayMap<>(); Runnable mFreeNativeResources; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index fedd6fbe56ed..a6087be26abc 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -45,6 +45,7 @@ import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.BLASTBufferQueue; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.FrameInfo; @@ -170,6 +171,8 @@ public final class ViewRootImpl implements ViewParent, */ private static final boolean MT_RENDERER_AVAILABLE = true; + private static final boolean USE_BLAST_BUFFERQUEUE = false; + /** * If set to 2, the view system will switch from using rectangles retrieved from window to * dispatch to the view hierarchy to using {@link InsetsController}, that derives the insets @@ -475,6 +478,9 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage public final Surface mSurface = new Surface(); private final SurfaceControl mSurfaceControl = new SurfaceControl(); + private SurfaceControl mBlastSurfaceControl; + + private BLASTBufferQueue mBlastBufferQueue; /** * Transaction object that can be used to synchronize child SurfaceControl changes with @@ -1282,6 +1288,11 @@ public final class ViewRootImpl implements ViewParent, } mWindowAttributes.privateFlags |= compatibleWindowFlag; + if (USE_BLAST_BUFFERQUEUE) { + mWindowAttributes.privateFlags = + WindowManager.LayoutParams.PRIVATE_FLAG_USE_BLAST; + } + if (mWindowAttributes.preservePreviousSurfaceInsets) { // Restore old surface insets. mWindowAttributes.surfaceInsets.set( @@ -1629,6 +1640,29 @@ public final class ViewRootImpl implements ViewParent, return mBoundsLayer; } + Surface getOrCreateBLASTSurface(int width, int height) { + if (mSurfaceControl == null || !mSurfaceControl.isValid()) { + return null; + } + if (mBlastSurfaceControl == null) { + mBlastSurfaceControl = new SurfaceControl.Builder(mSurfaceSession) + .setParent(mSurfaceControl) + .setName("BLAST") + .setBLASTLayer() + .build(); + mBlastBufferQueue = new BLASTBufferQueue( + mBlastSurfaceControl, width, height); + + } + mBlastBufferQueue.update(mSurfaceControl, width, height); + + mTransaction.show(mBlastSurfaceControl) + .reparent(mBlastSurfaceControl, mSurfaceControl) + .apply(); + + return mBlastBufferQueue.getSurface(); + } + private void setBoundsLayerCrop() { // mWinFrame is already adjusted for surface insets. So offset it and use it as // the cropping bounds. @@ -1658,6 +1692,13 @@ public final class ViewRootImpl implements ViewParent, } mSurface.release(); mSurfaceControl.release(); + + if (mBlastBufferQueue != null) { + mTransaction.remove(mBlastSurfaceControl).apply(); + mBlastSurfaceControl = null; + // We should probably add an explicit dispose. + mBlastBufferQueue = null; + } } /** @@ -2413,10 +2454,9 @@ public final class ViewRootImpl implements ViewParent, // will be transparent if (mAttachInfo.mThreadedRenderer != null) { try { - hwInitialized = mAttachInfo.mThreadedRenderer.initialize( - mSurface); + hwInitialized = mAttachInfo.mThreadedRenderer.initialize(mSurface); if (hwInitialized && (host.mPrivateFlags - & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) == 0) { + & View.PFLAG_REQUEST_TRANSPARENT_REGIONS) == 0) { // Don't pre-allocate if transparent regions // are requested as they may not be needed mAttachInfo.mThreadedRenderer.allocateBuffers(); @@ -7139,7 +7179,13 @@ public final class ViewRootImpl implements ViewParent, mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingDisplayCutout, mPendingMergedConfiguration, mSurfaceControl, mTempInsets); if (mSurfaceControl.isValid()) { - mSurface.copyFrom(mSurfaceControl); + if (USE_BLAST_BUFFERQUEUE == false) { + mSurface.copyFrom(mSurfaceControl); + } else { + mSurface.transferFrom(getOrCreateBLASTSurface( + (int) (mView.getMeasuredWidth() * appScale + 0.5f), + (int) (mView.getMeasuredHeight() * appScale + 0.5f))); + } } else { destroySurface(); } diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 001ab6650551..4a6ef987a642 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1834,6 +1834,13 @@ public interface WindowManager extends ViewManager { public static final int PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC = 0x01000000; /** + * Flag to request creation of a BLAST (Buffer as LayerState) Layer. + * If not specified the client will receive a BufferQueue layer. + * @hide + */ + public static final int PRIVATE_FLAG_USE_BLAST = 0x02000000; + + /** * An internal annotation for flags that can be specified to {@link #softInputMode}. * * @hide |
