summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ViewRootImpl.java19
-rw-r--r--core/jni/android_graphics_BLASTBufferQueue.cpp8
-rw-r--r--graphics/java/android/graphics/BLASTBufferQueue.java5
3 files changed, 25 insertions, 7 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 52357402877a..93c2787ede2e 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3881,10 +3881,6 @@ public final class ViewRootImpl implements ViewParent,
}
private void addFrameCallbackIfNeeded() {
- if (!mNextDrawUseBLASTSyncTransaction) {
- return;
- }
-
// Frame callbacks will always occur after submitting draw requests and before
// the draw actually occurs. This will ensure that we set the next transaction
// for the frame that's about to get drawn and not on a previous frame that.
@@ -3892,8 +3888,19 @@ public final class ViewRootImpl implements ViewParent,
// This is thread safe since mRtNextFrameReportConsumeWithBlast will only be
// modified in onFrameDraw and then again in onFrameComplete. This is to ensure the
// next frame completed should be reported with the blast sync transaction.
- registerRtFrameCallback(createFrameDrawingCallback());
- mNextDrawUseBLASTSyncTransaction = false;
+ if (mNextDrawUseBLASTSyncTransaction) {
+ registerRtFrameCallback(createFrameDrawingCallback());
+ mNextDrawUseBLASTSyncTransaction = false;
+ } else if (mReportNextDraw) {
+ registerRtFrameCallback(frame -> {
+ if (mBlastBufferQueue != null) {
+ // If we need to report next draw, wait for adapter to flush its shadow queue
+ // by processing previously queued buffers so that we can submit the
+ // transaction a timely manner.
+ mBlastBufferQueue.flushShadowQueue();
+ }
+ });
+ }
}
private void performDraw() {
diff --git a/core/jni/android_graphics_BLASTBufferQueue.cpp b/core/jni/android_graphics_BLASTBufferQueue.cpp
index a30c37bbd11c..b07c29307339 100644
--- a/core/jni/android_graphics_BLASTBufferQueue.cpp
+++ b/core/jni/android_graphics_BLASTBufferQueue.cpp
@@ -69,13 +69,19 @@ static void nativeUpdate(JNIEnv*env, jclass clazz, jlong ptr, jlong surfaceContr
queue->update(reinterpret_cast<SurfaceControl*>(surfaceControl), width, height);
}
+static void nativeFlushShadowQueue(JNIEnv* env, jclass clazz, jlong ptr) {
+ sp<BLASTBufferQueue> queue = reinterpret_cast<BLASTBufferQueue*>(ptr);
+ queue->flushShadowQueue();
+}
+
static const JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
{"nativeCreate", "(Ljava/lang/String;JJJZ)J", (void*)nativeCreate},
{"nativeGetSurface", "(J)Landroid/view/Surface;", (void*)nativeGetSurface},
{"nativeDestroy", "(J)V", (void*)nativeDestroy},
{"nativeSetNextTransaction", "(JJ)V", (void*)nativeSetNextTransaction},
- {"nativeUpdate", "(JJJJ)V", (void*)nativeUpdate}};
+ {"nativeUpdate", "(JJJJ)V", (void*)nativeUpdate},
+ {"nativeFlushShadowQueue", "(J)V", (void*)nativeFlushShadowQueue}};
int register_android_graphics_BLASTBufferQueue(JNIEnv* env) {
int res = jniRegisterNativeMethods(env, "android/graphics/BLASTBufferQueue",
diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java
index 4c0f890eee40..8284042c4dca 100644
--- a/graphics/java/android/graphics/BLASTBufferQueue.java
+++ b/graphics/java/android/graphics/BLASTBufferQueue.java
@@ -32,6 +32,7 @@ public final class BLASTBufferQueue {
private static native Surface nativeGetSurface(long ptr);
private static native void nativeSetNextTransaction(long ptr, long transactionPtr);
private static native void nativeUpdate(long ptr, long surfaceControl, long width, long height);
+ private static native void nativeFlushShadowQueue(long ptr);
/** Create a new connection with the surface flinger. */
public BLASTBufferQueue(String name, SurfaceControl sc, int width, int height,
@@ -69,4 +70,8 @@ public final class BLASTBufferQueue {
super.finalize();
}
}
+
+ public void flushShadowQueue() {
+ nativeFlushShadowQueue(mNativeObject);
+ }
}