Loading core/java/android/view/SurfaceControl.java +21 −2 Original line number Diff line number Diff line Loading @@ -199,7 +199,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(); Loading Loading @@ -317,6 +320,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. * Loading Loading @@ -692,6 +700,14 @@ public final class SurfaceControl implements Parcelable { return (mFlags & FX_SURFACE_DIM) == FX_SURFACE_DIM; } /** * @hide */ public Builder setBLASTLayer() { unsetBufferSize(); return setFlags(FX_SURFACE_BLAST, FX_SURFACE_MASK); } /** * Indicates whether a 'ContainerLayer' is to be constructed. * Loading Loading @@ -1951,7 +1967,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; Loading core/java/android/view/ViewRootImpl.java +50 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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( Loading Loading @@ -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. Loading Loading @@ -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; } } /** Loading Loading @@ -2413,8 +2454,7 @@ 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) { // Don't pre-allocate if transparent regions Loading Loading @@ -7139,7 +7179,13 @@ public final class ViewRootImpl implements ViewParent, mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingDisplayCutout, mPendingMergedConfiguration, mSurfaceControl, mTempInsets); if (mSurfaceControl.isValid()) { 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(); } Loading core/java/android/view/WindowManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -1833,6 +1833,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}. * Loading core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ cc_library_shared { "android_view_RenderNodeAnimator.cpp", "android_view_Surface.cpp", "android_view_SurfaceControl.cpp", "android_graphics_BLASTBufferQueue.cpp", "android_view_SurfaceSession.cpp", "android_view_TextureView.cpp", "android_view_VelocityTracker.cpp", Loading core/jni/AndroidRuntime.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ extern int register_android_util_MemoryIntArray(JNIEnv* env); extern int register_android_content_StringBlock(JNIEnv* env); extern int register_android_content_XmlBlock(JNIEnv* env); extern int register_android_content_res_ApkAssets(JNIEnv* env); extern int register_android_graphics_BLASTBufferQueue(JNIEnv* env); extern int register_android_view_DisplayEventReceiver(JNIEnv* env); extern int register_android_view_InputApplicationHandle(JNIEnv* env); extern int register_android_view_InputWindowHandle(JNIEnv* env); Loading Loading @@ -1458,10 +1459,9 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_opengl_jni_GLES31), REG_JNI(register_android_opengl_jni_GLES31Ext), REG_JNI(register_android_opengl_jni_GLES32), REG_JNI(register_android_graphics_classes), REG_JNI(register_android_graphics_BLASTBufferQueue), REG_JNI(register_android_graphics_GraphicBuffer), REG_JNI(register_android_database_CursorWindow), REG_JNI(register_android_database_SQLiteConnection), REG_JNI(register_android_database_SQLiteGlobal), Loading Loading
core/java/android/view/SurfaceControl.java +21 −2 Original line number Diff line number Diff line Loading @@ -199,7 +199,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(); Loading Loading @@ -317,6 +320,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. * Loading Loading @@ -692,6 +700,14 @@ public final class SurfaceControl implements Parcelable { return (mFlags & FX_SURFACE_DIM) == FX_SURFACE_DIM; } /** * @hide */ public Builder setBLASTLayer() { unsetBufferSize(); return setFlags(FX_SURFACE_BLAST, FX_SURFACE_MASK); } /** * Indicates whether a 'ContainerLayer' is to be constructed. * Loading Loading @@ -1951,7 +1967,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; Loading
core/java/android/view/ViewRootImpl.java +50 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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( Loading Loading @@ -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. Loading Loading @@ -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; } } /** Loading Loading @@ -2413,8 +2454,7 @@ 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) { // Don't pre-allocate if transparent regions Loading Loading @@ -7139,7 +7179,13 @@ public final class ViewRootImpl implements ViewParent, mPendingStableInsets, mPendingOutsets, mPendingBackDropFrame, mPendingDisplayCutout, mPendingMergedConfiguration, mSurfaceControl, mTempInsets); if (mSurfaceControl.isValid()) { 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(); } Loading
core/java/android/view/WindowManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -1833,6 +1833,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}. * Loading
core/jni/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ cc_library_shared { "android_view_RenderNodeAnimator.cpp", "android_view_Surface.cpp", "android_view_SurfaceControl.cpp", "android_graphics_BLASTBufferQueue.cpp", "android_view_SurfaceSession.cpp", "android_view_TextureView.cpp", "android_view_VelocityTracker.cpp", Loading
core/jni/AndroidRuntime.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ extern int register_android_util_MemoryIntArray(JNIEnv* env); extern int register_android_content_StringBlock(JNIEnv* env); extern int register_android_content_XmlBlock(JNIEnv* env); extern int register_android_content_res_ApkAssets(JNIEnv* env); extern int register_android_graphics_BLASTBufferQueue(JNIEnv* env); extern int register_android_view_DisplayEventReceiver(JNIEnv* env); extern int register_android_view_InputApplicationHandle(JNIEnv* env); extern int register_android_view_InputWindowHandle(JNIEnv* env); Loading Loading @@ -1458,10 +1459,9 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_opengl_jni_GLES31), REG_JNI(register_android_opengl_jni_GLES31Ext), REG_JNI(register_android_opengl_jni_GLES32), REG_JNI(register_android_graphics_classes), REG_JNI(register_android_graphics_BLASTBufferQueue), REG_JNI(register_android_graphics_GraphicBuffer), REG_JNI(register_android_database_CursorWindow), REG_JNI(register_android_database_SQLiteConnection), REG_JNI(register_android_database_SQLiteGlobal), Loading