From fce5b2becedb011d85650ab7aae71669b6863732 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Mon, 6 Dec 2021 16:45:54 -0800 Subject: SurfaceView: Synchronize initial destframe change from BBQ Fixes a case where the SurfaceView is stuck with a wrong scale. Destination frame scales the buffer to the SurfaceView fixed size. Currently the initial destination frame is applied when the first buffer is acquired by BBQ. The transaction is sent via the BBQ apply token. Meanwhile if the client updates the SurfaceView fixed size, the SurfaceView will apply the transaction via the SCC apply token. This can cause destframe changes to be applied out of order causing the app to be stuck with the wrong scale. Bug: 195443440 Test: atest BLASTBufferQueueTest Test: repro steps from bug Change-Id: Ibf53a0efdebb87291d081e48633c373a98d347b1 Merged-In: Ibf53a0efdebb87291d081e48633c373a98d347b1 --- graphics/java/android/graphics/BLASTBufferQueue.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'graphics/java') diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java index 2393eaf32e9a..2faa532a241d 100644 --- a/graphics/java/android/graphics/BLASTBufferQueue.java +++ b/graphics/java/android/graphics/BLASTBufferQueue.java @@ -27,8 +27,9 @@ public final class BLASTBufferQueue { // Note: This field is accessed by native code. public long mNativeObject; // BLASTBufferQueue* - private static native long nativeCreate(String name, long surfaceControl, long width, + 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); private static native void nativeSetNextTransaction(long ptr, long transactionPtr); @@ -54,7 +55,11 @@ public final class BLASTBufferQueue { /** Create a new connection with the surface flinger. */ public BLASTBufferQueue(String name, SurfaceControl sc, int width, int height, @PixelFormat.Format int format) { - mNativeObject = nativeCreate(name, sc.mNativeObject, width, height, format); + mNativeObject = nativeCreateAndUpdate(name, sc.mNativeObject, width, height, format); + } + + public BLASTBufferQueue(String name) { + mNativeObject = nativeCreate(name); } public void destroy() { -- cgit v1.2.3-59-g8ed1b