From 3afbfad181fde57223cc4a15ed3402d4f11cc58d Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Tue, 9 Mar 2021 16:16:38 -0800 Subject: Add async mode tests for BLAST Add some tests to validate dequeue blocking behavior when the IGBP is configured in async mode. We want to validate that in this mode, with or without blast, the client will not be blocked when dequeuing a buffer. Instead, when the client tries to queue a buffer, the bufferqueue will drop the queued buffer if it exists. In async mode, the bufferqueue in the will have an additional buffer so for blast: one buffer will be acquired and presented, one buffer will be acquired in the queue, and the client will have two buffers left for non blocking dequeue. When queuing a buffer, the BQ in the adapter will drop the last queued buffer if available. Test: atest BufferPresentationTests Bug: 176916466 Change-Id: I6ff45c24d6529cc7cd4169f962eb2ca9cbc09943 --- tests/SurfaceViewBufferTests/cpp/SurfaceProxy.cpp | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/SurfaceViewBufferTests/cpp') diff --git a/tests/SurfaceViewBufferTests/cpp/SurfaceProxy.cpp b/tests/SurfaceViewBufferTests/cpp/SurfaceProxy.cpp index ce226fdce320..926ff4d5793c 100644 --- a/tests/SurfaceViewBufferTests/cpp/SurfaceProxy.cpp +++ b/tests/SurfaceViewBufferTests/cpp/SurfaceProxy.cpp @@ -130,6 +130,9 @@ JNIEXPORT jint JNICALL Java_com_android_test_SurfaceProxy_SurfaceDequeueBuffer(J return result; } sBuffers[slot] = anb; + if (timeoutMs == 0) { + return android::OK; + } android::sp fence(new android::Fence(fenceFd)); int waitResult = fence->wait(timeoutMs); if (waitResult != android::OK) { @@ -197,6 +200,28 @@ JNIEXPORT jint JNICALL Java_com_android_test_SurfaceProxy_SurfaceQueueBuffer(JNI return result; } +JNIEXPORT jint JNICALL Java_com_android_test_SurfaceProxy_SurfaceSetAsyncMode(JNIEnv* /* env */, + jclass /* clazz */, + jboolean async) { + assert(sAnw); + android::sp surface = static_cast(sAnw); + return surface->setAsyncMode(async); +} + +JNIEXPORT jint JNICALL Java_com_android_test_SurfaceProxy_SurfaceSetDequeueTimeout( + JNIEnv* /* env */, jclass /* clazz */, jlong timeoutMs) { + assert(sAnw); + android::sp surface = static_cast(sAnw); + return surface->setDequeueTimeout(timeoutMs); +} + +JNIEXPORT jint JNICALL Java_com_android_test_SurfaceProxy_SurfaceSetMaxDequeuedBufferCount( + JNIEnv* /* env */, jclass /* clazz */, jint maxDequeuedBuffers) { + assert(sAnw); + android::sp surface = static_cast(sAnw); + return surface->setMaxDequeuedBufferCount(maxDequeuedBuffers); +} + JNIEXPORT jint JNICALL Java_com_android_test_SurfaceProxy_NativeWindowSetBufferCount( JNIEnv* /* env */, jclass /* clazz */, jint count) { assert(sAnw); -- cgit v1.2.3-59-g8ed1b