summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Patrick Williams <pdwilliams@google.com> 2023-08-02 14:29:18 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-08-02 14:29:18 +0000
commit6cb305e12c3060ab1b6cea9cda236f66d7207729 (patch)
treedc7c0189a3b5cd855fa653ab03784b076773bae8
parent8fa4561dda2d18fb7646d03b01c43fa74a0df28d (diff)
parent1cd73f8a6869ed5b600312b7eacbfb6fc2ef0d31 (diff)
Merge "Replace BLASTBufferQueueTest#OutOfOrderTransactionTest" into main
-rw-r--r--libs/gui/tests/BLASTBufferQueue_test.cpp37
-rw-r--r--services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp41
2 files changed, 41 insertions, 37 deletions
diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp
index cce28926ea..cc6f3ddd4e 100644
--- a/libs/gui/tests/BLASTBufferQueue_test.cpp
+++ b/libs/gui/tests/BLASTBufferQueue_test.cpp
@@ -1348,43 +1348,6 @@ TEST_F(BLASTBufferQueueTest, QueryNativeWindowQueuesToWindowComposer) {
ASSERT_EQ(queuesToNativeWindow, 1);
}
-// Test a slow producer doesn't hold up a faster producer from the same client. Essentially tests
-// BBQ uses separate transaction queues.
-TEST_F(BLASTBufferQueueTest, OutOfOrderTransactionTest) {
- sp<SurfaceControl> bgSurface =
- mClient->createSurface(String8("BGTest"), 0, 0, PIXEL_FORMAT_RGBA_8888,
- ISurfaceComposerClient::eFXSurfaceBufferState);
- ASSERT_NE(nullptr, bgSurface.get());
- Transaction t;
- t.setLayerStack(bgSurface, ui::DEFAULT_LAYER_STACK)
- .show(bgSurface)
- .setDataspace(bgSurface, ui::Dataspace::V0_SRGB)
- .setLayer(bgSurface, std::numeric_limits<int32_t>::max() - 1)
- .apply();
-
- BLASTBufferQueueHelper slowAdapter(mSurfaceControl, mDisplayWidth, mDisplayHeight);
- sp<IGraphicBufferProducer> slowIgbProducer;
- setUpProducer(slowAdapter, slowIgbProducer);
- nsecs_t presentTimeDelay = std::chrono::nanoseconds(500ms).count();
- queueBuffer(slowIgbProducer, 0 /* r */, 255 /* g */, 0 /* b */, presentTimeDelay);
-
- BLASTBufferQueueHelper fastAdapter(bgSurface, mDisplayWidth, mDisplayHeight);
- sp<IGraphicBufferProducer> fastIgbProducer;
- setUpProducer(fastAdapter, fastIgbProducer);
- uint8_t r = 255;
- uint8_t g = 0;
- uint8_t b = 0;
- queueBuffer(fastIgbProducer, r, g, b, 0 /* presentTimeDelay */);
- fastAdapter.waitForCallbacks();
-
- // capture screen and verify that it is red
- ASSERT_EQ(NO_ERROR, captureDisplay(mCaptureArgs, mCaptureResults));
-
- ASSERT_NO_FATAL_FAILURE(
- checkScreenCapture(r, g, b,
- {0, 0, (int32_t)mDisplayWidth, (int32_t)mDisplayHeight / 2}));
-}
-
TEST_F(BLASTBufferQueueTest, TransformHint) {
// Transform hint is provided to BBQ via the surface control passed by WM
mSurfaceControl->setTransformHint(ui::Transform::ROT_90);
diff --git a/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp b/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp
index 644b8c70c6..1f2a1edb77 100644
--- a/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp
@@ -306,6 +306,47 @@ public:
~FakeExternalTexture() = default;
};
+TEST_F(TransactionApplicationTest, ApplyTokensUseDifferentQueues) {
+ auto applyToken1 = sp<BBinder>::make();
+ auto applyToken2 = sp<BBinder>::make();
+
+ // Transaction 1 has a buffer with an unfired fence. It should not be ready to be applied.
+ TransactionState transaction1;
+ transaction1.applyToken = applyToken1;
+ transaction1.id = 42069;
+ transaction1.states.emplace_back();
+ transaction1.states[0].state.what |= layer_state_t::eBufferChanged;
+ transaction1.states[0].state.bufferData =
+ std::make_shared<fake::BufferData>(/* bufferId */ 1, /* width */ 1, /* height */ 1,
+ /* pixelFormat */ 0, /* outUsage */ 0);
+ transaction1.states[0].externalTexture =
+ std::make_shared<FakeExternalTexture>(*transaction1.states[0].state.bufferData);
+ transaction1.states[0].state.surface =
+ sp<Layer>::make(LayerCreationArgs(mFlinger.flinger(), nullptr, "TestLayer", 0, {}))
+ ->getHandle();
+ auto fence = sp<mock::MockFence>::make();
+ EXPECT_CALL(*fence, getStatus()).WillRepeatedly(Return(Fence::Status::Unsignaled));
+ transaction1.states[0].state.bufferData->acquireFence = std::move(fence);
+ transaction1.states[0].state.bufferData->flags = BufferData::BufferDataChange::fenceChanged;
+ transaction1.isAutoTimestamp = true;
+
+ // Transaction 2 should be ready to be applied.
+ TransactionState transaction2;
+ transaction2.applyToken = applyToken2;
+ transaction2.id = 2;
+ transaction2.isAutoTimestamp = true;
+
+ mFlinger.setTransactionStateInternal(transaction1);
+ mFlinger.setTransactionStateInternal(transaction2);
+ mFlinger.flushTransactionQueues();
+ auto transactionQueues = mFlinger.getPendingTransactionQueue();
+
+ // Transaction 1 is still in its queue.
+ EXPECT_EQ(transactionQueues[applyToken1].size(), 1u);
+ // Transaction 2 has been dequeued.
+ EXPECT_EQ(transactionQueues[applyToken2].size(), 0u);
+}
+
class LatchUnsignaledTest : public TransactionApplicationTest {
public:
void TearDown() override {