summaryrefslogtreecommitdiff
path: root/graphics/java
diff options
context:
space:
mode:
authorHaamed Gheibi <haamed@google.com>2022-03-09 12:05:14 -0800
committerWeijie Wang <quic_weijiew@quicinc.com>2022-03-15 15:38:25 +0800
commit12bb6d3cbf05cea529a165917c7430af607056f2 (patch)
treeff322630f9716306236ca70ecae1f265ae2aa2c6 /graphics/java
parenta42412b7fc93a0eb852d8bf1a4d001f7df7f43b3 (diff)
Merge SP2A.220305.013
Bug: 220074017 Change-Id: Idfdd94e902f656ac65a2a75dfdd199f6f85ba472
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/BLASTBufferQueue.java18
-rw-r--r--graphics/java/android/graphics/HardwareRenderer.java33
2 files changed, 39 insertions, 12 deletions
diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java
index 5261af2503a2..a45c104a016c 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 nativeSetUndequeuedBufferCount(long ptr, int count);
@@ -36,11 +37,11 @@ public final class BLASTBufferQueue {
private static native void nativeSetNextTransaction(long ptr, long transactionPtr);
private static native void nativeUpdate(long ptr, long surfaceControl, long width, long height,
int format, long transactionPtr);
- private static native void nativeFlushShadowQueue(long ptr);
private static native void nativeMergeWithNextTransaction(long ptr, long transactionPtr,
long frameNumber);
private static native void nativeSetTransactionCompleteCallback(long ptr, long frameNumber,
TransactionCompleteCallback callback);
+ private static native long nativeGetLastAcquiredFrameNum(long ptr);
/**
* Callback sent to {@link #setTransactionCompleteCallback(long, TransactionCompleteCallback)}
@@ -56,7 +57,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() {
@@ -140,10 +145,6 @@ public final class BLASTBufferQueue {
}
}
- public void flushShadowQueue() {
- nativeFlushShadowQueue(mNativeObject);
- }
-
/**
* Merge the transaction passed in to the next transaction in BlastBufferQueue. The next
* transaction will be applied or merged when the next frame with specified frame number
@@ -161,4 +162,7 @@ public final class BLASTBufferQueue {
nativeMergeWithNextTransaction(mNativeObject, nativeTransaction, frameNumber);
}
+ public long getLastAcquiredFrameNum() {
+ return nativeGetLastAcquiredFrameNum(mNativeObject);
+ }
}
diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java
index c3b1cd74d29b..14ad74e12618 100644
--- a/graphics/java/android/graphics/HardwareRenderer.java
+++ b/graphics/java/android/graphics/HardwareRenderer.java
@@ -388,7 +388,8 @@ public class HardwareRenderer {
*/
public @NonNull FrameRenderRequest setFrameCommitCallback(@NonNull Executor executor,
@NonNull Runnable frameCommitCallback) {
- setFrameCompleteCallback(frameNr -> executor.execute(frameCommitCallback));
+ nSetFrameCommitCallback(mNativeProxy,
+ didProduceBuffer -> executor.execute(frameCommitCallback));
return this;
}
@@ -609,6 +610,11 @@ public class HardwareRenderer {
}
/** @hide */
+ public void setFrameCommitCallback(FrameCommitCallback callback) {
+ nSetFrameCommitCallback(mNativeProxy, callback);
+ }
+
+ /** @hide */
public void setFrameCompleteCallback(FrameCompleteCallback callback) {
nSetFrameCompleteCallback(mNativeProxy, callback);
}
@@ -904,13 +910,27 @@ public class HardwareRenderer {
*
* @hide
*/
- public interface FrameCompleteCallback {
+ public interface FrameCommitCallback {
/**
- * Invoked after a frame draw
+ * Invoked after a new frame was drawn
*
- * @param frameNr The id of the frame that was drawn.
+ * @param didProduceBuffer The draw successfully produced a new buffer.
+ */
+ void onFrameCommit(boolean didProduceBuffer);
+ }
+
+ /**
+ * Interface used to be notified when RenderThread has finished an attempt to draw. This doesn't
+ * mean a new frame has drawn, specifically if there's nothing new to draw, but only that
+ * RenderThread had a chance to draw a frame.
+ *
+ * @hide
+ */
+ public interface FrameCompleteCallback {
+ /**
+ * Invoked after a frame draw was attempted.
*/
- void onFrameComplete(long frameNr);
+ void onFrameComplete();
}
/**
@@ -1362,6 +1382,9 @@ public class HardwareRenderer {
private static native void nSetFrameCallback(long nativeProxy, FrameDrawingCallback callback);
+ private static native void nSetFrameCommitCallback(long nativeProxy,
+ FrameCommitCallback callback);
+
private static native void nSetFrameCompleteCallback(long nativeProxy,
FrameCompleteCallback callback);