diff options
| author | 2021-12-28 14:30:45 -0800 | |
|---|---|---|
| committer | 2021-12-29 00:47:40 +0000 | |
| commit | daa281da189a12226869f3e981b8fb20619fbd84 (patch) | |
| tree | e475cbd5ca1e3b66be0a0a8bee72e7c75284fc0a /graphics/java/android | |
| parent | 0e27aa3be60780ff64db48af11adc3c7d47bfec4 (diff) | |
BBQ: Recreate BBQ when SurfaceControl changes 2/2
Alternative approach to fab15e55446080bdcfc05ba315e8ef914b0a6f65 which
was racy because the disconnect callback is called without the
BQ lock and the client can continue to modify the BQ state after
disconnecting from the queue.
This approach resets the BQ and BBQ states when the SurfaceControl is
updated. This solves one concrete problem of not relying on the old
SurfaceControl to be destroyed in order to release the currently presented
buffer back to BQ.
In addition this change resets the sync state in BBQ with the rationale
the system does not want to sync on buffers presented on an older
SurfaceControl.
Bug: 197269223
Test: atest BLASTBufferQueueTest
Test: labtest ag/16407859 cf-foldable * 3 (b/197269223#comment40)
Change-Id: I137d3284c4e9216963f9c672f192afd334501ee5
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/BLASTBufferQueue.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java index 8d3eadb8496d..a9e730d58e65 100644 --- a/graphics/java/android/graphics/BLASTBufferQueue.java +++ b/graphics/java/android/graphics/BLASTBufferQueue.java @@ -27,8 +27,6 @@ public final class BLASTBufferQueue { // Note: This field is accessed by native code. public long mNativeObject; // BLASTBufferQueue* - private static native long nativeCreateAndUpdate(String name, long surfaceControl, long width, - long height, int format); private static native long nativeCreate(String name); private static native void nativeDestroy(long ptr); private static native Surface nativeGetSurface(long ptr, boolean includeSurfaceControlHandle); @@ -40,11 +38,13 @@ public final class BLASTBufferQueue { long frameNumber); private static native long nativeGetLastAcquiredFrameNum(long ptr); private static native void nativeApplyPendingTransactions(long ptr, long frameNumber); + private static native boolean nativeIsSameSurfaceControl(long ptr, long surfaceControlPtr); /** Create a new connection with the surface flinger. */ public BLASTBufferQueue(String name, SurfaceControl sc, int width, int height, @PixelFormat.Format int format) { - mNativeObject = nativeCreateAndUpdate(name, sc.mNativeObject, width, height, format); + this(name); + update(sc, width, height, format); } public BLASTBufferQueue(String name) { @@ -152,4 +152,11 @@ public final class BLASTBufferQueue { public long getLastAcquiredFrameNum() { return nativeGetLastAcquiredFrameNum(mNativeObject); } + + /** + * @return True if the associated SurfaceControl has the same handle as {@param sc}. + */ + public boolean isSameSurfaceControl(SurfaceControl sc) { + return nativeIsSameSurfaceControl(mNativeObject, sc.mNativeObject); + } } |