From e12e51892aee86b3ca4e7e268afed63006215010 Mon Sep 17 00:00:00 2001 From: chaviw Date: Tue, 8 Feb 2022 11:19:37 -0600 Subject: Add gatherPendingTransactions in BBQ Instead of applying the pending transactions when a frame wasn't rendered, we gather the transactions and merge them with the transaction that will be used to sync. This is to ensure these frames are sent to the caller that requested the sync so they can ensure it's applied at the correct time. Test: Builds and run Bug: 200284684 Change-Id: I087c67138f31cc93e79df42c29464ab4f7989d52 --- graphics/java/android/graphics/BLASTBufferQueue.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'graphics/java') diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java index a9e730d58e65..2678c79d1454 100644 --- a/graphics/java/android/graphics/BLASTBufferQueue.java +++ b/graphics/java/android/graphics/BLASTBufferQueue.java @@ -39,6 +39,8 @@ public final class BLASTBufferQueue { 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); + private static native SurfaceControl.Transaction nativeGatherPendingTransactions(long ptr, + long frameNumber); /** Create a new connection with the surface flinger. */ public BLASTBufferQueue(String name, SurfaceControl sc, int width, int height, @@ -159,4 +161,17 @@ public final class BLASTBufferQueue { public boolean isSameSurfaceControl(SurfaceControl sc) { return nativeIsSameSurfaceControl(mNativeObject, sc.mNativeObject); } + + /** + * Get any transactions that were passed to {@link #mergeWithNextTransaction} with the + * specified frameNumber. This is intended to ensure transactions don't get stuck as pending + * if the specified frameNumber is never drawn. + * + * @param frameNumber The frameNumber used to determine which transactions to apply. + * @return a Transaction that contains the merge of all the transactions that were sent to + * mergeWithNextTransaction + */ + public SurfaceControl.Transaction gatherPendingTransactions(long frameNumber) { + return nativeGatherPendingTransactions(mNativeObject, frameNumber); + } } -- cgit v1.2.3-59-g8ed1b