Introduce release buffer callback for BufferStateLayer
Currently BLAST clients use the TransactionCompleted callbacks to
determine when to release buffers. The TransactionCompleted callback
is overloaded. For transactions without buffers, the callback is
called when the transaction is applied on the server. If the
Transaction contains one or more buffers, the callback is called when
all the buffers are latched and ready to be presented. If we have
multiple buffers on multiple transactions, where one or more buffers
maybe dropped, the pending callbacks are called together. This may
delay signaling the client when a buffer can be released.
To fix this, we introduce a new buffer release callback that is
called as soon as a buffer is dropped by the server or when a new
buffer has been latched and the buffer will no longer be presented.
This new callback provides a graphic bufferid to identify the buffer
that can be released and a release fence to wait on.
BlastBufferQueue has been switched to use this new callback. Other
BLAST users continue to use the existing callback.
Test: go/wm-smoke
Test: atest ReleaseBufferCallbackTest
Bug: 178385281
Change-Id: Idd88e4994e543443198a5a8cfa0e3f5f67d5d482
diff --git a/services/surfaceflinger/tests/LayerCallback_test.cpp b/services/surfaceflinger/tests/LayerCallback_test.cpp
index aa1cce2..158801a 100644
--- a/services/surfaceflinger/tests/LayerCallback_test.cpp
+++ b/services/surfaceflinger/tests/LayerCallback_test.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wconversion"
-
#include <sys/epoll.h>
#include <gui/DisplayEventReceiver.h>
@@ -25,6 +21,8 @@
#include "LayerTransactionTest.h"
#include "utils/CallbackUtils.h"
+using namespace std::chrono_literals;
+
namespace android {
using android::hardware::graphics::common::V1_1::BufferUsage;
@@ -801,7 +799,7 @@
}
// Try to present 100ms in the future
- nsecs_t time = systemTime() + (100 * 1e6);
+ nsecs_t time = systemTime() + std::chrono::nanoseconds(100ms).count();
transaction.setDesiredPresentTime(time);
transaction.apply();
@@ -825,7 +823,7 @@
}
// Try to present 100ms in the future
- nsecs_t time = systemTime() + (100 * 1e6);
+ nsecs_t time = systemTime() + std::chrono::nanoseconds(100ms).count();
transaction.setDesiredPresentTime(time);
transaction.apply();
@@ -842,7 +840,7 @@
}
// Try to present 33ms after the first frame
- time += (33.3 * 1e6);
+ time += std::chrono::nanoseconds(33ms).count();
transaction.setDesiredPresentTime(time);
transaction.apply();
@@ -870,7 +868,7 @@
}
// Try to present 100ms in the future
- nsecs_t time = systemTime() + (100 * 1e6);
+ nsecs_t time = systemTime() + std::chrono::nanoseconds(100ms).count();
transaction.setDesiredPresentTime(time);
transaction.apply();
@@ -887,7 +885,7 @@
}
// Try to present 33ms before the previous frame
- time -= (33.3 * 1e6);
+ time -= std::chrono::nanoseconds(33ms).count();
transaction.setDesiredPresentTime(time);
transaction.apply();
@@ -914,7 +912,7 @@
}
// Try to present 100ms in the past
- nsecs_t time = systemTime() - (100 * 1e6);
+ nsecs_t time = systemTime() - std::chrono::nanoseconds(100ms).count();
transaction.setDesiredPresentTime(time);
transaction.apply();
@@ -948,6 +946,3 @@
}
} // namespace android
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic pop // ignored "-Wconversion"